gtk.tree_expander

Module for [TreeExpander] class

Types 3

gtk.tree_expander.TreeExpander is a widget that provides an expander for a list.

It is typically placed as a bottommost child into a gtk.list_view.ListView to allow users to expand and collapse children in a list with a gtk.tree_list_model.TreeListModel. gtk.tree_expander.TreeExpander provides the common UI elements, gestures and keybindings for this purpose.

On top of this, the "listitem.expand", "listitem.collapse" and "listitem.toggle-expand" actions are provided to allow adding custom UI for managing expanded state.

It is important to mention that you want to set the gtk.list_item.ListItem.focusable property to FALSE when using this widget, as you want the keyboard focus to be in the treexpander, and not inside the list to make use of the keybindings.

The gtk.tree_list_model.TreeListModel must be set to not be passthrough. Then it will provide gtk.tree_list_row.TreeListRow items which can be set via gtk.tree_expander.TreeExpander.setListRow on the expander. The expander will then watch that row item automatically. gtk.tree_expander.TreeExpander.setChild sets the widget that displays the actual row contents.

gtk.tree_expander.TreeExpander can be modified with properties such as gtk.tree_expander.TreeExpander.indentForIcon, gtk.tree_expander.TreeExpander.indentForDepth, and gtk.tree_expander.TreeExpander.hideExpander to achieve a different appearance. This can even be done to influence individual rows, for example by binding the gtk.tree_expander.TreeExpander.hideExpander property to the item count of the model of the treelistrow, to hide the expander for rows without children, even if the row is expandable.

CSS nodes

treeexpander
├── [indent]*
├── [expander]
╰── <child>

gtk.tree_expander.TreeExpander has zero or one CSS nodes with the name "expander" that should display the expander icon. The node will be :checked when it is expanded. If the node is not expandable, an "indent" node will be displayed instead.

For every level of depth, another "indent" node is prepended.

Accessibility

Until GTK 4.10, gtk.tree_expander.TreeExpander used the gtk.types.AccessibleRole.Group role.

Since GTK 4.12, gtk.tree_expander.TreeExpander uses the gtk.types.AccessibleRole.Button role. Toggling it will change the gtk.types.AccessibleState.Expanded state.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
TreeExpander self() nothrowReturns `this`, for use in `with` statements.
TreeExpanderGidBuilder builder() static nothrowGet builder for [gtk.tree_expander.TreeExpander] Returns: New builder object
gtk.widget.Widget child() @property nothrowGet `child` property. Returns: The child widget with the actual contents.
void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget with the actual contents.
bool hideExpander() @property nothrowGet `hideExpander` property. Returns: Whether the expander icon should be hidden in a GtkTreeListRow. Note that this property simply hides the icon. The actions and keybinding (i.e. collapse and e...
void hideExpander(bool propval) @property nothrowSet `hideExpander` property. Params: propval = Whether the expander icon should be hidden in a GtkTreeListRow. Note that this property simply hides the icon. The actions and keybinding (i.e. colla...
bool indentForDepth() @property nothrowGet `indentForDepth` property. Returns: TreeExpander indents the child according to its depth.
void indentForDepth(bool propval) @property nothrowSet `indentForDepth` property. Params: propval = TreeExpander indents the child according to its depth.
bool indentForIcon() @property nothrowGet `indentForIcon` property. Returns: TreeExpander indents the child by the width of an expander-icon if it is not expandable.
void indentForIcon(bool propval) @property nothrowSet `indentForIcon` property. Params: propval = TreeExpander indents the child by the width of an expander-icon if it is not expandable.
gobject.object.ObjectWrap item() @property nothrowGet `item` property. Returns: The item held by this expander's row.
gtk.tree_list_row.TreeListRow listRow() @property nothrowGet `listRow` property. Returns: The list row to track for expander state.
void listRow(gtk.tree_list_row.TreeListRow propval) @property nothrowSet `listRow` property. Params: propval = The list row to track for expander state.
gtk.widget.Widget getChild() nothrowGets the child widget displayed by self. Returns: The child displayed by self
bool getHideExpander() nothrowGets whether the TreeExpander should be hidden in a GtkTreeListRow. Returns: TRUE if the expander icon should be hidden. Otherwise FALSE.
bool getIndentForDepth() nothrowTreeExpander indents each level of depth with an additional indent. Returns: TRUE if the child should be indented . Otherwise FALSE.
bool getIndentForIcon() nothrowTreeExpander indents the child by the width of an expander-icon if it is not expandable. Returns: TRUE if the child should be indented when not expandable. Otherwise FALSE.
gobject.object.ObjectWrap getItem() nothrowForwards the item set on the [gtk.tree_list_row.TreeListRow] that self is managing.
gtk.tree_list_row.TreeListRow getListRow() nothrowGets the list row managed by self. Returns: The list row displayed by self
void setChild(gtk.widget.Widget child = null) nothrowSets the content widget to display.
void setHideExpander(bool hideExpander) nothrowSets whether the expander icon should be visible in a GtkTreeListRow.
void setIndentForDepth(bool indentForDepth) nothrowSets if the TreeExpander should indent the child according to its depth.
void setIndentForIcon(bool indentForIcon) nothrowSets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
void setListRow(gtk.tree_list_row.TreeListRow listRow = null) nothrowSets the tree list row that this expander should manage.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.tree_expander.TreeExpander] Returns: a new [gtk.tree_expander.TreeExpander]

Fluent builder implementation template for gtk.tree_expander.TreeExpander

Methods
T child(gtk.widget.Widget propval) nothrowSet `child` property. Params: propval = The child widget with the actual contents. Returns: Builder instance for fluent chaining
T hideExpander(bool propval) nothrowSet `hideExpander` property. Params: propval = Whether the expander icon should be hidden in a GtkTreeListRow. Note that this property simply hides the icon. The actions and keybinding (i.e. colla...
T indentForDepth(bool propval) nothrowSet `indentForDepth` property. Params: propval = TreeExpander indents the child according to its depth. Returns: Builder instance for fluent chaining
T indentForIcon(bool propval) nothrowSet `indentForIcon` property. Params: propval = TreeExpander indents the child by the width of an expander-icon if it is not expandable. Returns: Builder instance for fluent chaining
T listRow(gtk.tree_list_row.TreeListRow propval) nothrowSet `listRow` property. Params: propval = The list row to track for expander state. Returns: Builder instance for fluent chaining
Methods
TreeExpander build() nothrowCreate object from builder. Returns: New object