[gtk/listview-for-merge: 154/174] inspector: Make Controller page a GtkWidget



commit 53623c2df6445ef8e449ce8efc3e403775efae23
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 9 00:43:41 2019 +0100

    inspector: Make Controller page a GtkWidget

 gtk/inspector/controllers.c | 49 +++++++++++++++++++++++++++++----------------
 gtk/inspector/controllers.h |  4 ++--
 2 files changed, 34 insertions(+), 19 deletions(-)
---
diff --git a/gtk/inspector/controllers.c b/gtk/inspector/controllers.c
index ad5181b89e..fa41af9b65 100644
--- a/gtk/inspector/controllers.c
+++ b/gtk/inspector/controllers.c
@@ -21,8 +21,9 @@
 #include "controllers.h"
 #include "object-tree.h"
 
-#include "gtksizegroup.h"
+#include "gtkbinlayout.h"
 #include "gtkcomboboxtext.h"
+#include "gtkcustomsorter.h"
 #include "gtkflattenlistmodel.h"
 #include "gtkframe.h"
 #include "gtkgesture.h"
@@ -31,15 +32,15 @@
 #include "gtkmaplistmodel.h"
 #include "gtkpropertylookuplistmodelprivate.h"
 #include "gtkscrolledwindow.h"
+#include "gtksizegroup.h"
 #include "gtksortlistmodel.h"
-#include "gtkwidgetprivate.h"
 #include "gtkstack.h"
 #include "gtkstylecontext.h"
-#include "gtkcustomsorter.h"
+#include "gtkwidgetprivate.h"
 
 struct _GtkInspectorControllers
 {
-  GtkBox parent_instance;
+  GtkWidget parent_instance;
 
   GtkWidget *listbox;
   GtkPropertyLookupListModel *model;
@@ -49,7 +50,7 @@ struct _GtkInspectorControllers
 
 struct _GtkInspectorControllersClass
 {
-  GtkBoxClass parent_class;
+  GtkWidgetClass parent_class;
 };
 
 enum
@@ -58,7 +59,7 @@ enum
   PROP_OBJECT_TREE
 };
 
-G_DEFINE_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK_TYPE_BOX)
+G_DEFINE_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK_TYPE_WIDGET)
 
 static void
 row_activated (GtkListBox              *box,
@@ -98,7 +99,7 @@ gtk_inspector_controllers_init (GtkInspectorControllers *self)
   gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->listbox), GTK_SELECTION_NONE);
   gtk_box_append (GTK_BOX (box), self->listbox);
 
-  gtk_box_append (GTK_BOX (self), sw);
+  gtk_widget_set_parent (sw, GTK_WIDGET (self));
 }
 
 static void
@@ -260,10 +261,10 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
 }
 
 static void
-get_property (GObject    *object,
-              guint       param_id,
-              GValue     *value,
-              GParamSpec *pspec)
+gtk_inspector_controllers_get_property (GObject    *object,
+                                        guint       param_id,
+                                        GValue     *value,
+                                        GParamSpec *pspec)
 {
   GtkInspectorControllers *self = GTK_INSPECTOR_CONTROLLERS (object);
 
@@ -280,10 +281,10 @@ get_property (GObject    *object,
 }
 
 static void
-set_property (GObject      *object,
-              guint         param_id,
-              const GValue *value,
-              GParamSpec   *pspec)
+gtk_inspector_controllers_set_property (GObject      *object,
+                                        guint         param_id,
+                                        const GValue *value,
+                                        GParamSpec   *pspec)
 {
   GtkInspectorControllers *self = GTK_INSPECTOR_CONTROLLERS (object);
 
@@ -299,17 +300,31 @@ set_property (GObject      *object,
     }
 }
 
+static void
+gtk_inspector_controllers_dispose (GObject *object)
+{
+  GtkInspectorControllers *self = GTK_INSPECTOR_CONTROLLERS (object);
+
+  gtk_widget_unparent (gtk_widget_get_first_child (GTK_WIDGET (self)));
+
+  G_OBJECT_CLASS (gtk_inspector_controllers_parent_class)->dispose (object);
+}
+
 static void
 gtk_inspector_controllers_class_init (GtkInspectorControllersClass *klass)
 {
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  object_class->get_property = get_property;
-  object_class->set_property = set_property;
+  object_class->get_property = gtk_inspector_controllers_get_property;
+  object_class->set_property = gtk_inspector_controllers_set_property;
+  object_class->dispose= gtk_inspector_controllers_dispose;
 
   g_object_class_install_property (object_class, PROP_OBJECT_TREE,
       g_param_spec_object ("object-tree", "Widget Tree", "Widget tree",
                            GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 }
 
 // vim: set et sw=2 ts=2:
diff --git a/gtk/inspector/controllers.h b/gtk/inspector/controllers.h
index d4c884cb0d..d4df218b88 100644
--- a/gtk/inspector/controllers.h
+++ b/gtk/inspector/controllers.h
@@ -18,13 +18,13 @@
 #ifndef _GTK_INSPECTOR_CONTROLLERS_H_
 #define _GTK_INSPECTOR_CONTROLLERS_H_
 
-#include <gtk/gtk.h>
+#include <gtk/gtkwidget.h>
 
 G_BEGIN_DECLS
 
 #define GTK_TYPE_INSPECTOR_CONTROLLERS gtk_inspector_controllers_get_type()
 
-G_DECLARE_FINAL_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK, INSPECTOR_CONTROLLERS, GtkBox)
+G_DECLARE_FINAL_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK, INSPECTOR_CONTROLLERS, 
GtkWidget)
 
 void            gtk_inspector_controllers_set_object            (GtkInspectorControllers        *sl,
                                                                  GObject                        *object);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]