1.111 <GtkListBox>

Class: <GtkListBox>

It derives from <GtkWidget>.

Shows a vertical list.

A <GtkListBox> only contains <GtkListBoxRow> children. These rows can by dynamically sorted and filtered, and headers can be added dynamically depending on the row content. It also allows keyboard and mouse navigation and selection like a typical list.

Using <GtkListBox> is often an alternative to GtkTreeView, especially when the list contents has a more complicated layout than what is allowed by a GtkCellRenderer, or when the contents is interactive (i.e. has a button in it).

Although a <GtkListBox> must have only <GtkListBoxRow> children, you can add any kind of widget to it via list-box:prepend, list-box:append and list-box:insert and a <GtkListBoxRow> widget will automatically be inserted between the list and the widget.

GtkListBoxRows can be marked as activatable or selectable. If a row is activatable, list-box:row-activated will be emitted for it when the user tries to activate it. If it is selectable, the row will be marked as selected when the user tries to select it.

GtkListBox as GtkBuildable

The <GtkListBox> implementation of the <GtkBuildable> interface supports setting a child as the placeholder by specifying “placeholder” as the “type” attribute of a <child> element. See list-box:set-placeholder for info.

Shortcuts and Gestures

The following signals have default keybindings:

CSS nodes

list[.separators][.rich-list][.navigation-sidebar][.boxed-list]
╰── row[.activatable]

<GtkListBox> uses a single CSS node named list. It may carry the .separators style class, when the list-box:show-separators property is set. Each <GtkListBoxRow> uses a single CSS node named row. The row nodes get the .activatable style class added when appropriate.

It may also carry the .boxed-list style class. In this case, the list will be automatically surrounded by a frame and have separators.

The main list node may also carry style classes to select the style of list presentation: .rich-list, .navigation-sidebar or .data-table.

Accessibility

<GtkListBox> uses the Gtk.AccessibleRole.list role and <GtkListBoxRow> uses the Gtk.AccessibleRole.list_item role.

Properties

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

Whether to accept unpaired release events.

Its value is a boolean.

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

Property: list-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! (list-box:activate-on-single-click self) value).

Property: list-box:selection-mode self

The selection mode used by the list box.

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

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

Property: list-box:show-separators self

Whether to show separators between rows.

Its value is a boolean.

Set it with (set! (list-box:show-separators self) value).

Property: list-box:tab-behavior self

Behavior of the Tab key

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

Set it with (set! (list-box:tab-behavior self) value).

Procedures

Method: list-box:append self child
Method: append self child

Append a widget to the list.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

child

Passed: a <GtkWidget>.

the <GtkWidget> to add

Method: list-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 list-box:insert) while self is bound to a model.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

model

Passed, or left out: a <GListModel>, or #f.

the <GListModel> to be bound to self

create-widget-func

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

a function that creates widgets for items or #f in case you also passed #f as model

See GtkListBoxCreateWidgetFunc 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: list-box:drag-highlight-row self row
Method: drag-highlight-row self row

Add a drag highlight to a row.

This is a helper function for implementing DnD onto a <GtkListBox>. The passed in row will be highlighted by setting the drop-active state and any previously highlighted row will be unhighlighted.

The row will also be unhighlighted when the widget gets a drag leave event.

self

Passed: a <GtkListBox>.

a <GtkListBox>

row

Passed: a <GtkListBoxRow>.

a <GtkListBoxRow>

Method: list-box:drag-unhighlight-row self
Method: drag-unhighlight-row self

If a row has previously been highlighted via list-box:drag-highlight-row, it will have the highlight removed.

self

Passed: a <GtkListBox>.

a <GtkListBox>

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

Returns whether rows activate on single clicks.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a boolean.

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

Method: list-box:get-adjustment self ⇒ %return
Method: get-adjustment self ⇒ %return

Gets the adjustment (if any) that the widget uses to for vertical scrolling.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a <GtkAdjustment>, or #f.

the adjustment

Method: list-box:get-row-at-index self index- ⇒ %return
Method: get-row-at-index self index- ⇒ %return

Gets the n-th child in the list (not counting headers).

If index- is negative or larger than the number of items in the list, #f is returned.

self

