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)
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);
}
}
_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