[gtk/listview-for-merge: 148/180] inspector: Remove private struct from controllers



commit 5d7397a00cbe114d6112e11cd779d28f28e03b51
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 9 00:36:59 2019 +0100

    inspector: Remove private struct from controllers

 gtk/inspector/controllers.c | 79 ++++++++++++++++++++++++---------------------
 gtk/inspector/controllers.h | 27 +++-------------
 2 files changed, 46 insertions(+), 60 deletions(-)
---
diff --git a/gtk/inspector/controllers.c b/gtk/inspector/controllers.c
index 2e926675d7..ad5181b89e 100644
--- a/gtk/inspector/controllers.c
+++ b/gtk/inspector/controllers.c
@@ -37,40 +37,46 @@
 #include "gtkstylecontext.h"
 #include "gtkcustomsorter.h"
 
-enum
+struct _GtkInspectorControllers
 {
-  PROP_0,
-  PROP_OBJECT_TREE
-};
+  GtkBox parent_instance;
 
-struct _GtkInspectorControllersPrivate
-{
   GtkWidget *listbox;
   GtkPropertyLookupListModel *model;
   GtkSizeGroup *sizegroup;
   GtkInspectorObjectTree *object_tree;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorControllers, gtk_inspector_controllers, GTK_TYPE_BOX)
+struct _GtkInspectorControllersClass
+{
+  GtkBoxClass parent_class;
+};
+
+enum
+{
+  PROP_0,
+  PROP_OBJECT_TREE
+};
+
+G_DEFINE_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK_TYPE_BOX)
 
 static void
 row_activated (GtkListBox              *box,
                GtkListBoxRow           *row,
-               GtkInspectorControllers *sl)
+               GtkInspectorControllers *self)
 {
   GObject *controller;
   
   controller = G_OBJECT (g_object_get_data (G_OBJECT (row), "controller"));
-  gtk_inspector_object_tree_select_object (sl->priv->object_tree, controller);
+  gtk_inspector_object_tree_select_object (self->object_tree, controller);
 }
 
 static void
