It seems to me that both functions can be used to add some widget to the container.
What's the difference?
It seems to me that both functions can be used to add some widget to the container.
What's the difference?
GtkBox is further down the object hierarchy than GtkContainer, that is GtkBox adds the notion of packing to GtkContainer, with GtkContainer adding the ability for GtkWidgets to contain other GtkWidgets.
In short, GtkBox gives you more control over the layout of the contained widgets.
So if you need more control use gtk_box_pack_start to pack widgets, for example adding a number of aligned combo boxes within a hbox, otherwise use gtk_container_add, for example adding a frame to a window.
http://library.gnome.org/devel/gtk/stable/GtkContainer.html#GtkContainer.description
http://library.gnome.org/devel/gtk/stable/GtkBox.html#GtkBox.description
gtk_pack_start
gives you more control over how child widgets are allocated space. You can control whether child widgets will "expand" (allocate any extra space), "fill" (use all allocated space or only minimum space requested by them), and amount of padding given to child. So, if your container id a GtkBox, gtk_box_pack_start
/gtk_box_pack_end
is preferred, as gtk_container_add will work, but use default values, which are not optimal most of the time.
On a GtkBox, the following pseudo-code is equivalent:
gtk_container_add(box, widget)
gtk_box_pack_start(box, widget, default_expand, default_expand, 0)