There are two kinds of container widgets in GTK+. All of
them are subclasses of the abstract
GtkContainer. The first type of container widget
always descends from GtkBin,
another abstract base class. Descendents of GtkBin can contain only one child widget;
these containers add some kind of functionality to the
child. For example, GtkButton is
a GtkBin which makes the child
into a clickable button.
GtkFrame is a GtkBin which
draws a relieved border around the child. GtkWindow allows the child to appear in a
The second type of container widget often has GtkContainer as its immediate parent.
These containers can have more than one child, and their
purpose is to manage layout. "Manage layout" means that
these containers assign sizes and
positions to the widgets they
contain. For example, GtkVBox
arranges its children in a vertical stack. GtkFixed allows you to position children
at arbitrary coordinates.
GtkPacker gives you Tk-style layout management.
This chapter is about the second kind of container. To
produce the layout you want without hard-coding any sizes,
you'll need to understand how to use these. The goal is to
avoid making assumptions about window size, screen size,
widget appearance, fonts, and so on. Your application
should automatically adapt if these factors change.
To understand layout containers, you first have to
understand how GTK+ widgets negotiate their size. It's
quite simple really; there are only two concepts, requisition and allocation. These correspond to the two
phases of layout.