gtk.list_box

Module for [ListBox] class

Types 3

classListBox : gtk.widget.Widget

[gtk.list_box.ListBox] is a vertical list.

A [gtk.list_box.ListBox] only contains [gtk.list_box_row.ListBoxRow] 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 [gtk.list_box.ListBox] is often an alternative to [gtk.tree_view.TreeView], especially when the list contents has a more complicated layout than what is allowed by a [gtk.cell_renderer.CellRenderer], or when the contents is interactive (i.e. has a button in it).

Although a [gtk.list_box.ListBox] must have only [gtk.list_box_row.ListBoxRow] children, you can add any kind of widget to it via [gtk.list_box.ListBox.prepend], [gtk.list_box.ListBox.append] and [gtk.list_box.ListBox.insert] and a [gtk.list_box_row.ListBoxRow] widget will automatically be inserted between the list and the widget.

GtkListBoxRows can be marked as activatable or selectable. If a row is activatable, signal@Gtk.ListBox::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 [gtk.list_box.ListBox] implementation of the [gtk.buildable.Buildable] interface supports setting a child as the placeholder by specifying “placeholder” as the “type” attribute of a <child> element. See [gtk.list_box.ListBox.setPlaceholder] for info.

CSS nodes

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

[gtk.list_box.ListBox] uses a single CSS node named list. It may carry the .separators style class, when the property@Gtk.ListBox:show-separators property is set. Each [gtk.list_box_row.ListBoxRow] 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

[gtk.list_box.ListBox] uses the [gtk.types.AccessibleRole.List] role and [gtk.list_box_row.ListBoxRow] uses the [gtk.types.AccessibleRole.ListItem] role.

