[gtk/issue-1821] Fix get_request_mode for GtkBoxLayout
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/issue-1821] Fix get_request_mode for GtkBoxLayout
- Date: Fri, 12 Apr 2019 12:22:57 +0000 (UTC)
commit b91fbfd5a02c57897f31edfb21338aea741c4911
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Apr 12 13:11:28 2019 +0100
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
gtk/gtkboxlayout.c | 32 +++++++++++++++++++++++++++++---
1 file 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]