[gtk+] GtkStack: warn if child names are not unique



commit 85ccb93b9f618828bbdf511a31912f0c69b6bb72
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Apr 21 20:41:22 2013 -0400

    GtkStack: warn if child names are not unique

 gtk/gtkstack.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index c6b5953..6ca1fbb 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -568,6 +568,9 @@ gtk_stack_set_child_property (GtkContainer *container,
   GtkStack *stack = GTK_STACK (container);
   GtkStackPrivate *priv = stack->priv;
   GtkStackChildInfo *info;
+  GtkStackChildInfo *info2;
+  gchar *name;
+  GList *l;
 
   info = find_child_info_for_widget (stack, child);
   if (info == NULL)
@@ -579,8 +582,19 @@ gtk_stack_set_child_property (GtkContainer *container,
   switch (property_id)
     {
     case CHILD_PROP_NAME:
+      name = g_value_dup_string (value);
+      for (l = priv->children; l != NULL; l = l->next)
+        {
+          info2 = l->data;
+          if (g_strcmp0 (info2->name, name) == 0)
+            {
+              g_warning ("Duplicate child name in GtkStack: %s\n", name);
+              break;
+            }
+        }
+
       g_free (info->name);
-      info->name = g_value_dup_string (value);
+      info->name = name;
 
       gtk_container_child_notify (container, child, "name");
 


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