Chapter 4. The packing problem

Background

The reader who is used to WISYWIG IDEs, may feel lost in the wilderness when exposed to packing widgets for the first time. With a piece of paper to plan your screen and a few applications worth of practice, the packing skill soon becomes second nature.

4.1. Gtk2::Bin and its subclasses

Widgets gets packed into containers (all of which are subclasses of Gtk2::Container), but containers which are subclasses of Gtk2::Bin can house only one child widget. This includes Gtk2::Window and Gtk2::Button.

Widgets gets added or removed by using the Gtk2::Container class's add and remove methods.

If you already added a widget to a container who is a subclass of Gtk2::Bin, it is impossible to add a second widget to it. To overcome this limitation, you add a special widget, who in turn can contain more than one widget. These special widgets can be divided into boxes and tables.

Figure 4-1. Packing Schematic