What is the difference between gtk_box_pack_start and gtk_container_add?

It seems to me that both functions can be used to add some widget to the container.

Who cares?

+3
source share
4 answers

gtk_pack_startgives you more control over the distribution of space of children. You can control whether the child widgets will “expand” (allocate additional space), “fill” (use all the allocated space, or only the minimum space requested by them) and the number of indents set for the child. Thus, if your container identifier is GtkBox, it is preferable to gtk_box_pack_start/ gtk_box_pack_end, since gtk_container_add will work, but use default values ​​that are not optimal most of the time.

+3
source

GtkBox , GtkContainer, GtkBox GtkContainer, GtkContainer GtkWidgets GtkWidgets.

, GtkBox .

, , gtk_box_pack_start , , hbox, gtk_container_add, , .

http://library.gnome.org/devel/gtk/stable/GtkContainer.html#GtkContainer.description

http://library.gnome.org/devel/gtk/stable/GtkBox.html#GtkBox.description

+2

GtkBox :

gtk_container_add(box, widget)
gtk_box_pack_start(box, widget, default_expand, default_expand, 0)

http://git.gnome.org/browse/gtk+/tree/gtk/gtkbox.c#n1665

+2

gtk_container adds widgets to the container (by the way, many widgets can be containers), and gtk_box_pack_start is used to pack widgets in some virtual objects called boxes, which are also widgets. Adding simply puts them in a container in accordance with some predefined rules, where, as in the package, you specify how to add widgets, and then add these hosted widgets to the container.

+1
source

Source: https://habr.com/ru/post/1743621/


All Articles