Methods
GType _gType() @property
ListBox self()Returns `this`, for use in `with` statements.
ListBoxGidBuilder builder()Get builder for [gtk.list_box.ListBox] Returns: New builder object
bool acceptUnpairedRelease() @propertyGet `acceptUnpairedRelease` property. Returns: Whether to accept unpaired release events.
void acceptUnpairedRelease(bool propval) @propertySet `acceptUnpairedRelease` property. Params: propval = Whether to accept unpaired release events.
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.
gtk.types.SelectionMode selectionMode() @propertyGet `selectionMode` property. Returns: The selection mode used by the list box.
void selectionMode(gtk.types.SelectionMode propval) @propertySet `selectionMode` property. Params: propval = The selection mode used by the list box.
bool showSeparators() @propertyGet `showSeparators` property. Returns: Whether to show separators between rows.
void showSeparators(bool propval) @propertySet `showSeparators` property. Params: propval = Whether to show separators between rows.
void append(gtk.widget.Widget child)Append a widget to the list.
void bindModel(gio.list_model.ListModel model = null, gtk.types.ListBoxCreateWidgetFunc createWidgetFunc = null)Binds model to box.
void dragHighlightRow(gtk.list_box_row.ListBoxRow row)Add a drag highlight to a row.
void dragUnhighlightRow()If a row has previously been highlighted via [gtk.list_box.ListBox.dragHighlightRow], it will have the highlight removed.
bool getActivateOnSingleClick()Returns whether rows activate on single clicks. Returns: true if rows are activated on single click, false otherwise
gtk.adjustment.Adjustment getAdjustment()Gets the adjustment (if any) that the widget uses to for vertical scrolling. Returns: the adjustment
gtk.list_box_row.ListBoxRow getRowAtIndex(int index)Gets the n-th child in the list (not counting headers).
gtk.list_box_row.ListBoxRow getRowAtY(int y)Gets the row at the `y` position.
gtk.list_box_row.ListBoxRow getSelectedRow()Gets the selected row, or null if no rows are selected.
gtk.list_box_row.ListBoxRow[] getSelectedRows()Creates a list of all selected children. Returns: A [glib.list.List] containing the [gtk.widget.Widget] for each selected child. Free with [glib.list.List.free] when done.
gtk.types.SelectionMode getSelectionMode()Gets the selection mode of the listbox. Returns: a [gtk.types.SelectionMode]
bool getShowSeparators()Returns whether the list box should show separators between rows. Returns: true if the list box shows separators
void insert(gtk.widget.Widget child, int position)Insert the child into the box at position.
void invalidateFilter()Update the filtering for all rows.
void invalidateHeaders()Update the separators for all rows.
void invalidateSort()Update the sorting for all rows.
void prepend(gtk.widget.Widget child)Prepend a widget to the list.
void remove(gtk.widget.Widget child)Removes a child from box.
void removeAll()Removes all rows from box.
void selectAll()Select all children of box, if the selection mode allows it.
void selectRow(gtk.list_box_row.ListBoxRow row = null)Make row the currently selected row.
void selectedForeach(gtk.types.ListBoxForeachFunc func)Calls a function for each selected child.
void setActivateOnSingleClick(bool single)If single is true, rows will be activated when you click on them, otherwise you need to double-click.
void setAdjustment(gtk.adjustment.Adjustment adjustment = null)Sets the adjustment (if any) that the widget uses to for vertical scrolling.
void setFilterFunc(gtk.types.ListBoxFilterFunc filterFunc = null)By setting a filter function on the box one can decide dynamically which of the rows to show.
void setHeaderFunc(gtk.types.ListBoxUpdateHeaderFunc updateHeader = null)Sets a header function.
void setPlaceholder(gtk.widget.Widget placeholder = null)Sets the placeholder widget that is shown in the list when it doesn't display any visible children.
void setSelectionMode(gtk.types.SelectionMode mode)Sets how selection works in the listbox.
void setShowSeparators(bool showSeparators)Sets whether the list box should show separators between rows.
void setSortFunc(gtk.types.ListBoxSortFunc sortFunc = null)Sets a sort function.
void unselectAll()Unselect all children of box, if the selection mode allows it.
void unselectRow(gtk.list_box_row.ListBoxRow row)Unselects a single row of box, if the selection mode allows it.
gulong connectActivateCursorRow(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.list_box.ListBox))) && Parameters!T.length < 2)Connect to `ActivateCursorRow` signal.
gulong connectMoveCursor(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.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] == bool))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] == bool))) && (Parameters!T.length < 5 || (ParameterStorageClassTuple!T[4] == ParameterStorageClass.none && is(Parameters!T[4] : gtk.list_box.ListBox))) && Parameters!T.length < 6)Connect to `MoveCursor` signal.
gulong connectRowActivated(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.list_box_row.ListBoxRow))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.list_box.ListBox))) && Parameters!T.length < 3)Connect to `RowActivated` signal.
gulong connectRowSelected(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.list_box_row.ListBoxRow))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.list_box.ListBox))) && Parameters!T.length < 3)Connect to `RowSelected` 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.list_box.ListBox))) && Parameters!T.length < 2)Connect to `SelectAll` signal.
gulong connectSelectedRowsChanged(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.list_box.ListBox))) && Parameters!T.length < 2)Connect to `SelectedRowsChanged` signal.
gulong connectToggleCursorRow(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.list_box.ListBox))) && Parameters!T.length < 2)Connect to `ToggleCursorRow` 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.list_box.ListBox))) && Parameters!T.length < 2)Connect to `UnselectAll` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.listbox.ListBox] container. Returns: a new [gtk.listbox.ListBox]
Methods
T acceptUnpairedRelease(bool propval)Set `acceptUnpairedRelease` property. Params: propval = Whether to accept unpaired release events. Returns: Builder instance for fluent chaining
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 selectionMode(gtk.types.SelectionMode propval)Set `selectionMode` property. Params: propval = The selection mode used by the list box. Returns: Builder instance for fluent chaining
T showSeparators(bool propval)Set `showSeparators` property. Params: propval = Whether to show separators between rows. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.list_box.ListBox]

Methods
ListBox build()