gtk.flow_box

Module for [FlowBox] class

Types 3

A GtkFlowBox positions child widgets in sequence according to its orientation.

For instance, with the horizontal orientation, the widgets will be arranged from left to right, starting a new row under the previous row when necessary. Reducing the width in this case will require more rows, so a larger height will be requested.

Likewise, with the vertical orientation, the widgets will be arranged from top to bottom, starting a new column to the right when necessary. Reducing the height will require more columns, so a larger width will be requested.

The size request of a GtkFlowBox alone may not be what you expect; if you need to be able to shrink it along both axes and dynamically reflow its children, you may have to wrap it in a #GtkScrolledWindow to enable that.

The children of a GtkFlowBox can be dynamically sorted and filtered.

Although a GtkFlowBox must have only #GtkFlowBoxChild children, you can add any kind of widget to it via [gtk.container.Container.add], and a GtkFlowBoxChild widget will automatically be inserted between the box and the widget.

Also see #GtkListBox.

GtkFlowBox was added in GTK+ 3.12.

CSS nodes

flowbox
├── flowboxchild
│   ╰── <child>
├── flowboxchild
│   ╰── <child>
┊
╰── [rubberband]

GtkFlowBox uses a single CSS node with name flowbox. GtkFlowBoxChild uses a single CSS node with name flowboxchild. For rubberband selection, a subnode with name rubberband is used.