Passed: a <GtkListBox>.

a <GtkListBox>

index-

Passed: a 32-bit integer.

the index of the row

%return

Returned: a <GtkListBoxRow>, or #f.

the child <GtkWidget>

Method: list-box:get-row-at-y self y ⇒ %return
Method: get-row-at-y self y ⇒ %return

Gets the row at the y position.

self

Passed: a <GtkListBox>.

a <GtkListBox>

y

Passed: a 32-bit integer.

position

%return

Returned: a <GtkListBoxRow>, or #f.

the row

Method: list-box:get-selected-row self ⇒ %return
Method: get-selected-row self ⇒ %return

Gets the selected row, or #f if no rows are selected.

Note that the box may allow multiple selection, in which case you should use list-box:selected-foreach to find all selected rows.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a <GtkListBoxRow>, or #f.

the selected row

Method: list-box:get-selected-rows self ⇒ %return
Method: get-selected-rows self ⇒ %return

Creates a list of all selected children.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a list, each a <GtkListBoxRow>.

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

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

Gets the selection mode of the listbox.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a <GtkSelectionMode>.

a <GtkSelectionMode>

Method: list-box:get-show-separators? self ⇒ %return
Method: get-show-separators? self ⇒ %return

Returns whether the list box should show separators between rows.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a boolean.

#t if the list box shows separators

Method: list-box:get-tab-behavior self ⇒ %return
Method: get-tab-behavior self ⇒ %return

Returns the behavior of the Tab and Shift+Tab keys.

self

Passed: a <GtkListBox>.

a <GtkListBox>

%return

Returned: a <GtkListTabBehavior>.

the tab behavior

Method: list-box:insert self child position
Method: insert self child position

Insert the child into the 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 items in the self, then the child will be appended to the end.

self

Passed: a <GtkListBox>.

a <GtkListBox>

child

Passed: a <GtkWidget>.

the <GtkWidget> to add

position

Passed: a 32-bit integer.

the position to insert child in

Method: list-box:invalidate-filter self
Method: invalidate-filter self

Update the filtering for all rows.

Call this when 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 string and the entry with the search string has changed.

self

Passed: a <GtkListBox>.

a <GtkListBox>

Method: list-box:invalidate-headers self
Method: invalidate-headers self

Update the separators for all rows.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

Method: list-box:invalidate-sort self
Method: invalidate-sort self

Update the sorting for all rows.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

Procedure: list-box:new ⇒ %return

Creates a new <GtkListBox> container.

%return

Returned: a <GtkWidget>.

a new <GtkListBox>

Method: list-box:prepend self child
Method: prepend self child

Prepend a widget to the list.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

child

Passed: a <GtkWidget>.

the <GtkWidget> to add

Method: list-box:remove self child
Method: remove self child

Removes a child from self.

self

Passed: a <GtkListBox>.

a <GtkListBox>

child

Passed: a <GtkWidget>.

the child to remove

Method: list-box:remove-all self
Method: remove-all self

Removes all rows from self.

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

Method: list-box:select-all self
Method: select-all self

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

Method: list-box:select-row self [row]
Method: select-row self [row]

Make row the currently selected row.

self

Passed: a <GtkListBox>.

a <GtkListBox>

row

Passed, or left out: a <GtkListBoxRow>, or #f.

The row to select

Method: list-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 <GtkListBox>.

a <GtkListBox>

func

Passed: a procedure.

the function to call for each selected child

See GtkListBoxForeachFunc for how it is called.

data

Not passed: guile-gi supplies it.

user data to pass to the function

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

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

single

Passed: a boolean.

a boolean

Method: list-box:set-adjustment self [adjustment]
Method: set-adjustment self [adjustment]

Sets the adjustment (if any) that the widget uses to for vertical scrolling.

For instance, this is used to get the page size for PageUp/Down key handling.

In the normal case when the self is packed inside a <GtkScrolledWindow> the adjustment from that will be picked up automatically, so there is no need to manually do that.

self

Passed: a <GtkListBox>.

a <GtkListBox>

adjustment

Passed, or left out: a <GtkAdjustment>, or #f.

the adjustment

Method: list-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 rows to show.

