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 property@Gtk.TreeExpander:indent-for-icon, property@Gtk.TreeExpander:indent-for-depth, and property@Gtk.TreeExpander:hide-expander to achieve a different appearance. This can even be done to influence individual rows, for example by binding the property@Gtk.TreeExpander:hide-expander 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 _gType() @property
TreeExpander self()Returns `this`, for use in `with` statements.
TreeExpanderGidBuilder builder()Get builder for [gtk.tree_expander.TreeExpander] Returns: New builder object
gtk.widget.Widget child() @propertyGet `child` property. Returns: The child widget with the actual contents.
void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget with the actual contents.
bool hideExpander() @propertyGet `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) @propertySet `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() @propertyGet `indentForDepth` property. Returns: TreeExpander indents the child according to its depth.
void indentForDepth(bool propval) @propertySet `indentForDepth` property. Params: propval = TreeExpander indents the child according to its depth.
bool indentForIcon() @propertyGet `indentForIcon` property. Returns: TreeExpander indents the child by the width of an expander-icon if it is not expandable.
void indentForIcon(bool propval) @propertySet `indentForIcon` property. Params: propval = TreeExpander indents the child by the width of an expander-icon if it is not expandable.
gobject.object.ObjectWrap item() @propertyGet `item` property. Returns: The item held by this expander's row.
gtk.tree_list_row.TreeListRow listRow() @propertyGet `listRow` property. Returns: The list row to track for expander state.
void listRow(gtk.tree_list_row.TreeListRow propval) @propertySet `listRow` property. Params: propval = The list row to track for expander state.
gtk.widget.Widget getChild()Gets the child widget displayed by self. Returns: The child displayed by self
bool getHideExpander()Gets whether the TreeExpander should be hidden in a GtkTreeListRow. Returns: TRUE if the expander icon should be hidden. Otherwise FALSE.
bool getIndentForDepth()TreeExpander indents each level of depth with an additional indent. Returns: TRUE if the child should be indented . Otherwise FALSE.
bool getIndentForIcon()TreeExpander 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()Forwards the item set on the [gtk.treelistrow.TreeListRow] that self is managing.
gtk.tree_list_row.TreeListRow getListRow()Gets the list row managed by self. Returns: The list row displayed by self
void setChild(gtk.widget.Widget child = null)Sets the content widget to display.
void setHideExpander(bool hideExpander)Sets whether the expander icon should be visible in a GtkTreeListRow.
void setIndentForDepth(bool indentForDepth)Sets if the TreeExpander should indent the child according to its depth.
void setIndentForIcon(bool indentForIcon)Sets 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)Sets the tree list row that this expander should manage.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.treeexpander.TreeExpander] Returns: a new [gtk.treeexpander.TreeExpander]
Methods
T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget with the actual contents. Returns: Builder instance for fluent chaining
T hideExpander(bool propval)Set `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)Set `indentForDepth` property. Params: propval = TreeExpander indents the child according to its depth. Returns: Builder instance for fluent chaining
T indentForIcon(bool propval)Set `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)Set `listRow` property. Params: propval = The list row to track for expander state. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.tree_expander.TreeExpander]