Object Hierarchy:

Object hierarchy for LayoutManager


[ CCode ( type_id = "gtk_layout_manager_get_type ()" ) ]
public abstract class LayoutManager : Object

Layout managers are delegate classes that handle the preferred size and the allocation of a container widget.

You typically subclass LayoutManager if you want to implement a layout policy for the children of a widget, or if you want to determine the size of a widget depending on its contents.

Each Widget can only have a LayoutManager instance associated to it at any given time; it is possible, though, to replace the layout manager instance using set_layout_manager.

Layout properties

A layout manager can expose properties for controlling the layout of each child, by creating an object type derived from LayoutChild and installing the properties on it as normal GObject properties.

Each LayoutChild instance storing the layout properties for a specific child is created through the get_layout_child method; a LayoutManager controls the creation of its LayoutChild instances by overriding the GtkLayoutManagerClass.create_layout_child() virtual function. The typical implementation should look like:

static GtkLayoutChild *
create_layout_child (GtkLayoutManager *manager,
GtkWidget *container,
GtkWidget *child)
return g_object_new (your_layout_child_get_type (),
"layout-manager", manager,
"child-widget", child,

The layout_manager and child_widget properties on the newly created LayoutChild instance are mandatory. The LayoutManager will cache the newly created LayoutChild instance until the widget is removed from its parent, or the parent removes the layout manager.

Each LayoutManager instance creating a LayoutChild should use get_layout_child every time it needs to query the layout properties; each LayoutChild instance should call layout_changed every time a property is updated, in order to queue a new size measuring and allocation.

Namespace: Gtk
Package: gtk4


Creation methods:


Inherited Members: