X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtksizegroup.c;h=e31dfa84eb1755b30b53f228eeff280941a16989;hb=79695ee64d41c9aadfe2c6f18dc7dd1e3fd44852;hp=b51b824c86b396a9514cb6d360ea83ef4cab1549;hpb=fd6ea423190c7275c2b096d17e83846426400d78;p=~andy%2Fgtk diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c index b51b824c8..e31dfa84e 100644 --- a/gtk/gtksizegroup.c +++ b/gtk/gtksizegroup.c @@ -147,18 +147,23 @@ static void gtk_size_group_buildable_custom_finished (GtkBuildable *buildable, const gchar *tagname, gpointer user_data); +G_STATIC_ASSERT (GTK_SIZE_GROUP_HORIZONTAL == (1 << GTK_ORIENTATION_HORIZONTAL)); +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) @@ -166,16 +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 != GTK_SIZE_GROUP_BOTH && - (!(tmp_priv->mode == GTK_SIZE_GROUP_HORIZONTAL && orientation == GTK_ORIENTATION_HORIZONTAL)) && - (!(tmp_priv->mode == GTK_SIZE_GROUP_VERTICAL && orientation == GTK_ORIENTATION_VERTICAL))) + 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); } } @@ -183,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