gtk.list_box
Module for [ListBox] class
Types 3
A GtkListBox is a vertical container that contains GtkListBoxRow children. These rows can be 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 [gtk.container.Container.add], 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, #GtkListBox::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 widget was added in GTK+ 3.10.
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 [gtk.list_box.ListBox.setPlaceholder] for info.
CSS nodes
list
╰── row[.activatable]GtkListBox uses a single CSS node named list. Each GtkListBoxRow uses a single CSS node named row. The row nodes get the .activatable style class added when appropriate.
ListBoxGidBuilder builder()Get builder for [gtk.list_box.ListBox] Returns: New builder objectbool activateOnSingleClick() @propertyvoid activateOnSingleClick(bool propval) @propertygtk.types.SelectionMode selectionMode() @propertyvoid selectionMode(gtk.types.SelectionMode propval) @propertyvoid bindModel(gio.list_model.ListModel model = null, gtk.types.ListBoxCreateWidgetFunc createWidgetFunc = null)Binds model to box.void dragHighlightRow(gtk.list_box_row.ListBoxRow row)This is a helper function for implementing DnD onto a #GtkListBox. The passed in row will be highlighted via [gtk.widget.Widget.dragHighlight], and any previously highlighted row will be unhighligh...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 otherwisegtk.adjustment.Adjustment getAdjustment()Gets the adjustment (if any) that the widget uses to for vertical scrolling. Returns: the adjustmentgtk.list_box_row.ListBoxRow getRowAtIndex(int index)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, null is returned.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.gtk.list_box_row.ListBoxRow[] getSelectedRows()Creates a list of all selected children. Returns: A #GList containing the #GtkWidget 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 #GtkSelectionModevoid insert(gtk.widget.Widget child, int position)Insert the child into the box at position. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of [gtk.container.Contain...void invalidateFilter()Update the filtering for all rows. Call this when result of the filter function on the box is changed due to an external factor. For instance, this would be used if the filter function just looked ...void invalidateHeaders()Update the separators for all rows. Call this when result of the header function on the box is changed due to an external factor.void invalidateSort()Update the sorting for all rows. Call this when result of the sort function on the box is changed due to an external factor.void prepend(gtk.widget.Widget child)Prepend a widget to the list. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of [gtk.container.Container.add].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. For instance, this is used to get the page size for PageUp/Down key handling.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. For instance, to implement a search function on a list that filters the original list to only show the ...void setHeaderFunc(gtk.types.ListBoxUpdateHeaderFunc updateHeader = null)By setting a header function on the box 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 he...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. See #GtkSelectionMode for details.void setSortFunc(gtk.types.ListBoxSortFunc sortFunc = null)By setting a sort function on the box one can dynamically reorder the rows of the list, based on the contents of the rows.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] : gtk.list_box.ListBox)))
&& Parameters!T.length < 4)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.