1.75 <GtkFlowBox>

Class: <GtkFlowBox>

It derives from <GtkWidget>.

Puts child widgets in a reflowing grid.

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 flow-box:insert, and a <GtkFlowBoxChild> widget will automatically be inserted between the box and the widget.

Also see <GtkListBox>.

Shortcuts and Gestures

The following signals have default keybindings:

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.

Accessibility

<GtkFlowBox> uses the Gtk.AccessibleRole.grid role, and <GtkFlowBoxChild> uses the Gtk.AccessibleRole.grid_cell role.

Properties

Property: flow-box:accept-unpaired-release self

Whether to accept unpaired release events.

Its value is a boolean.

Set it with (set! (flow-box:accept-unpaired-release self) value).

Property: flow-box:activate-on-single-click self

Determines whether children can be activated with a single click, or require a double-click.

Its value is a boolean.

Set it with (set! (flow-box:activate-on-single-click self) value).

Property: flow-box:column-spacing self

The amount of horizontal space between two children.

Its value is an unsigned 32-bit integer.

Set it with (set! (flow-box:column-spacing self) value).

Property: flow-box:homogeneous self

Determines whether all children should be allocated the same size.

Its value is a boolean.

Set it with (set! (flow-box:homogeneous self) value).

Property: flow-box:max-children-per-line self

The maximum amount of children to request space for consecutively in the given orientation.

Its value is an unsigned 32-bit integer.

Set it with (set! (flow-box:max-children-per-line self) value).

Property: flow-box:min-children-per-line self

The minimum number of children to allocate consecutively in the given orientation.

Setting the minimum children per line ensures that a reasonably small height will be requested for the overall minimum width of the box.

Its value is an unsigned 32-bit integer.

Set it with (set! (flow-box:min-children-per-line self) value).

Property: flow-box:row-spacing self

The amount of vertical space between two children.

Its value is an unsigned 32-bit integer.

Set it with (set! (flow-box:row-spacing self) value).

Property: flow-box:selection-mode self

The selection mode used by the flow box.

Its value is a <GtkSelectionMode> (or, to set it, one of its symbols).

Set it with (set! (flow-box:selection-mode self) value).

Procedures

Method: flow-box:append self child
Method: append self child

Adds child to the end of self.

If a sort function is set, the widget will actually be inserted at the calculated position.

See also: flow-box:insert.

self

Passed: a <GtkFlowBox>.

a ‘GtkFlowBox

child

Passed: a <GtkWidget>.

the <GtkWidget> to add

Method: flow-box:bind-model self model create-widget-func
Method: bind-model self model create-widget-func

Binds model to self.

If self was already bound to a model, that previous binding is destroyed.

The contents of self are cleared and then filled with widgets that represent items from model. self is updated whenever model changes. If model is #f, self is left empty.

It is undefined to add or remove widgets directly (for example, with flow-box:insert) while self is bound to a model.

Note that using a model is incompatible with the filtering and sorting functionality in <GtkFlowBox>. When using a model, filtering and sorting should be implemented by the model.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

model

Passed: a <GListModel>, or #f.

the <GListModel> to be bound to self

create-widget-func

Passed: a procedure.

a function that creates widgets for items

See GtkFlowBoxCreateWidgetFunc for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to create-widget-func

user-data-free-func

Not passed: guile-gi supplies it.

function for freeing user-data

See GDestroyNotify for how it is called.

Method: flow-box:get-activate-on-single-click? self ⇒ %return
Method: get-activate-on-single-click? self ⇒ %return

Returns whether children activate on single clicks.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: a boolean.

#t if children are activated on single click, #f otherwise

Method: flow-box:get-child-at-index self idx ⇒ %return
Method: get-child-at-index self idx ⇒ %return

Gets the nth child in the self.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

idx

Passed: a 32-bit integer.

the position of the child

%return

Returned: a <GtkFlowBoxChild>, or #f.

the child widget, which will always be a <GtkFlowBoxChild> or #f in case no child widget with the given index exists.

Method: flow-box:get-child-at-pos self x y ⇒ %return
Method: get-child-at-pos self x y ⇒ %return

Gets the child in the (x, y) position.

Both x and y are assumed to be relative to the origin of self.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

x

Passed: a 32-bit integer.

the x coordinate of the child

y

Passed: a 32-bit integer.

the y coordinate of the child

%return

Returned: a <GtkFlowBoxChild>, or #f.

the child widget, which will always be a <GtkFlowBoxChild> or #f in case no child widget exists for the given x and y coordinates.

Method: flow-box:get-column-spacing self ⇒ %return
Method: get-column-spacing self ⇒ %return

Gets the horizontal spacing.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: an unsigned 32-bit integer.

the horizontal spacing

Method: flow-box:get-homogeneous? self ⇒ %return
Method: get-homogeneous? self ⇒ %return

Returns whether the box is homogeneous.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: a boolean.

#t if the box is homogeneous.

Method: flow-box:get-max-children-per-line self ⇒ %return
Method: get-max-children-per-line self ⇒ %return

