diff options
author | Timm Bäder <mail@baedert.org> | 2018-03-17 14:54:23 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-03-20 09:37:58 +0100 |
commit | 781400f6d3bda0471976917d58e2b245844f0911 (patch) | |
tree | 24322aa9f0cc58ed6f94781a4b23a54f1a082b17 /gtk/gtkcontainer.c | |
parent | f7326ff828ad133a7884906ad4cd03e2d9980535 (diff) | |
download | gtk+-781400f6d3bda0471976917d58e2b245844f0911.tar.gz |
container: Don't use forall() in get_request_mode
We can just use the widget child list, which save some code.
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r-- | gtk/gtkcontainer.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index fabdb983f9..7ceb758868 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -1709,45 +1709,38 @@ gtk_container_real_check_resize (GtkContainer *container) } } -typedef struct { - gint hfw; - gint wfh; -} RequestModeCount; - -static void -count_request_modes (GtkWidget *widget, - RequestModeCount *count) -{ - GtkSizeRequestMode mode = gtk_widget_get_request_mode (widget); - - switch (mode) - { - case GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH: - count->hfw++; - break; - case GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT: - count->wfh++; - break; - case GTK_SIZE_REQUEST_CONSTANT_SIZE: - default: - break; - } -} - static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget) { - GtkContainer *container = GTK_CONTAINER (widget); - RequestModeCount count = { 0, 0 }; + GtkWidget *w; + int wfh = 0, hfw = 0; + + for (w = gtk_widget_get_first_child (widget); + w != NULL; + w = gtk_widget_get_next_sibling (w)) + { + GtkSizeRequestMode mode = gtk_widget_get_request_mode (w); - gtk_container_forall (container, (GtkCallback)count_request_modes, &count); + switch (mode) + { + case GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH: + hfw ++; + break; + case GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT: + wfh ++; + break; + case GTK_SIZE_REQUEST_CONSTANT_SIZE: + default: + break; + } + } - if (!count.hfw && !count.wfh) + if (hfw == 0 && wfh == 0) return GTK_SIZE_REQUEST_CONSTANT_SIZE; else - return count.wfh > count.hfw ? + return wfh > hfw ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT : - GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; + GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; } /** |