Basics
Guides
API Reference
Basics
Guides
API Reference
[51:7] extends: object
Provides an expander for a tree-like list. It is typically placed as a
bottommost child into a GtkListView to allow users to expand and collapse
children in a list with a [class@Gtk.TreeListModel]. GtkTreeExpander
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
[property@Gtk.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 GtkTreeListModel must be set to
not be passthrough. Then it will provide [class@Gtk.TreeListRow] items which
can be set via [method@Gtk.TreeExpander.set_list_row] on the expander. The
expander will then watch that row item automatically.
[method@Gtk.TreeExpander.set_child] sets the widget that displays the actual
row contents. GtkTreeExpander 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. ## Shortcuts and Gestures GtkTreeExpander
supports the following keyboard shortcuts: - + or *
expands the expander. - - or / collapses the expander.
GtkTreeExpander
defines a set of built-in actions: - listitem.expand expands the expander
if it can be expanded. - listitem.collapse collapses the expander. -
listitem.toggle-expand tries to expand the expander if it was collapsed or
collapses it if it was expanded. ## CSS nodes treeexpander ├── [indent]* ├── [expander] ╰── <child> GtkTreeExpander 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, GtkTreeExpander used
the [enum@Gtk.AccessibleRole.group] role. Since GTK 4.12, GtkTreeExpander
uses the [enum@Gtk.AccessibleRole.button] role. Toggling it will change the
GTK_ACCESSIBLE_STATE_EXPANDED state.TreeExpander ()
Creates a new
GtkTreeExpander
toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asWidget ()
Wraps this handle as
Widget.
A Widget object.asAccessible ()
Wraps this handle as
Accessible.
A Accessible object.asBuildable ()
Wraps this handle as
Buildable.
A Buildable object.asConstraintTarget ()
Wraps this handle as
ConstraintTarget.
A ConstraintTarget object.getProperty (string Name)
Reads one generated property by name.
setProperty (string Name, Value)
Writes one generated property by name.
setChild (object Value)
The child widget with the actual contents.
Value is the new property value.None.setHideexpander (bool Value)
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 expand) are not affected by this property. A common use for this property would be to bind to the number of children in a GtkTreeListRow's model in order to hide the expander when a row has no children.
Value is the new property value.None.setIndentfordepth (bool Value)
TreeExpander indents the child according to its depth.
Value is the new property value.None.setIndentforicon (bool Value)
TreeExpander indents the child by the width of an expander-icon if it is not expandable.
Value is the new property value.None.setListrow (object Value)
The list row to track for expander state.
Value is the new property value.None.get_child ()
Gets the child widget displayed by @self.
get_hide_expander ()
Gets whether the TreeExpander should be hidden in a GtkTreeListRow.
get_indent_for_depth ()
TreeExpander indents each level of depth with an additional indent.
get_indent_for_icon ()
TreeExpander indents the child by the width of an expander-icon if it is not expandable.
get_item ()
Forwards the item set on the
GtkTreeListRowthat @self is managing. This call is essentially equivalent to calling:c gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));
get_list_row ()
Gets the list row managed by @self.
set_child (object child)
Sets the content widget to display.
child is a GtkWidget.None.set_hide_expander (bool hide_expander)
Sets whether the expander icon should be visible in a GtkTreeListRow.
hide_expander is TRUE if the expander should be hidden. Otherwise FALSE..None.set_indent_for_depth (bool indent_for_depth)
Sets if the TreeExpander should indent the child according to its depth.
indent_for_depth is TRUE if the child should be indented. Otherwise FALSE..None.set_indent_for_icon (bool indent_for_icon)
Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
indent_for_icon is TRUE if the child should be indented without expander. Otherwise FALSE..None.set_list_row (object list_row)
Sets the tree list row that this expander should manage.
list_row is a GtkTreeListRow.None.[365:14] static extends: object
Generated metadata helpers for TreeExpander class surfaces.
properties ()
Returns property metadata for
TreeExpander.
A list.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.