Gets the maximum number of children per line.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: an unsigned 32-bit integer.

the maximum number of children per line

Method: flow-box:get-min-children-per-line self ⇒ %return
Method: get-min-children-per-line self ⇒ %return

Gets the minimum number of children per line.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: an unsigned 32-bit integer.

the minimum number of children per line

Method: flow-box:get-row-spacing self ⇒ %return
Method: get-row-spacing self ⇒ %return

Gets the vertical spacing.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: an unsigned 32-bit integer.

the vertical spacing

Method: flow-box:get-selected-children self ⇒ %return
Method: get-selected-children self ⇒ %return

Creates a list of all selected children.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: a list, each a <GtkFlowBoxChild>.

A GList containing the <GtkWidget> for each selected child. Free with g_list_free() when done.

Method: flow-box:get-selection-mode self ⇒ %return
Method: get-selection-mode self ⇒ %return

Gets the selection mode of self.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

%return

Returned: a <GtkSelectionMode>.

the <GtkSelectionMode>

Method: flow-box:insert self widget position
Method: insert self widget position

Inserts the widget into self at position.

If a sort function is set, the widget will actually be inserted at the calculated position.

If position is -1, or larger than the total number of children in the self, then the widget will be appended to the end.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

widget

Passed: a <GtkWidget>.

the <GtkWidget> to add

position

Passed: a 32-bit integer.

the position to insert child in

Method: flow-box:invalidate-filter self
Method: invalidate-filter self

Updates the filtering for all children.

Call this function when the result of the filter function on the self is changed due to an external factor. For instance, this would be used if the filter function just looked for a specific search term, and the entry with the string has changed.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

Method: flow-box:invalidate-sort self
Method: invalidate-sort self

Updates the sorting for all children.

Call this when the result of the sort function on self is changed due to an external factor.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

Procedure: flow-box:new ⇒ %return

Creates a <GtkFlowBox>.

%return

Returned: a <GtkWidget>.

a new <GtkFlowBox>

Method: flow-box:prepend self child
Method: prepend self child

Adds child to the start of self.

If a sort function is set, the widget will actually be inserted at the calculated position.

See also: flow-box:insert.

self

Passed: a <GtkFlowBox>.

a ‘GtkFlowBox

child

Passed: a <GtkWidget>.

the <GtkWidget> to add

Method: flow-box:remove self widget
Method: remove self widget

Removes a child from self.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

widget

Passed: a <GtkWidget>.

the child widget to remove

Method: flow-box:remove-all self
Method: remove-all self

Removes all children from self.

This function does nothing if self is backed by a model.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

Method: flow-box:select-all self
Method: select-all self

Select all children of self, if the selection mode allows it.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

Method: flow-box:select-child self child
Method: select-child self child

Selects a single child of self, if the selection mode allows it.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

child

Passed: a <GtkFlowBoxChild>.

a child of self

Method: flow-box:selected-foreach self func
Method: selected-foreach self func

Calls a function for each selected child.

Note that the selection cannot be modified from within this function.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

func

Passed: a procedure.

the function to call for each selected child

See GtkFlowBoxForeachFunc for how it is called.

data

Not passed: guile-gi supplies it.

user data to pass to the function

Method: flow-box:set-activate-on-single-click self single
Method: set-activate-on-single-click self single

If single is #t, children will be activated when you click on them, otherwise you need to double-click.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

single

Passed: a boolean.

#t to emit child-activated on a single click

Method: flow-box:set-column-spacing self spacing
Method: set-column-spacing self spacing

Sets the horizontal space to add between children.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

spacing

Passed: an unsigned 32-bit integer.

the spacing to use

Method: flow-box:set-filter-func self [filter-func]
Method: set-filter-func self [filter-func]

By setting a filter function on the self 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.

The filter-func will be called for each child after the call, and it will continue to be called each time a child changes (via flow-box-child:changed) or when flow-box:invalidate-filter is called.

Note that using a filter function is incompatible with using a model (see flow-box:bind-model).

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

filter-func

Passed, or left out: a procedure, or #f.

callback that lets you filter which children to show

See GtkFlowBoxFilterFunc for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to filter-func

destroy

Not passed: guile-gi supplies it.

destroy notifier for user-data

See GDestroyNotify for how it is called.

Method: flow-box:set-hadjustment self adjustment
Method: set-hadjustment self adjustment

Hooks up an adjustment to focus handling in self.

The adjustment is also used for autoscrolling during rubberband selection. See scrolled-window:get-hadjustment for a typical way of obtaining the adjustment, and flow-box:set-vadjustment for setting the vertical adjustment.

The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

adjustment

Passed: a <GtkAdjustment>.

an adjustment which should be adjusted when the focus is moved among the descendents of container

Method: flow-box:set-homogeneous self homogeneous
Method: set-homogeneous self homogeneous

Sets whether or not all children of self are given equal space in the box.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

homogeneous

Passed: a boolean.

#t to create equal allotments, #f for variable allotments

Method: flow-box:set-max-children-per-line self n-children
Method: set-max-children-per-line self n-children

