Package: gtk

Class gtk:tree-expander

Superclasses

Documented Subclasses

None

Direct Slots

child
The child property of type gtk:widget (Read / Write)
The child widget with the actual contents.
hide-expander
The hide-expander property of type :boolean (Read / Write)
Whether the expander icon should be hidden in a gtk:tree-list-row object. Note that this property simply hides the icon. The actions and keybinding, that is, collapse and expand, are not affected by this property. A common use for this property would be to bind to the number of children in the model of a gtk:tree-list-row object, to hide the expander when a row has no children. Since 4.10
Default value: false
indent-for-depth
The indent-for-depth property of type :boolean (Read / Write)
The tree expander indents the child according to its depth. Since 4.10
Default value: true
indent-for-icon
The indent-for-icon property of type :boolean (Read / Write)
The tree expander indents the child by the width of an expander-icon if it is not expandable. Since 4.6
Default value: true
item
The item property of type g:object (Read)
The item held by this expander’s row.
list-row
The list-row property of type gtk:tree-list-row (Read / Write)
The list row to track for expander state.

Details

The gtk:tree-expander widget is a widget that provides an expander for a list. It is typically placed as a bottommost child into a gtk:list-view widget to allow users to expand and collapse children in a list with a gtk:tree-list-model object. The gtk:tree-expander widget 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 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 object must be set to not be passthrough. Then it will provide gtk:tree-list-row items which can be set via the gtk:tree-expander-list-row function on the expander. The expander will then watch that row item automatically. The gtk:tree-expander-child function sets the widget that displays the actual row contents.

The gtk:tree-expander widget can be modified with properties such as indent-for-icon, indent-for-depth, and hide-expander properties to achieve a different appearance. This can even be done to influence individual rows, for example by binding the 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

The gtk:tree-expander implementation 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, the gtk:tree-expander implementation used the :group role. Since GTK 4.12, the gtk:tree-expander implementation uses the :button role of the gtk:accessible-role enumeration. Toggling it will change the :expanded value of the gtk:accessible-state enumeration.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

#2023-9-10