check that the action name is unique before adding it to a

2008-12-03  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpactiongroup.c: check that the action name is
	unique before adding it to a GimpActionGroup.


svn path=/trunk/; revision=27751
This commit is contained in:
Sven Neumann 2008-12-03 13:20:03 +00:00 committed by Sven Neumann
parent 86bab55c2f
commit 6c82108236
2 changed files with 54 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2008-12-03 Sven Neumann <sven@gimp.org>
* app/widgets/gimpactiongroup.c: check that the action name is
unique before adding it to a GimpActionGroup.
2008-12-03 Sven Neumann <sven@gimp.org>
* app/core/gimpitem.c (gimp_item_get_offset_node): use

View file

@ -111,8 +111,7 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
static void
@ -262,6 +261,23 @@ gimp_action_group_get_property (GObject *object,
}
}
static gboolean
gimp_action_group_check_unique_action (GimpActionGroup *group,
const gchar *action_name)
{
if (G_UNLIKELY (gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name)))
{
g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
action_name,
gtk_action_group_get_name (GTK_ACTION_GROUP (group)));
return FALSE;
}
return TRUE;
}
/**
* gimp_action_group_new:
* @gimp: the @Gimp instance this action group belongs to
@ -349,6 +365,9 @@ gimp_action_group_add_actions (GimpActionGroup *group,
gchar *label;
const gchar *tooltip;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) g_strip_context (entries[i].label,
gettext (entries[i].label));
tooltip = gettext (entries[i].tooltip);
@ -395,6 +414,9 @@ gimp_action_group_add_toggle_actions (GimpActionGroup *group,
gchar *label;
const gchar *tooltip;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) g_strip_context (entries[i].label,
gettext (entries[i].label));
tooltip = gettext (entries[i].tooltip);
@ -447,6 +469,9 @@ gimp_action_group_add_radio_actions (GimpActionGroup *group,
gchar *label;
const gchar *tooltip;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) g_strip_context (entries[i].label,
gettext (entries[i].label));
tooltip = gettext (entries[i].tooltip);
@ -506,6 +531,9 @@ gimp_action_group_add_enum_actions (GimpActionGroup *group,
gchar *label;
const gchar *tooltip;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) g_strip_context (entries[i].label,
gettext (entries[i].label));
tooltip = gettext (entries[i].tooltip);
@ -555,6 +583,9 @@ gimp_action_group_add_string_actions (GimpActionGroup *group,
gchar *label;
const gchar *tooltip;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) g_strip_context (entries[i].label,
gettext (entries[i].label));
tooltip = gettext (entries[i].tooltip);
@ -602,6 +633,9 @@ gimp_action_group_add_plug_in_actions (GimpActionGroup *group,
GimpPlugInAction *action;
gchar *label;
if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue;
label = (gchar *) entries[i].label;
if (! group->mnemonics)