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, gtk.list_box.ListBox.rowActivated 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 gtk.list_box.ListBox.showSeparators 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 _getGType() static nothrow
GType _gType() @property nothrow
ListBox self() nothrowReturns `this`, for use in `with` statements.
ListBoxGidBuilder builder() static nothrowGet builder for [gtk.list_box.ListBox] Returns: New builder object
bool acceptUnpairedRelease() @property nothrowGet `acceptUnpairedRelease` property. Returns: Whether to accept unpaired release events.
void acceptUnpairedRelease(bool propval) @property nothrowSet `acceptUnpairedRelease` property. Params: propval = Whether to accept unpaired release events.
bool activateOnSingleClick() @property nothrowGet `activateOnSingleClick` property. Returns: Determines whether children can be activated with a single click, or require a double-click.
void activateOnSingleClick(bool propval) @property nothrowSet `activateOnSingleClick` property. Params: propval = Determines whether children can be activated with a single click, or require a double-click.
gtk.types.SelectionMode selectionMode() @property nothrowGet `selectionMode` property. Returns: The selection mode used by the list box.
void selectionMode(gtk.types.SelectionMode propval) @property nothrowSet `selectionMode` property. Params: propval = The selection mode used by the list box.
bool showSeparators() @property nothrowGet `showSeparators` property. Returns: Whether to show separators between rows.
void showSeparators(bool propval) @property nothrowSet `showSeparators` property. Params: propval = Whether to show separators between rows.
void append(gtk.widget.Widget child) nothrowAppend a widget to the list.
void bindModel(gio.list_model.ListModel model = null, gtk.types.ListBoxCreateWidgetFunc createWidgetFunc = null) nothrowBinds model to box.
void dragHighlightRow(gtk.list_box_row.ListBoxRow row) nothrowAdd a drag highlight to a row.
void dragUnhighlightRow() nothrowIf a row has previously been highlighted via [gtk.list_box.ListBox.dragHighlightRow], it will have the highlight removed.
bool getActivateOnSingleClick() nothrowReturns whether rows activate on single clicks. Returns: true if rows are activated on single click, false otherwise
gtk.adjustment.Adjustment getAdjustment() nothrowGets the adjustment (if any) that the widget uses to for vertical scrolling. Returns: the adjustment
gtk.list_box_row.ListBoxRow getRowAtIndex(int index) nothrowGets the n-th child in the list (not counting headers).
gtk.list_box_row.ListBoxRow getRowAtY(int y) nothrowGets the row at the `y` position.
gtk.list_box_row.ListBoxRow getSelectedRow() nothrowGets the selected row, or null if no rows are selected.
gtk.list_box_row.ListBoxRow[] getSelectedRows() nothrowCreates 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() nothrowGets the selection mode of the listbox. Returns: a [gtk.types.SelectionMode]
bool getShowSeparators() nothrowReturns 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) nothrowInsert the child into the box at position.
void invalidateFilter() nothrowUpdate the filtering for all rows.
void invalidateHeaders() nothrowUpdate the separators for all rows.
void invalidateSort() nothrowUpdate the sorting for all rows.
void prepend(gtk.widget.Widget child) nothrowPrepend a widget to the list.
void remove(gtk.widget.Widget child) nothrowRemoves a child from box.
void removeAll() nothrowRemoves all rows from box.
void selectAll() nothrowSelect all children of box, if the selection mode allows it.
void selectRow(gtk.list_box_row.ListBoxRow row = null) nothrowMake row the currently selected row.
void selectedForeach(gtk.types.ListBoxForeachFunc func) nothrowCalls a function for each selected child.
void setActivateOnSingleClick(bool single) nothrowIf 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) nothrowSets the adjustment (if any) that the widget uses to for vertical scrolling.
void setFilterFunc(gtk.types.ListBoxFilterFunc filterFunc = null) nothrowBy setting a filter function on the box one can decide dynamically which of the rows to show.
void setHeaderFunc(gtk.types.ListBoxUpdateHeaderFunc updateHeader = null) nothrowSets a header function.
void setPlaceholder(gtk.widget.Widget placeholder = null) nothrowSets the placeholder widget that is shown in the list when it doesn't display any visible children.
void setSelectionMode(gtk.types.SelectionMode mode) nothrowSets how selection works in the listbox.
void setShowSeparators(bool showSeparators) nothrowSets whether the list box should show separators between rows.
void setSortFunc(gtk.types.ListBoxSortFunc sortFunc = null) nothrowSets a sort function.
void unselectAll() nothrowUnselect all children of box, if the selection mode allows it.
void unselectRow(gtk.list_box_row.ListBoxRow row) nothrowUnselects 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `UnselectAll` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.list_box.ListBox] container. Returns: a new [gtk.list_box.ListBox]

Fluent builder implementation template for gtk.list_box.ListBox

Methods
T acceptUnpairedRelease(bool propval) nothrowSet `acceptUnpairedRelease` property. Params: propval = Whether to accept unpaired release events. Returns: Builder instance for fluent chaining
T activateOnSingleClick(bool propval) nothrowSet `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) nothrowSet `selectionMode` property. Params: propval = The selection mode used by the list box. Returns: Builder instance for fluent chaining
T showSeparators(bool propval) nothrowSet `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() nothrowCreate object from builder. Returns: New object