gimp r27751 - in trunk: . app/widgets



Author: neo
Date: Wed Dec  3 13:20:03 2008
New Revision: 27751
URL: http://svn.gnome.org/viewvc/gimp?rev=27751&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/app/widgets/gimpactiongroup.c

Modified: trunk/app/widgets/gimpactiongroup.c
==============================================================================
--- trunk/app/widgets/gimpactiongroup.c	(original)
+++ trunk/app/widgets/gimpactiongroup.c	Wed Dec  3 13:20:03 2008
@@ -52,19 +52,19 @@
 };
 
 
-static GObject * gimp_action_group_constructor (GType                  type,
-                                                guint                  n_params,
-                                                GObjectConstructParam *params);
-static void   gimp_action_group_dispose        (GObject               *object);
-static void   gimp_action_group_finalize       (GObject               *object);
-static void   gimp_action_group_set_property   (GObject               *object,
-                                                guint                  prop_id,
-                                                const GValue          *value,
-                                                GParamSpec            *pspec);
-static void   gimp_action_group_get_property   (GObject               *object,
-                                                guint                  prop_id,
-                                                GValue                *value,
-                                                GParamSpec            *pspec);
+static GObject * gimp_action_group_constructor   (GType                  type,
+                                                  guint                  n_params,
+                                                  GObjectConstructParam *params);
+static void      gimp_action_group_dispose       (GObject               *object);
+static void      gimp_action_group_finalize      (GObject               *object);
+static void      gimp_action_group_set_property  (GObject               *object,
+                                                  guint                  prop_id,
+                                                  const GValue          *value,
+                                                  GParamSpec            *pspec);
+static void      gimp_action_group_get_property  (GObject               *object,
+                                                  guint                  prop_id,
+                                                  GValue                *value,
+                                                  GParamSpec            *pspec);
 
 
 G_DEFINE_TYPE (GimpActionGroup, gimp_action_group, GTK_TYPE_ACTION_GROUP)
@@ -111,8 +111,7 @@
                                                          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 @@
     }
 }
 
+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 @@
       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 @@
       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 @@
       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 @@
       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 @@
       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 @@
       GimpPlugInAction *action;
       gchar            *label;
 
+      if (! gimp_action_group_check_unique_action (group, entries[i].name))
+        continue;
+
       label = (gchar *) entries[i].label;
 
       if (! group->mnemonics)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]