For instance, to implement a search function on a list that filters the original list to only show the matching rows.

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

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

filter-func

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

callback that lets you filter which rows to show

See GtkListBoxFilterFunc 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: list-box:set-header-func self [update-header]
Method: set-header-func self [update-header]

Sets a header function.

By setting a header function on the self one can dynamically add headers in front of rows, depending on the contents of the row and its position in the list.

For instance, one could use it to add headers in front of the first item of a new kind, in a list sorted by the kind.

The update-header can look at the current header widget using list-box-row:get-header and either update the state of the widget as needed, or set a new one using list-box-row:set-header. If no header is needed, set the header to #f.

Note that you may get many calls update-header to this for a particular row when e.g. changing things that don’t affect the header. In this case it is important for performance to not blindly replace an existing header with an identical one.

The update-header function will be called for each row after the call, and it will continue to be called each time a row changes (via list-box-row:changed) and when the row before changes (either by list-box-row:changed on the previous row, or when the previous row becomes a different row). It is also called for all rows when list-box:invalidate-headers is called.

self

Passed: a <GtkListBox>.

a <GtkListBox>

update-header

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

callback that lets you add row headers

See GtkListBoxUpdateHeaderFunc for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to update-header

destroy

Not passed: guile-gi supplies it.

destroy notifier for user-data

See GDestroyNotify for how it is called.

Method: list-box:set-placeholder self [placeholder]
Method: set-placeholder self [placeholder]

Sets the placeholder widget that is shown in the list when it doesn’t display any visible children.

self

Passed: a <GtkListBox>.

a <GtkListBox>

placeholder

Passed, or left out: a <GtkWidget>, or #f.

a <GtkWidget>

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

Sets how selection works in the listbox.

self

Passed: a <GtkListBox>.

a <GtkListBox>

mode

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

The <GtkSelectionMode>

Method: list-box:set-show-separators self show-separators
Method: set-show-separators self show-separators

Sets whether the list box should show separators between rows.

self

Passed: a <GtkListBox>.

a <GtkListBox>

show-separators

Passed: a boolean.

#t to show separators

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

Sets a sort function.

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

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

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

sort-func

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

the sort function

See GtkListBoxSortFunc 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: list-box:set-tab-behavior self behavior
Method: set-tab-behavior self behavior

Sets the behavior of the Tab and Shift+Tab keys.

self

Passed: a <GtkListBox>.

a <GtkListBox>

behavior

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

the tab behavior

Method: list-box:unselect-all self
Method: unselect-all self

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

Method: list-box:unselect-row self row
Method: unselect-row self row

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

self

Passed: a <GtkListBox>.

a <GtkListBox>

row

Passed: a <GtkListBoxRow>.

the row to unselect

Signals

Signal: list-box:activate-cursor-row

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

Emitted when the cursor row is activated.

self

Passed: a <GtkListBox>.

Signal: list-box:move-cursor

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

Emitted when the user initiates a cursor movement.

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 <GtkListBox>.

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

Signal: list-box:row-activated

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

Emitted when a row has been activated by the user.

self

Passed: a <GtkListBox>.

row

Passed: a <GtkListBoxRow>.

the activated row

Signal: list-box:row-selected

Connect a handler with (connect object list-box:row-selected handler). It is called as (handler self row).

Emitted when a new row is selected, or (with a #f row) when the selection is cleared.

When the box is using multiple, this signal will not give you the full picture of selection changes, and you should use the list-box:selected-rows-changed signal instead.

self

Passed: a <GtkListBox>.

row

Passed: a <GtkListBoxRow>, or #f.

the selected row

Signal: list-box:select-all

Connect a handler with (connect object list-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 binding for this signal is Ctrl-a.

self

Passed: a <GtkListBox>.

Signal: list-box:selected-rows-changed

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

Emitted when the set of selected rows changes.

self

Passed: a <GtkListBox>.

Signal: list-box:toggle-cursor-row

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

Emitted when the cursor row is toggled.

The default bindings for this signal is Ctrl+␣.

self

Passed: a <GtkListBox>.

Signal: list-box:unselect-all

Connect a handler with (connect object list-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 binding for this signal is Ctrl-Shift-a.

self

Passed: a <GtkListBox>.