Warn and refuse to add actions with duplicate names. (#150877, Tommi

2007-05-18  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkactiongroup.c: Warn and refuse to add actions with
        duplicate names.  (#150877, Tommi Komulainen)



svn path=/trunk/; revision=17872
This commit is contained in:
Matthias Clasen 2007-05-19 04:07:42 +00:00 committed by Matthias Clasen
parent 4c1173b7f3
commit 924d6fdc4e
2 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2007-05-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.c: Warn and refuse to add actions with
duplicate names. (#150877, Tommi Komulainen)
2007-05-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:

View File

@ -535,6 +535,21 @@ gtk_action_group_get_action (GtkActionGroup *action_group,
(action_group, action_name);
}
static gboolean
check_unique_action (GtkActionGroup *action_group,
const gchar *action_name)
{
if (gtk_action_group_get_action (action_group, action_name) != NULL)
{
g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
action_name,
action_group->private_data->name);
return FALSE;
}
return TRUE;
}
/**
* gtk_action_group_add_action:
* @action_group: the action group
@ -556,6 +571,9 @@ gtk_action_group_add_action (GtkActionGroup *action_group,
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
g_return_if_fail (GTK_IS_ACTION (action));
g_return_if_fail (gtk_action_get_name (action) != NULL);
if (!check_unique_action (action_group, gtk_action_get_name (action)))
return;
g_hash_table_insert (action_group->private_data->actions,
g_strdup (gtk_action_get_name (action)),
@ -592,6 +610,9 @@ gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
GtkStockItem stock_item;
gchar *name;
gchar *stock_id;
if (!check_unique_action (action_group, gtk_action_get_name (action)))
return;
g_object_get (action, "name", &name, "stock-id", &stock_id, NULL);
@ -773,6 +794,9 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
const gchar *label;
const gchar *tooltip;
if (!check_unique_action (action_group, entries[i].name))
continue;
label = gtk_action_group_translate_string (action_group, entries[i].label);
tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
@ -877,6 +901,9 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
const gchar *label;
const gchar *tooltip;
if (!check_unique_action (action_group, entries[i].name))
continue;
label = gtk_action_group_translate_string (action_group, entries[i].label);
tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
@ -989,6 +1016,9 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
const gchar *label;
const gchar *tooltip;
if (!check_unique_action (action_group, entries[i].name))
continue;
label = gtk_action_group_translate_string (action_group, entries[i].label);
tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);