Methods
GType _gType() @property
FlowBox self()Returns `this`, for use in `with` statements.
FlowBoxGidBuilder builder()Get builder for [gtk.flow_box.FlowBox] Returns: New builder object
bool activateOnSingleClick() @propertyGet `activateOnSingleClick` property. Returns: Determines whether children can be activated with a single click, or require a double-click.
void activateOnSingleClick(bool propval) @propertySet `activateOnSingleClick` property. Params: propval = Determines whether children can be activated with a single click, or require a double-click.
uint columnSpacing() @propertyGet `columnSpacing` property. Returns: The amount of horizontal space between two children.
void columnSpacing(uint propval) @propertySet `columnSpacing` property. Params: propval = The amount of horizontal space between two children.
bool homogeneous() @propertyGet `homogeneous` property. Returns: Determines whether all children should be allocated the same size.
void homogeneous(bool propval) @propertySet `homogeneous` property. Params: propval = Determines whether all children should be allocated the same size.
uint maxChildrenPerLine() @propertyGet `maxChildrenPerLine` property. Returns: The maximum amount of children to request space for consecutively in the given orientation.
void maxChildrenPerLine(uint propval) @propertySet `maxChildrenPerLine` property. Params: propval = The maximum amount of children to request space for consecutively in the given orientation.
uint minChildrenPerLine() @propertyGet `minChildrenPerLine` property. Returns: The minimum number of children to allocate consecutively in the given orientation.
void minChildrenPerLine(uint propval) @propertySet `minChildrenPerLine` property. Params: propval = The minimum number of children to allocate consecutively in the given orientation.
uint rowSpacing() @propertyGet `rowSpacing` property. Returns: The amount of vertical space between two children.
void rowSpacing(uint propval) @propertySet `rowSpacing` property. Params: propval = The amount of vertical space between two children.
gtk.types.SelectionMode selectionMode() @propertyGet `selectionMode` property. Returns: The selection mode used by the flow box.
void selectionMode(gtk.types.SelectionMode propval) @propertySet `selectionMode` property. Params: propval = The selection mode used by the flow box.
void bindModel(gio.list_model.ListModel model, gtk.types.FlowBoxCreateWidgetFunc createWidgetFunc)Binds model to box.
bool getActivateOnSingleClick()Returns whether children activate on single clicks. Returns: true if children are activated on single click, false otherwise
gtk.flow_box_child.FlowBoxChild getChildAtIndex(int idx)Gets the nth child in the box.
gtk.flow_box_child.FlowBoxChild getChildAtPos(int x, int y)Gets the child in the (`x`, `y`) position.
uint getColumnSpacing()Gets the horizontal spacing. Returns: the horizontal spacing
bool getHomogeneous()Returns whether the box is homogeneous (all children are the same size). See [gtk.box.Box.setHomogeneous]. Returns: true if the box is homogeneous.
uint getMaxChildrenPerLine()Gets the maximum number of children per line. Returns: the maximum number of children per line
uint getMinChildrenPerLine()Gets the minimum number of children per line. Returns: the minimum number of children per line
uint getRowSpacing()Gets the vertical spacing. Returns: the vertical spacing
gtk.flow_box_child.FlowBoxChild[] getSelectedChildren()Creates a list of all selected children. Returns: A #GList containing the #GtkWidget for each selected child. Free with [glib.list.List.free] when done.
gtk.types.SelectionMode getSelectionMode()Gets the selection mode of box. Returns: the #GtkSelectionMode
void insert(gtk.widget.Widget widget, int position)Inserts the widget into box at position.
void invalidateFilter()Updates the filtering for all children.
void invalidateSort()Updates the sorting for all children.
void selectAll()Select all children of box, if the selection mode allows it.
void selectChild(gtk.flow_box_child.FlowBoxChild child)Selects a single child of box, if the selection mode allows it.
void selectedForeach(gtk.types.FlowBoxForeachFunc func)Calls a function for each selected child.
void setActivateOnSingleClick(bool single)If single is true, children will be activated when you click on them, otherwise you need to double-click.
void setColumnSpacing(uint spacing)Sets the horizontal space to add between children. See the #GtkFlowBox:column-spacing property.
void setFilterFunc(gtk.types.FlowBoxFilterFunc filterFunc = null)By setting a filter function on the box one can decide dynamically which of the children to show. For instance, to implement a search function that only shows the children matching the search terms.
void setHadjustment(gtk.adjustment.Adjustment adjustment)Hooks up an adjustment to focus handling in box. The adjustment is also used for autoscrolling during rubberband selection. See [gtk.scrolledwindow.ScrolledWindow.getHadjustment] for a typical way ...
void setHomogeneous(bool homogeneous)Sets the #GtkFlowBox:homogeneous property of box, controlling whether or not all children of box are given equal space in the box.
void setMaxChildrenPerLine(uint nChildren)Sets the maximum number of children to request and allocate space for in box’s orientation.
void setMinChildrenPerLine(uint nChildren)Sets the minimum number of children to line up in box’s orientation before flowing.
void setRowSpacing(uint spacing)Sets the vertical space to add between children. See the #GtkFlowBox:row-spacing property.
void setSelectionMode(gtk.types.SelectionMode mode)Sets how selection works in box. See #GtkSelectionMode for details.
void setSortFunc(gtk.types.FlowBoxSortFunc sortFunc = null)By setting a sort function on the box, one can dynamically reorder the children of the box, based on the contents of the children.
void setVadjustment(gtk.adjustment.Adjustment adjustment)Hooks up an adjustment to focus handling in box. The adjustment is also used for autoscrolling during rubberband selection. See [gtk.scrolledwindow.ScrolledWindow.getVadjustment] for a typical way ...
void unselectAll()Unselect all children of box, if the selection mode allows it.
void unselectChild(gtk.flow_box_child.FlowBoxChild child)Unselects a single child of box, if the selection mode allows it.
gulong connectActivateCursorChild(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box.FlowBox))) && Parameters!T.length < 2)Connect to `ActivateCursorChild` signal.
gulong connectChildActivated(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box_child.FlowBoxChild))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.flow_box.FlowBox))) && Parameters!T.length < 3)Connect to `ChildActivated` signal.
gulong connectMoveCursor(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.MovementStep))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.flow_box.FlowBox))) && Parameters!T.length < 4)Connect to `MoveCursor` signal.
gulong connectSelectAll(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box.FlowBox))) && Parameters!T.length < 2)Connect to `SelectAll` signal.
gulong connectSelectedChildrenChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box.FlowBox))) && Parameters!T.length < 2)Connect to `SelectedChildrenChanged` signal.
gulong connectToggleCursorChild(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box.FlowBox))) && Parameters!T.length < 2)Connect to `ToggleCursorChild` signal.
gulong connectUnselectAll(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.flow_box.FlowBox))) && Parameters!T.length < 2)Connect to `UnselectAll` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a GtkFlowBox. Returns: a new #GtkFlowBox container
Methods
T activateOnSingleClick(bool propval)Set `activateOnSingleClick` property. Params: propval = Determines whether children can be activated with a single click, or require a double-click. Returns: Builder instance for fluent chaining
T columnSpacing(uint propval)Set `columnSpacing` property. Params: propval = The amount of horizontal space between two children. Returns: Builder instance for fluent chaining
T homogeneous(bool propval)Set `homogeneous` property. Params: propval = Determines whether all children should be allocated the same size. Returns: Builder instance for fluent chaining
T maxChildrenPerLine(uint propval)Set `maxChildrenPerLine` property. Params: propval = The maximum amount of children to request space for consecutively in the given orientation. Returns: Builder instance for fluent chaining
T minChildrenPerLine(uint propval)Set `minChildrenPerLine` property. Params: propval = The minimum number of children to allocate consecutively in the given orientation.
T rowSpacing(uint propval)Set `rowSpacing` property. Params: propval = The amount of vertical space between two children. Returns: Builder instance for fluent chaining
T selectionMode(gtk.types.SelectionMode propval)Set `selectionMode` property. Params: propval = The selection mode used by the flow box. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.flow_box.FlowBox]

Methods