summaryrefslogtreecommitdiff
path: root/gtk/gtkcontainer.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-03-17 14:59:19 +0100
committerTimm Bäder <mail@baedert.org>2018-03-20 09:37:58 +0100
commit93aa5ce167b0d02a1cecb94828b2b566c178a18f (patch)
treec8da91685404e905bae58989889fcb238ab772d0 /gtk/gtkcontainer.c
parent781400f6d3bda0471976917d58e2b245844f0911 (diff)
downloadgtk+-93aa5ce167b0d02a1cecb94828b2b566c178a18f.tar.gz
container: Don't use forall() in compute_expand
Use the widget list instead, which saves some code.
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r--gtk/gtkcontainer.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 7ceb758868..18b6ccfe9d 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -1849,51 +1849,36 @@ gtk_container_get_children (GtkContainer *container)
return g_list_reverse (children);
}
-typedef struct {
- gboolean hexpand;
- gboolean vexpand;
-} ComputeExpandData;
-
-static void
-gtk_container_compute_expand_callback (GtkWidget *widget,
- gpointer client_data)
-{
- ComputeExpandData *data = client_data;
-
- /* note that we don't get_expand on the child if we already know we
- * have to expand, so we only recurse into children until we find
- * one that expands and then we basically don't do any more
- * work. This means that we can leave some children in a
- * need_compute_expand state, which is fine, as long as GtkWidget
- * doesn't rely on an invariant that "if a child has
- * need_compute_expand, its parents also do"
- *
- * gtk_widget_compute_expand() always returns FALSE if the
- * child is !visible so that's taken care of.
- */
- data->hexpand = data->hexpand ||
- gtk_widget_compute_expand (widget, GTK_ORIENTATION_HORIZONTAL);
-
- data->vexpand = data->vexpand ||
- gtk_widget_compute_expand (widget, GTK_ORIENTATION_VERTICAL);
-}
-
static void
-gtk_container_compute_expand (GtkWidget *widget,
- gboolean *hexpand_p,
- gboolean *vexpand_p)
+gtk_container_compute_expand (GtkWidget *widget,
+ gboolean *hexpand_p,
+ gboolean *vexpand_p)
{
- ComputeExpandData data;
-
- data.hexpand = FALSE;
- data.vexpand = FALSE;
+ GtkWidget *w;
+ gboolean hexpand = FALSE;
+ gboolean vexpand = FALSE;
- gtk_container_forall (GTK_CONTAINER (widget),
- gtk_container_compute_expand_callback,
- &data);
+ for (w = gtk_widget_get_first_child (widget);
+ w != NULL;
+ w = gtk_widget_get_next_sibling (w))
+ {
+ /* note that we don't get_expand on the child if we already know we
+ * have to expand, so we only recurse into children until we find
+ * one that expands and then we basically don't do any more
+ * work. This means that we can leave some children in a
+ * need_compute_expand state, which is fine, as long as GtkWidget
+ * doesn't rely on an invariant that "if a child has
+ * need_compute_expand, its parents also do"
+ *
+ * gtk_widget_compute_expand() always returns FALSE if the
+ * child is !visible so that's taken care of.
+ */
+ hexpand = hexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_HORIZONTAL);
+ vexpand = vexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_VERTICAL);
+ }
- *hexpand_p = data.hexpand;
- *vexpand_p = data.vexpand;
+ *hexpand_p = hexpand;
+ *vexpand_p = vexpand;
}
static void