<interface>
<object class='GtkWindow' id='window'>
<child>
<object class='GtkBox' id='box'>
<property name='orientation'>horizontal</property>
<child>
<object class='GtkAspectFrame' id='aspect_frame'>
<property name='xalign'>0.0</property>
<property name='yalign'>0.0</property>
<child>
<object class='GtkDrawingArea' id='drawing_area_A'>
<property name='expand'>TRUE</property>
</object>
</child>
</object>
</child>
<child>
<!-- widget B goes here -->
</child>
</object>
</child>
</object>
</interface>
The above GtkBuilder UI definition creates a square DrawingArea A. I want it to be as large as possible within its window, so I set the expand
property of A to TRUE
. However, when the window itself has a greater width than height, I want a widget, B, to fill the remainder width not used by the drawing area. Basically, I want this:
+--------------------+
|+-----------++-----+|
|| || ||
|| A || B ||
|| || ||
|| || ||
|+-----------++-----+|
+--------------------+
But I get this instead (if B has expand
set to FALSE
):
+--------------------+
|+-----------+ +-+|
|| | | ||
|| A | |B||
|| | | ||
|| | | ||
|+-----------+ +-+|
+--------------------+
Or this (if B has expand
set to TRUE
):
+--------------------+
|+-------++---------+|
|| || ||
|| A || B ||
|| || ||
|+-------+| ||
| +---------+|
+--------------------+
How do I get GTK to cooperate?
gtk_widget_get_preferred_width_for_height()
. No idea if this is doable from XML or if there's a simpler way. – doublep