Sets the maximum number of children to request and allocate space for in self’s orientation.

Setting the maximum number of children per line limits the overall natural size request to be no more than n-children children long in the given orientation.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

n-children

Passed: an unsigned 32-bit integer.

the maximum number of children per line

Method: flow-box:set-min-children-per-line self n-children
Method: set-min-children-per-line self n-children

Sets the minimum number of children to line up in self’s orientation before flowing.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

n-children

Passed: an unsigned 32-bit integer.

the minimum number of children per line

Method: flow-box:set-row-spacing self spacing
Method: set-row-spacing self spacing

Sets the vertical space to add between children.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

spacing

Passed: an unsigned 32-bit integer.

the spacing to use

Method: flow-box:set-selection-mode self mode
Method: set-selection-mode self mode

Sets how selection works in self.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

mode

Passed: a <GtkSelectionMode>, or one of its symbols.

the new selection mode

Method: flow-box:set-sort-func self [sort-func]
Method: set-sort-func self [sort-func]

By setting a sort function on the self, one can dynamically reorder the children of the box, based on the contents of the children.

The sort-func will be called for each child after the call, and will continue to be called each time a child changes (via flow-box-child:changed) and when flow-box:invalidate-sort is called.

Note that using a sort function is incompatible with using a model (see flow-box:bind-model).

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

sort-func

Passed, or left out: a procedure, or #f.

the sort function

See GtkFlowBoxSortFunc for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to sort-func

destroy

Not passed: guile-gi supplies it.

destroy notifier for user-data

See GDestroyNotify for how it is called.

Method: flow-box:set-vadjustment self adjustment
Method: set-vadjustment self adjustment

Hooks up an adjustment to focus handling in self.

The adjustment is also used for autoscrolling during rubberband selection. See scrolled-window:get-vadjustment for a typical way of obtaining the adjustment, and flow-box:set-hadjustment for setting the horizontal adjustment.

The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

adjustment

Passed: a <GtkAdjustment>.

an adjustment which should be adjusted when the focus is moved among the descendents of container

Method: flow-box:unselect-all self
Method: unselect-all self

Unselect all children of self, if the selection mode allows it.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

Method: flow-box:unselect-child self child
Method: unselect-child self child

Unselects a single child of self, if the selection mode allows it.

self

Passed: a <GtkFlowBox>.

a <GtkFlowBox>

child

Passed: a <GtkFlowBoxChild>.

a child of self

Signals

Signal: flow-box:activate-cursor-child

Connect a handler with (connect object flow-box:activate-cursor-child handler). It is called as (handler self).

Emitted when the user activates the box.

This is a keybinding signal.

self

Passed: a <GtkFlowBox>.

Signal: flow-box:child-activated

Connect a handler with (connect object flow-box:child-activated handler). It is called as (handler self child).

Emitted when a child has been activated by the user.

self

Passed: a <GtkFlowBox>.

child

Passed: a <GtkFlowBoxChild>.

the child that is activated

Signal: flow-box:move-cursor

Connect a handler with (connect object flow-box:move-cursor handler). It is called as (handler self step count extend modify) ⇒ %return.

Emitted when the user initiates a cursor movement.

This is a keybinding signal. Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifier does not. There are too many key combinations to list them all here.

  • ←, →, ↑, ↓ move by individual children
  • Home, End move to the ends of the box
  • PgUp, PgDn move vertically by pages
self

Passed: a <GtkFlowBox>.

step

Passed: a <GtkMovementStep>.

the granularity of the move, as a <GtkMovementStep>

count

Passed: a 32-bit integer.

the number of step units to move

extend

Passed: a boolean.

whether to extend the selection

modify

Passed: a boolean.

whether to modify the selection

%return

Returned: a boolean.

#t to stop other handlers from being invoked for the event. #f to propagate the event further.

Signal: flow-box:select-all

Connect a handler with (connect object flow-box:select-all handler). It is called as (handler self).

Emitted to select all children of the box, if the selection mode permits it.

This is a keybinding signal.

The default bindings for this signal is Ctrl-a.

self

Passed: a <GtkFlowBox>.

Signal: flow-box:selected-children-changed

Connect a handler with (connect object flow-box:selected-children-changed handler). It is called as (handler self).

Emitted when the set of selected children changes.

Use flow-box:selected-foreach or flow-box:get-selected-children to obtain the selected children.

self

Passed: a <GtkFlowBox>.

Signal: flow-box:toggle-cursor-child

Connect a handler with (connect object flow-box:toggle-cursor-child handler). It is called as (handler self).

Emitted to toggle the selection of the child that has the focus.

This is a keybinding signal.

The default binding for this signal is Ctrl-Space.

self

Passed: a <GtkFlowBox>.

Signal: flow-box:unselect-all

Connect a handler with (connect object flow-box:unselect-all handler). It is called as (handler self).

Emitted to unselect all children of the box, if the selection mode permits it.

This is a keybinding signal.

The default bindings for this signal is Ctrl-Shift-a.

self

Passed: a <GtkFlowBox>.