-gtk_inspector_controllers_init (GtkInspectorControllers *sl)
+gtk_inspector_controllers_init (GtkInspectorControllers *self)
 {
   GtkWidget *sw, *box;
 
-  sl->priv = gtk_inspector_controllers_get_instance_private (sl);
-  sl->priv->sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+  self->sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   sw = gtk_scrolled_window_new (NULL, NULL);
 
@@ -85,19 +91,19 @@ gtk_inspector_controllers_init (GtkInspectorControllers *sl)
   gtk_widget_set_hexpand (box, TRUE);
   gtk_widget_set_vexpand (box, TRUE);
 
-  sl->priv->listbox = gtk_list_box_new ();
-  gtk_widget_add_css_class (sl->priv->listbox, "frame");
-  gtk_widget_set_halign (sl->priv->listbox, GTK_ALIGN_CENTER);
-  g_signal_connect (sl->priv->listbox, "row-activated", G_CALLBACK (row_activated), sl);
-  gtk_list_box_set_selection_mode (GTK_LIST_BOX (sl->priv->listbox), GTK_SELECTION_NONE);
-  gtk_box_append (GTK_BOX (box), sl->priv->listbox);
+  self->listbox = gtk_list_box_new ();
+  gtk_widget_add_css_class (self->listbox, "frame");
+  gtk_widget_set_halign (self->listbox, GTK_ALIGN_CENTER);
+  g_signal_connect (self->listbox, "row-activated", G_CALLBACK (row_activated), 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 (sl), sw);
+  gtk_box_append (GTK_BOX (self), sw);
 }
 
 static void
 phase_changed_cb (GtkComboBox             *combo,
-                  GtkInspectorControllers *sl)
+                  GtkInspectorControllers *self)
 {
   GtkWidget *row;
   GtkPropagationPhase phase;
@@ -113,8 +119,8 @@ static GtkWidget *
 create_controller_widget (gpointer item,
                           gpointer user_data)
 {
+  GtkInspectorControllers *self = user_data;
   GtkEventController *controller = item;
-  GtkInspectorControllers *sl = user_data;
   GtkWidget *row;
   GtkWidget *box;
   GtkWidget *label;
@@ -131,7 +137,7 @@ create_controller_widget (gpointer item,
   label = gtk_label_new (G_OBJECT_TYPE_NAME (controller));
   g_object_set (label, "xalign", 0.0, NULL);
   gtk_box_append (GTK_BOX (box), label);
-  gtk_size_group_add_widget (sl->priv->sizegroup, label);
+  gtk_size_group_add_widget (self->sizegroup, label);
   gtk_widget_set_halign (label, GTK_ALIGN_START);
   gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
 
@@ -146,7 +152,7 @@ create_controller_widget (gpointer item,
   gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
 
   g_object_set_data (G_OBJECT (row), "controller", controller);
-  g_signal_connect (combo, "changed", G_CALLBACK (phase_changed_cb), sl);
+  g_signal_connect (combo, "changed", G_CALLBACK (phase_changed_cb), self);
 
   return row;
 }
@@ -209,19 +215,18 @@ compare_controllers (gconstpointer _first,
 }
 
 void
-gtk_inspector_controllers_set_object (GtkInspectorControllers *sl,
+gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
                                       GObject                 *object)
 {
   GtkWidget *stack;
   GtkStackPage *page;
-  GtkInspectorControllersPrivate *priv = sl->priv;
   GtkMapListModel *map_model;
   GtkFlattenListModel *flatten_model;
   GtkSortListModel *sort_model;
   GtkSorter *sorter;
 
-  stack = gtk_widget_get_parent (GTK_WIDGET (sl));
-  page = gtk_stack_get_page (GTK_STACK (stack), GTK_WIDGET (sl));
+  stack = gtk_widget_get_parent (GTK_WIDGET (self));
+  page = gtk_stack_get_page (GTK_STACK (stack), GTK_WIDGET (self));
 
   if (!GTK_IS_WIDGET (object))
     {
@@ -231,11 +236,11 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *sl,
 
   g_object_set (page, "visible", TRUE, NULL);
 
-  priv->model = gtk_property_lookup_list_model_new (GTK_TYPE_WIDGET, "parent");
-  gtk_property_lookup_list_model_set_object (priv->model, object);
+  self->model = gtk_property_lookup_list_model_new (GTK_TYPE_WIDGET, "parent");
+  gtk_property_lookup_list_model_set_object (self->model, object);
 
-  map_model = gtk_map_list_model_new (G_TYPE_LIST_MODEL, G_LIST_MODEL (priv->model), map_to_controllers, 
NULL, NULL);
-  g_object_unref (priv->model);
+  map_model = gtk_map_list_model_new (G_TYPE_LIST_MODEL, G_LIST_MODEL (self->model), map_to_controllers, 
NULL, NULL);
+  g_object_unref (self->model);
 
   flatten_model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER, G_LIST_MODEL (map_model));
 
@@ -243,10 +248,10 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *sl,
   sort_model = gtk_sort_list_model_new (G_LIST_MODEL (flatten_model), sorter);
   g_object_unref (sorter);
 
-  gtk_list_box_bind_model (GTK_LIST_BOX (priv->listbox),
+  gtk_list_box_bind_model (GTK_LIST_BOX (self->listbox),
                            G_LIST_MODEL (sort_model),
                            create_controller_widget,
-                           sl,
+                           self,
                            NULL);
 
   g_object_unref (sort_model);
@@ -260,12 +265,12 @@ get_property (GObject    *object,
               GValue     *value,
               GParamSpec *pspec)
 {
-  GtkInspectorControllers *sl = GTK_INSPECTOR_CONTROLLERS (object);
+  GtkInspectorControllers *self = GTK_INSPECTOR_CONTROLLERS (object);
 
   switch (param_id)
     {
       case PROP_OBJECT_TREE:
-        g_value_take_object (value, sl->priv->object_tree);
+        g_value_take_object (value, self->object_tree);
         break;
 
       default:
@@ -280,12 +285,12 @@ set_property (GObject      *object,
               const GValue *value,
               GParamSpec   *pspec)
 {
-  GtkInspectorControllers *sl = GTK_INSPECTOR_CONTROLLERS (object);
+  GtkInspectorControllers *self = GTK_INSPECTOR_CONTROLLERS (object);
 
   switch (param_id)
     {
       case PROP_OBJECT_TREE:
-        sl->priv->object_tree = g_value_get_object (value);
+        self->object_tree = g_value_get_object (value);
         break;
 
       default:
diff --git a/gtk/inspector/controllers.h b/gtk/inspector/controllers.h
index a0f9f8c265..d4c884cb0d 100644
--- a/gtk/inspector/controllers.h
+++ b/gtk/inspector/controllers.h
@@ -18,32 +18,13 @@
 #ifndef _GTK_INSPECTOR_CONTROLLERS_H_
 #define _GTK_INSPECTOR_CONTROLLERS_H_
 
-#include <gtk/gtkbox.h>
-
-#define GTK_TYPE_INSPECTOR_CONTROLLERS            (gtk_inspector_controllers_get_type())
-#define GTK_INSPECTOR_CONTROLLERS(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), 
GTK_TYPE_INSPECTOR_CONTROLLERS, GtkInspectorControllers))
-#define GTK_INSPECTOR_CONTROLLERS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), 
GTK_TYPE_INSPECTOR_CONTROLLERS, GtkInspectorControllersClass))
-#define GTK_INSPECTOR_IS_GESTURES(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), 
GTK_TYPE_INSPECTOR_CONTROLLERS))
-#define GTK_INSPECTOR_IS_GESTURES_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), 
GTK_TYPE_INSPECTOR_CONTROLLERS))
-#define GTK_INSPECTOR_CONTROLLERS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), 
GTK_TYPE_INSPECTOR_CONTROLLERS, GtkInspectorControllersClass))
-
-
-typedef struct _GtkInspectorControllersPrivate GtkInspectorControllersPrivate;
-
-typedef struct _GtkInspectorControllers
-{
-  GtkBox parent;
-  GtkInspectorControllersPrivate *priv;
-} GtkInspectorControllers;
-
-typedef struct _GtkInspectorControllersClass
-{
-  GtkBoxClass parent;
-} GtkInspectorControllersClass;
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
-GType           gtk_inspector_controllers_get_type              (void);
+#define GTK_TYPE_INSPECTOR_CONTROLLERS gtk_inspector_controllers_get_type()
+
+G_DECLARE_FINAL_TYPE (GtkInspectorControllers, gtk_inspector_controllers, GTK, INSPECTOR_CONTROLLERS, GtkBox)
 
 void            gtk_inspector_controllers_set_object            (GtkInspectorControllers        *sl,
                                                                  GObject                        *object);


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