diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-07-09 19:18:08 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-07-09 19:33:31 -0400 |
commit | 3247058a302402423b978276403c83bcc1e15df9 (patch) | |
tree | 83683e02be33569190e86276e33bee175d9ea740 | |
parent | af26a18032b298b7c4d1e592f97e2e7949190de6 (diff) | |
download | gtk+-3247058a302402423b978276403c83bcc1e15df9.tar.gz |
Revert the private macro change for GtkToolButton
There was a reason that GtkToolButton was not using the
G_DEFINE_TYPE macros - we need the klass argument to get
the proper button type at init time.
-rw-r--r-- | gtk/gtktoolbutton.c | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index 078fbdb006..e079faecda 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -83,6 +83,9 @@ 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, @@ -128,20 +131,47 @@ struct _GtkToolButtonPrivate guint contents_invalid : 1; }; +static GObjectClass *parent_class = NULL; static GtkActivatableIface *parent_activatable_iface; static guint toolbutton_signals[LAST_SIGNAL] = { 0 }; -/* for GTK_TYPE_ACTIVATABLE */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GType +gtk_tool_button_get_type (void) +{ + static GType g_define_type_id = 0; -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)) + if (!g_define_type_id) + { + 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 + }; + + g_define_type_id = 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); -G_GNUC_END_IGNORE_DEPRECATIONS + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + g_type_add_interface_static (g_define_type_id, + GTK_TYPE_ACTIONABLE, &actionable_info); + g_type_add_interface_static (g_define_type_id, + GTK_TYPE_ACTIVATABLE, &activatable_info); + G_GNUC_END_IGNORE_DEPRECATIONS; + } + return g_define_type_id; +} static void gtk_tool_button_class_init (GtkToolButtonClass *klass) @@ -150,6 +180,8 @@ 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; @@ -294,21 +326,26 @@ 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) +gtk_tool_button_init (GtkToolButton *button, + GtkToolButtonClass *klass) { GtkToolItem *toolitem = GTK_TOOL_ITEM (button); - button->priv = gtk_tool_button_get_instance_private (button); + button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, + GTK_TYPE_TOOL_BUTTON, + GtkToolButtonPrivate); button->priv->contents_invalid = TRUE; gtk_tool_item_set_homogeneous (toolitem, TRUE); /* create button */ - button->priv->button = g_object_new (GTK_TOOL_BUTTON_GET_CLASS (button)->button_type, NULL); + button->priv->button = g_object_new (klass->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); @@ -630,8 +667,8 @@ gtk_tool_button_property_notify (GObject *object, strcmp ("is-important", pspec->name) == 0) gtk_tool_button_construct_contents (GTK_TOOL_ITEM (object)); - if (G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify != NULL) - G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify (object, pspec); + if (parent_class->notify) + parent_class->notify (object, pspec); } static void @@ -732,7 +769,7 @@ gtk_tool_button_finalize (GObject *object) if (button->priv->icon_widget) g_object_unref (button->priv->icon_widget); - G_OBJECT_CLASS (gtk_tool_button_parent_class)->finalize (object); + parent_class->finalize (object); } static GtkWidget * @@ -902,7 +939,7 @@ gtk_tool_button_update_icon_spacing (GtkToolButton *button) static void gtk_tool_button_style_updated (GtkWidget *widget) { - GTK_WIDGET_CLASS (gtk_tool_button_parent_class)->style_updated (widget); + GTK_WIDGET_CLASS (parent_class)->style_updated (widget); gtk_tool_button_update_icon_spacing (GTK_TOOL_BUTTON (widget)); } |