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.
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.
The following signals have default keybindings:
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.
<GtkListBox> uses the
Gtk.AccessibleRole.list role and
<GtkListBoxRow> uses the
Gtk.AccessibleRole.list_item role.
Whether to accept unpaired release events.
Its value is a boolean.
Set it with (set! (list-box:accept-unpaired-release self) value).
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).
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).
Whether to show separators between rows.
Its value is a boolean.
Set it with (set! (list-box:show-separators self) value).
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).
Append a widget to the list.
If a sort function is set, the widget will actually be inserted at the calculated position.
Passed: a <GtkListBox>.
Passed: a <GtkWidget>.
the <GtkWidget> to add
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.
Passed: a <GtkListBox>.
Passed, or left out: a <GListModel>, or
#f.
the <GListModel> to be bound to self
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.
Not passed: guile-gi supplies it.
user data passed to create-widget-func
Not passed: guile-gi supplies it.
function for freeing user-data
See GDestroyNotify for how it is
called.
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.
Passed: a <GtkListBox>.
Passed: a <GtkListBoxRow>.
If a row has previously been highlighted via list-box:drag-highlight-row, it will have the
highlight removed.
Passed: a <GtkListBox>.
Returns whether rows activate on single clicks.
Passed: a <GtkListBox>.
Returned: a boolean.
#t if rows are activated on single click, #f otherwise
Gets the adjustment (if any) that the widget uses to for vertical scrolling.
Passed: a <GtkListBox>.
Returned: a <GtkAdjustment>, or #f.
the adjustment
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.
Passed: a <GtkListBox>.
Passed: a 32-bit integer.
the index of the row
Returned: a <GtkListBoxRow>, or #f.
the child <GtkWidget>
Gets the row at the y position.
Passed: a <GtkListBox>.
Passed: a 32-bit integer.
position
Returned: a <GtkListBoxRow>, or #f.
the row
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.
Passed: a <GtkListBox>.
Returned: a <GtkListBoxRow>, or #f.
the selected row
Creates a list of all selected children.
Passed: a <GtkListBox>.
Returned: a list, each a <GtkListBoxRow>.
A GList containing the <GtkWidget> for each
selected child. Free with g_list_free() when done.
Gets the selection mode of the listbox.
Passed: a <GtkListBox>.
Returned: a <GtkSelectionMode>.
Returns whether the list box should show separators between rows.
Passed: a <GtkListBox>.
Returned: a boolean.
#t if the list box shows separators
Returns the behavior of the Tab and Shift+Tab keys.
Passed: a <GtkListBox>.
Returned: a <GtkListTabBehavior>.
the tab behavior
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.
Passed: a <GtkListBox>.
Passed: a <GtkWidget>.
the <GtkWidget> to add
Passed: a 32-bit integer.
the position to insert child in
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.
Passed: a <GtkListBox>.
Update the separators for all rows.
Call this when result of the header function on the self is changed due to an external factor.
Passed: a <GtkListBox>.
Update the sorting for all rows.
Call this when result of the sort function on the self is changed due to an external factor.
Passed: a <GtkListBox>.
Creates a new <GtkListBox> container.
Returned: a <GtkWidget>.
a new <GtkListBox>
Prepend a widget to the list.
If a sort function is set, the widget will actually be inserted at the calculated position.
Passed: a <GtkListBox>.
Passed: a <GtkWidget>.
the <GtkWidget> to add
Removes a child from self.
Passed: a <GtkListBox>.
Passed: a <GtkWidget>.
the child to remove
Removes all rows from self.
This function does nothing if self is backed by a model.
Passed: a <GtkListBox>.
Select all children of self, if the selection mode allows it.
Passed: a <GtkListBox>.
Make row the currently selected row.
Passed: a <GtkListBox>.
Passed, or left out: a <GtkListBoxRow>, or
#f.
The row to select
Calls a function for each selected child.
Note that the selection cannot be modified from within this function.
Passed: a <GtkListBox>.
Passed: a procedure.
the function to call for each selected child
See GtkListBoxForeachFunc for how it is
called.
Not passed: guile-gi supplies it.
user data to pass to the function
If single is #t, rows will be activated when you click on
them, otherwise you need to double-click.
Passed: a <GtkListBox>.
Passed: a boolean.
a boolean
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.
Passed: a <GtkListBox>.
Passed, or left out: a <GtkAdjustment>, or
#f.
the adjustment
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).
Passed: a <GtkListBox>.
Passed, or left out: a procedure, or #f.
callback that lets you filter which rows to show
See GtkListBoxFilterFunc for how it is
called.
Not passed: guile-gi supplies it.
user data passed to filter-func
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
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.
Passed: a <GtkListBox>.
Passed, or left out: a procedure, or #f.
callback that lets you add row headers
See GtkListBoxUpdateHeaderFunc for
how it is called.
Not passed: guile-gi supplies it.
user data passed to update-header
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
Sets the placeholder widget that is shown in the list when it doesn’t display any visible children.
Passed: a <GtkListBox>.
Passed, or left out: a <GtkWidget>, or #f.
Sets how selection works in the listbox.
Passed: a <GtkListBox>.
Passed: a <GtkSelectionMode>, or one of its
symbols.
Sets whether the list box should show separators between rows.
Passed: a <GtkListBox>.
Passed: a boolean.
#t to show separators
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).
Passed: a <GtkListBox>.
Passed, or left out: a procedure, or #f.
the sort function
See GtkListBoxSortFunc for how it is
called.
Not passed: guile-gi supplies it.
user data passed to sort-func
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
Sets the behavior of the Tab and Shift+Tab keys.
Passed: a <GtkListBox>.
Passed: a <GtkListTabBehavior>, or one of
its symbols.
the tab behavior
Unselect all children of self, if the selection mode allows it.
Passed: a <GtkListBox>.
Unselects a single row of self, if the selection mode allows it.
Passed: a <GtkListBox>.
Passed: a <GtkListBoxRow>.
the row to unselect
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.
Passed: a <GtkListBox>.
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.
Passed: a <GtkListBox>.
Passed: a <GtkMovementStep>.
the granularity of the move, as a
<GtkMovementStep>
Passed: a 32-bit integer.
the number of step units to move
Passed: a boolean.
whether to extend the selection
Passed: a boolean.
whether to modify the selection
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.
Passed: a <GtkListBox>.
Passed: a <GtkListBoxRow>.
the activated row
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.
Passed: a <GtkListBox>.
Passed: a <GtkListBoxRow>, or #f.
the selected row
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.
Passed: a <GtkListBox>.
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.
Passed: a <GtkListBox>.
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+␣.
Passed: a <GtkListBox>.
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.
Passed: a <GtkListBox>.