Class TreeExpander

All Implemented Interfaces:
PointerInterface

public class TreeExpander extends Widget
`GtkTreeExpander` is a widget that provides an expander for a 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.

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.

# 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

`GtkTreeExpander` uses the %GTK_ACCESSIBLE_ROLE_GROUP role. The expander icon
is represented as a %GTK_ACCESSIBLE_ROLE_BUTTON, labelled by the expander's
child, and toggling it will change the %GTK_ACCESSIBLE_STATE_EXPANDED state.

https://docs.gtk.org/gtk4/class.TreeExpander.html

  • Constructor Details

    • TreeExpander

      public TreeExpander(PointerContainer pointer)
    • TreeExpander

      public TreeExpander()
      Creates a new `GtkTreeExpander`
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getChild

      public Widget getChild()
      Gets the child widget displayed by @self.
      Returns:
      The child displayed by @self
    • getIndentForIcon

      public boolean 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.
    • getItem

      public Pointer getItem()
      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));
      ```
      Returns:
      The item of the row
    • getListRow

      public TreeListRow getListRow()
      Gets the list row managed by @self.
      Returns:
      The list row displayed by @self
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the content widget to display.
      Parameters:
      child - a `GtkWidget`
    • setIndentForIcon

      public void setIndentForIcon(boolean indent_for_icon)
      Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
      Parameters:
      indent_for_icon - TRUE if the child should be indented without expander. Otherwise FALSE.
    • setListRow

      public void setListRow(@Nullable TreeListRow list_row)
      Sets the tree list row that this expander should manage.
      Parameters:
      list_row - a `GtkTreeListRow`
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()