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
This commit is contained in:
Emmanuele Bassi 2019-04-12 13:11:28 +01:00
parent 88086ea91a
commit b91fbfd5a0

View File

@ -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;
return self->orientation == GTK_ORIENTATION_HORIZONTAL
? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
: GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
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;
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