[gtk/wip/otte/listview: 163/169] inspector: Make Controller page a GtkWidget



commit 8c5d87c03bd038adbbd808c993799d16e16c787f
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 3cfd00ab2b..ef6a743dac 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_container_add (GTK_CONTAINER (box), self->listbox);
 
-  gtk_container_add (GTK_CONTAINER (self), sw);
+  gtk_widget_set_parent (sw, GTK_WIDGET (self));
 }
 
 static void
@@ -257,10 +258,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);
 
@@ -277,10 +278,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);
 
@@ -296,17 +297,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]