[gtk/wip/otte/listview] inspector: Remove private struct from controllers
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview] inspector: Remove private struct from controllers
- Date: Sun, 10 Nov 2019 01:42:49 +0000 (UTC)
commit 1cfdc7c7e3821d01b5573c56f7ef0db73b80ba7a
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 deea5b866f..516818dc17 100644
--- a/gtk/inspector/controllers.c
+++ b/gtk/inspector/controllers.c
@@ -36,40 +36,46 @@
#include "gtkstack.h"
#include "gtkstylecontext.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);
@@ -84,19 +90,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_style_context_add_class (gtk_widget_get_style_context (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_container_add (GTK_CONTAINER (box), sl->priv->listbox);
+ self->listbox = gtk_list_box_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (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_container_add (GTK_CONTAINER (box), self->listbox);
- gtk_container_add (GTK_CONTAINER (sl), sw);
+ gtk_container_add (GTK_CONTAINER (self), sw);
}
static void
phase_changed_cb (GtkComboBox *combo,
- GtkInspectorControllers *sl)
+ GtkInspectorControllers *self)
{
GtkWidget *row;
GtkPropagationPhase phase;
@@ -112,8 +118,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;
@@ -127,7 +133,7 @@ create_controller_widget (gpointer item,
label = gtk_label_new (G_OBJECT_TYPE_NAME (controller));
g_object_set (label, "xalign", 0.0, NULL);
gtk_container_add (GTK_CONTAINER (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);
@@ -142,7 +148,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;
}
@@ -205,18 +211,17 @@ 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;
- 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))
{
@@ -226,11 +231,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));
@@ -238,10 +243,10 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *sl,
compare_controllers,
NULL, NULL);
- 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);
@@ -255,12 +260,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:
@@ -275,12 +280,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]