summaryrefslogtreecommitdiff
path: root/gtk/gtkboxlayout.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-04-12 13:11:28 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2019-04-12 13:14:44 +0100
commitb91fbfd5a02c57897f31edfb21338aea741c4911 (patch)
treec232adf05c68e6b3936821bd4d1ab76d6b3752d0 /gtk/gtkboxlayout.c
parent88086ea91aa19dc8b8a20b0e560d593cbd9f45e2 (diff)
downloadgtk+-b91fbfd5a02c57897f31edfb21338aea741c4911.tar.gz
Fix get_request_mode for GtkBoxLayout
The default GtkWidgetClass.get_request_mode() is implemented by GtkContainer; now that GtkBox uses a GtkBoxLayout, we need to implement it inside the layout manager to preserve the same behavior as the old GtkBox. Fixes #1821
Diffstat (limited to 'gtk/gtkboxlayout.c')
-rw-r--r--gtk/gtkboxlayout.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 5d3ef2bd0d..cc6731b068 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -204,10 +204,36 @@ gtk_box_layout_get_request_mode (GtkLayoutManager *layout_manager,
GtkWidget *widget)
{
GtkBoxLayout *self = GTK_BOX_LAYOUT (layout_manager);
+ GtkWidget *child;
+ int wfh = 0, hfw = 0;
+
+ for (child = _gtk_widget_get_first_child (widget);
+ child != NULL;
+ child = _gtk_widget_get_next_sibling (child))
+ {
+ GtkSizeRequestMode mode = gtk_widget_get_request_mode (child);
+
+ switch (mode)
+ {
+ case GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH:
+ hfw += 1;
+ break;
- return self->orientation == GTK_ORIENTATION_HORIZONTAL
- ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
- : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+ case GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT:
+ wfh += 1;
+ break;
+
+ case GTK_SIZE_REQUEST_CONSTANT_SIZE:
+ default:
+ break;
+ }
+ }
+
+ if (hfw == 0 && wfh == 0)
+ return GTK_SIZE_REQUEST_CONSTANT_SIZE;
+ else
+ return wfh > hfw ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
+ : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
static void