diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2013-06-27 20:02:52 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2013-07-09 09:30:02 +0100 |
commit | 0899ef7cc9cf73824901923143f38bb9b6d224a3 (patch) | |
tree | 16207a8837da8a89a6f4a1d1a1c23074fd29aa1d /gtk/gtktoolbutton.c | |
parent | 365919d5f6da0a8648815ca5cf5805fb88c9be16 (diff) | |
download | gtk+-0899ef7cc9cf73824901923143f38bb9b6d224a3.tar.gz |
gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
Diffstat (limited to 'gtk/gtktoolbutton.c')
-rw-r--r-- | gtk/gtktoolbutton.c | 70 |
1 files changed, 17 insertions, 53 deletions
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index 10af3cbcb2..078fbdb006 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -83,9 +83,6 @@ enum { PROP_ACTION_TARGET }; -static void gtk_tool_button_init (GtkToolButton *button, - GtkToolButtonClass *klass); -static void gtk_tool_button_class_init (GtkToolButtonClass *klass); static void gtk_tool_button_set_property (GObject *object, guint prop_id, const GValue *value, @@ -131,46 +128,20 @@ struct _GtkToolButtonPrivate guint contents_invalid : 1; }; -static GObjectClass *parent_class = NULL; static GtkActivatableIface *parent_activatable_iface; static guint toolbutton_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_tool_button_get_type (void) -{ - static GType type = 0; - - if (!type) - { - const GInterfaceInfo actionable_info = - { - (GInterfaceInitFunc) gtk_tool_button_actionable_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - const GInterfaceInfo activatable_info = - { - (GInterfaceInitFunc) gtk_tool_button_activatable_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = g_type_register_static_simple (GTK_TYPE_TOOL_ITEM, - I_("GtkToolButton"), - sizeof (GtkToolButtonClass), - (GClassInitFunc) gtk_tool_button_class_init, - sizeof (GtkToolButton), - (GInstanceInitFunc) gtk_tool_button_init, - 0); +/* for GTK_TYPE_ACTIVATABLE */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - g_type_add_interface_static (type, GTK_TYPE_ACTIONABLE, &actionable_info); - g_type_add_interface_static (type, GTK_TYPE_ACTIVATABLE, - &activatable_info); - G_GNUC_END_IGNORE_DEPRECATIONS; - } - return type; -} +G_DEFINE_TYPE_WITH_CODE (GtkToolButton, gtk_tool_button, GTK_TYPE_TOOL_ITEM, + G_ADD_PRIVATE (GtkToolButton) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, + gtk_tool_button_actionable_iface_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, + gtk_tool_button_activatable_interface_init)) + +G_GNUC_END_IGNORE_DEPRECATIONS static void gtk_tool_button_class_init (GtkToolButtonClass *klass) @@ -179,8 +150,6 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass) GtkWidgetClass *widget_class; GtkToolItemClass *tool_item_class; - parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *)klass; widget_class = (GtkWidgetClass *)klass; tool_item_class = (GtkToolItemClass *)klass; @@ -325,26 +294,21 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkToolButtonPrivate)); } static void -gtk_tool_button_init (GtkToolButton *button, - GtkToolButtonClass *klass) +gtk_tool_button_init (GtkToolButton *button) { GtkToolItem *toolitem = GTK_TOOL_ITEM (button); - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_TOOL_BUTTON, - GtkToolButtonPrivate); + button->priv = gtk_tool_button_get_instance_private (button); button->priv->contents_invalid = TRUE; gtk_tool_item_set_homogeneous (toolitem, TRUE); /* create button */ - button->priv->button = g_object_new (klass->button_type, NULL); + button->priv->button = g_object_new (GTK_TOOL_BUTTON_GET_CLASS (button)->button_type, NULL); gtk_button_set_focus_on_click (GTK_BUTTON (button->priv->button), FALSE); g_signal_connect_object (button->priv->button, "clicked", G_CALLBACK (button_clicked), button, 0); @@ -666,8 +630,8 @@ gtk_tool_button_property_notify (GObject *object, strcmp ("is-important", pspec->name) == 0) gtk_tool_button_construct_contents (GTK_TOOL_ITEM (object)); - if (parent_class->notify) - parent_class->notify (object, pspec); + if (G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify != NULL) + G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify (object, pspec); } static void @@ -768,7 +732,7 @@ gtk_tool_button_finalize (GObject *object) if (button->priv->icon_widget) g_object_unref (button->priv->icon_widget); - parent_class->finalize (object); + G_OBJECT_CLASS (gtk_tool_button_parent_class)->finalize (object); } static GtkWidget * @@ -938,7 +902,7 @@ gtk_tool_button_update_icon_spacing (GtkToolButton *button) static void gtk_tool_button_style_updated (GtkWidget *widget) { - GTK_WIDGET_CLASS (parent_class)->style_updated (widget); + GTK_WIDGET_CLASS (gtk_tool_button_parent_class)->style_updated (widget); gtk_tool_button_update_icon_spacing (GTK_TOOL_BUTTON (widget)); } |