From 6e35e2333f643a7ebbc9ac9d2d3b98d40645e78c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 3 May 2004 15:54:54 +0000 Subject: [PATCH] added gimp_help_id_quark() which is G_GNUC_CONST and a new macro 2004-05-03 Michael Natterer * libgimpwidgets/gimphelpui.[ch]: added gimp_help_id_quark() which is G_GNUC_CONST and a new macro GIMP_HELP_ID as shortcut. * app/widgets/gimpactiongroup.c (gimp_action_group_add_*_actions): attach the help ID to the action using the new quark key. Call gtk_action_group_add_action() instead of the _with_accel() variant if the accel is the empty string (== if we explicitely want no accel even if the stock item specifies one). Fixes warning flood with GTK+ 2.4.1. --- ChangeLog | 12 +++++ app/widgets/gimpactiongroup.c | 95 ++++++++++++++++++++++++++++------- libgimpwidgets/gimphelpui.c | 23 ++++++++- libgimpwidgets/gimphelpui.h | 5 ++ 4 files changed, 115 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index c617804f7b..3d1ca3e6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-05-03 Michael Natterer + + * libgimpwidgets/gimphelpui.[ch]: added gimp_help_id_quark() + which is G_GNUC_CONST and a new macro GIMP_HELP_ID as shortcut. + + * app/widgets/gimpactiongroup.c (gimp_action_group_add_*_actions): + attach the help ID to the action using the new quark key. Call + gtk_action_group_add_action() instead of the _with_accel() variant + if the accel is the empty string (== if we explicitely want no + accel even if the stock item specifies one). Fixes warning flood + with GTK+ 2.4.1. + 2004-05-03 Sven Neumann * libgimpwidgets/gimpframe.c: if the label_widget is a button, set diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c index cd6f522bb9..b9b45e6e3d 100644 --- a/app/widgets/gimpactiongroup.c +++ b/app/widgets/gimpactiongroup.c @@ -308,9 +308,18 @@ gimp_action_group_add_actions (GimpActionGroup *group, entries[i].callback, group->user_data); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - action, - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), action); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + action, + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } } @@ -343,9 +352,19 @@ gimp_action_group_add_toggle_actions (GimpActionGroup *group, entries[i].callback, group->user_data); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - GTK_ACTION (action), - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), + GTK_ACTION (action)); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + GTK_ACTION (action), + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } } @@ -385,9 +404,19 @@ gimp_action_group_add_radio_actions (GimpActionGroup *group, if (value == entries[i].value) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - GTK_ACTION (action), - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), + GTK_ACTION (action)); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + GTK_ACTION (action), + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } @@ -425,9 +454,19 @@ gimp_action_group_add_enum_actions (GimpActionGroup *group, callback, group->user_data); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - GTK_ACTION (action), - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), + GTK_ACTION (action)); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + GTK_ACTION (action), + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } } @@ -460,9 +499,19 @@ gimp_action_group_add_string_actions (GimpActionGroup *group, callback, group->user_data); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - GTK_ACTION (action), - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), + GTK_ACTION (action)); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + GTK_ACTION (action), + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } } @@ -492,9 +541,19 @@ gimp_action_group_add_plug_in_actions (GimpActionGroup *group, callback, group->user_data); - gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), - GTK_ACTION (action), - entries[i].accelerator); + if (entries[i].accelerator && ! entries[i].accelerator[0]) + gtk_action_group_add_action (GTK_ACTION_GROUP (group), + GTK_ACTION (action)); + else + gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group), + GTK_ACTION (action), + entries[i].accelerator); + + if (entries[i].help_id) + g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID, + g_strdup (entries[i].help_id), + (GDestroyNotify) g_free); + g_object_unref (action); } } diff --git a/libgimpwidgets/gimphelpui.c b/libgimpwidgets/gimphelpui.c index d21266fdc5..3cf2481d23 100644 --- a/libgimpwidgets/gimphelpui.c +++ b/libgimpwidgets/gimphelpui.c @@ -210,7 +210,7 @@ gimp_help_set_help_data (GtkWidget *widget, if (tooltip) gtk_tooltips_set_tip (tool_tips, widget, tooltip, help_id); else - g_object_set_data (G_OBJECT (widget), "gimp-help-id", (gpointer) help_id); + g_object_set_qdata (G_OBJECT (widget), GIMP_HELP_ID, (gpointer) help_id); } /** @@ -236,6 +236,25 @@ gimp_context_help (GtkWidget *widget) gimp_help_callback (widget, GTK_WIDGET_HELP_WHATS_THIS, NULL); } +/** + * gimp_help_id_quark: + * + * This function returns the #GQuark which should be used as key when + * attachind help IDs to widgets and objects. + * + * Return value: The #GQuark. + **/ +GQuark +gimp_help_id_quark (void) +{ + static GQuark quark = 0; + + if (! quark) + quark = g_quark_from_static_string ("gimp-help-id"); + + return quark; +} + /* private functions */ @@ -255,7 +274,7 @@ gimp_help_get_help_data (GtkWidget *widget, if (tooltips_data && tooltips_data->tip_private) help_id = tooltips_data->tip_private; else - help_id = g_object_get_data (G_OBJECT (widget), "gimp-help-id"); + help_id = g_object_get_qdata (G_OBJECT (widget), GIMP_HELP_ID); help_data = g_object_get_data (G_OBJECT (widget), "gimp-help-data"); diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h index 2e36553146..5eee690208 100644 --- a/libgimpwidgets/gimphelpui.h +++ b/libgimpwidgets/gimphelpui.h @@ -53,6 +53,11 @@ void gimp_help_set_help_data (GtkWidget *widget, void gimp_context_help (GtkWidget *widget); +#define GIMP_HELP_ID (gimp_help_id_quark ()) + +GQuark gimp_help_id_quark (void) G_GNUC_CONST; + + G_END_DECLS #endif /* __GIMP_HELP_UI_H__ */