]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtksizegroup.c
filechooserbutton: whitespace fixes
[~andy/gtk] / gtk / gtksizegroup.c
index 7c57558f089286c6da94be8dae12e96b3cf018f2..e31dfa84eb1755b30b53f228eeff280941a16989 100644 (file)
@@ -152,17 +152,18 @@ G_STATIC_ASSERT (GTK_SIZE_GROUP_VERTICAL == (1 << GTK_ORIENTATION_VERTICAL));
 G_STATIC_ASSERT (GTK_SIZE_GROUP_BOTH == (GTK_SIZE_GROUP_HORIZONTAL | GTK_SIZE_GROUP_VERTICAL));
 
 static void
-add_widget_to_closure (GHashTable     *set,
+add_widget_to_closure (GHashTable     *widgets,
+                       GHashTable     *groups,
                        GtkWidget      *widget,
                       GtkOrientation  orientation)
 {
   GSList *tmp_groups, *tmp_widgets;
   gboolean hidden;
 
-  if (g_hash_table_lookup (set, widget))
+  if (g_hash_table_lookup (widgets, widget))
     return;
 
-  g_hash_table_insert (set, widget, widget);
+  g_hash_table_add (widgets, widget);
   hidden = !gtk_widget_is_visible (widget);
 
   for (tmp_groups = _gtk_widget_get_sizegroups (widget); tmp_groups; tmp_groups = tmp_groups->next)
@@ -170,14 +171,19 @@ add_widget_to_closure (GHashTable     *set,
       GtkSizeGroup        *tmp_group = tmp_groups->data;
       GtkSizeGroupPrivate *tmp_priv  = tmp_group->priv;
 
+      if (g_hash_table_lookup (groups, tmp_group))
+        continue;
+
       if (tmp_priv->ignore_hidden && hidden)
         continue;
 
       if (!(tmp_priv->mode & (1 << orientation)))
         continue;
 
+      g_hash_table_add (groups, tmp_group);
+
       for (tmp_widgets = tmp_priv->widgets; tmp_widgets; tmp_widgets = tmp_widgets->next)
-        add_widget_to_closure (set, tmp_widgets->data, orientation);
+        add_widget_to_closure (widgets, groups, tmp_widgets->data, orientation);
     }
 }
 
@@ -185,13 +191,16 @@ GHashTable *
 _gtk_size_group_get_widget_peers (GtkWidget      *for_widget,
                                   GtkOrientation  orientation)
 {
-  GHashTable *result;
+  GHashTable *widgets, *groups;
+
+  widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
+  groups = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-  result = g_hash_table_new (g_direct_hash, g_direct_equal);
+  add_widget_to_closure (widgets, groups, for_widget, orientation);
 
-  add_widget_to_closure (result, for_widget, orientation);
+  g_hash_table_unref (groups);
 
-  return result;
+  return widgets;
 }
                                      
 static void