gtk_container_add and vboxes
- From: Allin Cottrell <cottrell wfu edu>
- To: gtk-app-devel-list gnome org
- Subject: gtk_container_add and vboxes
- Date: Thu, 31 May 2012 11:39:05 -0400 (EDT)
I was modifying some gtk code to hush deprecations from gtk
3.4.3 and came across the following oddity.
One might think that these should be equivalent:
1) as per gtk2:
GtkWidget *box = gtk_vbox_new(FALSE, 4);
2) as recommended in gtk3:
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(box), FALSE);
But they're not equivalent. The widgets obtained via the two
methods behave quite differently when you add a single child
widget using gtk_container_add(). In the first case the child
takes up the full available vertical allotment, which is
surely what one would expect. In the second case the child may
appear compressed, taking up only a small fraction of the
vertical space available in the parent and leaving a big ugly
blank. This can be fixed by using gtk_box_pack_start() with
explicit TRUE values for the expand and fill arguments.
Now admittedly, gtk_container_add() doesn't offer any
guarantees; the doc states that "this function will pick
default packing parameters that may not be correct". But it
seems like a regression that these default packing parameters,
which were fine under the old API, should now be so off-base.
--
Allin Cottrell
Department of Economics
Wake Forest University, NC
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]