Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: TreeExpander

[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.

  • Left and right arrow keys, when combined with Shift or Ctrl+Shift, will expand or collapse, depending on the locale's text direction. - Ctrl+ toggles the expander state. The row can also expand on drag gestures. ## Actions 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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • 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 exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r 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.

    • @p Value is the new property value.
    • @r 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.

    • @p Value is the new property value.
    • @r None.
  • setIndentfordepth (bool Value)

    TreeExpander indents the child according to its depth.

    • @p Value is the new property value.
    • @r None.
  • setIndentforicon (bool Value)

    TreeExpander indents the child by the width of an expander-icon if it is not expandable.

    • @p Value is the new property value.
    • @r None.
  • setListrow (object Value)

    The list row to track for expander state.

    • @p Value is the new property value.
    • @r 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 GtkTreeListRow that @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.

    • @p child is a GtkWidget.
    • @r None.
  • set_hide_expander (bool hide_expander)

    Sets whether the expander icon should be visible in a GtkTreeListRow.

    • @p hide_expander is TRUE if the expander should be hidden. Otherwise FALSE..
    • @r None.
  • set_indent_for_depth (bool indent_for_depth)

    Sets if the TreeExpander should indent the child according to its depth.

    • @p indent_for_depth is TRUE if the child should be indented. Otherwise FALSE..
    • @r 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.

    • @p indent_for_icon is TRUE if the child should be indented without expander. Otherwise FALSE..
    • @r None.
  • set_list_row (object list_row)

    Sets the tree list row that this expander should manage.

    • @p list_row is a GtkTreeListRow.
    • @r None.

class: TreeExpanderMeta

[365:14] static extends: object

Generated metadata helpers for TreeExpander class surfaces.

Methods

  • properties ()

    Returns property metadata for TreeExpander.

    • @r A list.