GtkGrid: Fix a size allocation problem
We need pay attention the the request mode when doing size allocation. The code was using request mode for requisition, but orientation for allocation. Also add a reftest that exhibits the issue, courtesy of Benjamin Otte.
This commit is contained in:
@ -1231,6 +1231,7 @@ gtk_grid_size_allocate (GtkWidget *widget,
|
|||||||
GtkGridPrivate *priv = grid->priv;
|
GtkGridPrivate *priv = grid->priv;
|
||||||
GtkGridRequest request;
|
GtkGridRequest request;
|
||||||
GtkGridLines *lines;
|
GtkGridLines *lines;
|
||||||
|
GtkOrientation orientation;
|
||||||
|
|
||||||
if (priv->children == NULL)
|
if (priv->children == NULL)
|
||||||
{
|
{
|
||||||
@ -1250,10 +1251,15 @@ gtk_grid_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
gtk_widget_set_allocation (widget, allocation);
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
|
|
||||||
gtk_grid_request_run (&request, 1 - priv->orientation, FALSE);
|
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
|
||||||
gtk_grid_request_allocate (&request, 1 - priv->orientation, GET_SIZE (allocation, 1 - priv->orientation));
|
orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||||
gtk_grid_request_run (&request, priv->orientation, TRUE);
|
else
|
||||||
gtk_grid_request_allocate (&request, priv->orientation, GET_SIZE (allocation, priv->orientation));
|
orientation = GTK_ORIENTATION_VERTICAL;
|
||||||
|
|
||||||
|
gtk_grid_request_run (&request, 1 - orientation, FALSE);
|
||||||
|
gtk_grid_request_allocate (&request, 1 - orientation, GET_SIZE (allocation, 1 - orientation));
|
||||||
|
gtk_grid_request_run (&request, orientation, TRUE);
|
||||||
|
gtk_grid_request_allocate (&request, orientation, GET_SIZE (allocation, orientation));
|
||||||
|
|
||||||
gtk_grid_request_position (&request, 0);
|
gtk_grid_request_position (&request, 0);
|
||||||
gtk_grid_request_position (&request, 1);
|
gtk_grid_request_position (&request, 1);
|
||||||
|
|||||||
@ -69,6 +69,8 @@ EXTRA_DIST += \
|
|||||||
grid-expand.css \
|
grid-expand.css \
|
||||||
grid-expand.ref.ui \
|
grid-expand.ref.ui \
|
||||||
grid-expand.ui \
|
grid-expand.ui \
|
||||||
|
grid-wfh.ui \
|
||||||
|
grid-wfh.ref.ui \
|
||||||
grid-homogeneous.css \
|
grid-homogeneous.css \
|
||||||
grid-homogeneous.ref.ui \
|
grid-homogeneous.ref.ui \
|
||||||
grid-homogeneous.ui \
|
grid-homogeneous.ui \
|
||||||
|
|||||||
40
tests/reftests/grid-wfh.ref.ui
Normal file
40
tests/reftests/grid-wfh.ref.ui
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="grid1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">GNOME is awesome!</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label4">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">GNOME is awesome!</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
41
tests/reftests/grid-wfh.ui
Normal file
41
tests/reftests/grid-wfh.ui
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object class="GtkWindow" id="window1">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="type">popup</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="grid1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">GNOME is awesome!</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label4">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">GNOME is awesome!</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
Reference in New Issue
Block a user