
# This is an abstract interface; the CellLayout interface is
# implemented by concrete classes like ComboBox and TreeViewColumn.
# See the discussion for details on creating your own CellLayout.
# This synopsis assumes you already have an instance in $cell_layout.
# Add a cell renderer that shows the pixbuf in column 2 of the
# associated TreeModel. It will take up only the necessary space
# ("expand" => FALSE).
my $cell = Gtk2::CellRendererPixbuf->new ();
$cell_layout->pack_start ($cell, FALSE);
$cell_layout->add_attribute ($cell, pixbuf => 2);
# Add another cell renderer that gets the "text" property from
# column 3 of the associated TreeModel, and takes up all remaining
# horizontal space ("expand" => TRUE).
my $cell = Gtk2::CellRendererText->new ();
$cell_layout->pack_start ($cell, TRUE);
$cell_layout->add_attribute ($cell, text => 3);

Gtk2::CellLayout is an interface to be implemented by all objects which want to provide a Gtk2::TreeViewColumn-like API for packing cells, setting attributes and data funcs.

GTK+ provides several CellLayout implementations, such as Gtk2::TreeViewColumn and Gtk2::ComboBox. To create your own object that implements the CellLayout interface and therefore can be used to display CellRenderers, you need to add Gtk2::CellLayout to your class's "interfaces" list, like this:
package MyLayout;
use Gtk2;
use Glib::Object::Subclass
Gtk2::Widget::,
interfaces => [ Gtk2::CellLayout:: ],
;
This will cause perl to call several virtual methods with ALL_CAPS_NAMES when GTK+ attempts to perform certain actions. You simply provide (or override) those methods with perl code. The methods map rather directly to the object interface, so it should be easy to figure out what they should do. Those methods are: