Gnome::Gtk4::TreeExpander
Description
Gnome::Gtk4::TreeExpander is a widget that provides an expander for a list.
It is typically placed as a bottommost child into a Gnome::Gtk4::ListView to allow users to expand and collapse children in a list with a Gnome::Gtk4::TreeListModel. Gnome::Gtk4::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 focusable defined in Gnome::Gtk4::ListItem 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 Gnome::Gtk4::TreeListModel must be set to not be passthrough. Then it will provide Gnome::Gtk4::TreeListRow items which can be set via .set-list-row()
on the expander. The expander will then watch that row item automatically. .set-child()
sets the widget that displays the actual row contents.
Gnome::Gtk4::TreeExpander can be modified with properties such as indent-for-icon, indent-for-depth, and hide-expander 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
Gnome::Gtk4::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, Gnome::Gtk4::TreeExpander used the GTK_ACCESSIBLE_ROLE_GROUP role.
Since GTK 4.12, Gnome::Gtk4::TreeExpander uses the GTK_ACCESSIBLE_ROLE_BUTTON role. Toggling it will change the GTK_ACCESSIBLE_STATE_EXPANDED state.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-treeexpander
Creates a new Gnome::Gtk4::TreeExpander
method new-treeexpander ( --> Gnome::Gtk4::TreeExpander \)
Methods
get-child
Gets the child widget displayed by $self
.
method get-child (--> N-Object )
Return value; The child displayed by $self
.
get-hide-expander
Gets whether the TreeExpander should be hidden in a GtkTreeListRow.
method get-hide-expander (--> Bool )
Return value; TRUE if the expander icon should be hidden. Otherwise FALSE..
get-indent-for-depth
TreeExpander indents each level of depth with an additional indent.
method get-indent-for-depth (--> Bool )
Return value; TRUE if the child should be indented . Otherwise FALSE..
get-indent-for-icon
TreeExpander indents the child by the width of an expander-icon if it is not expandable.
method get-indent-for-icon (--> Bool )
Return value; TRUE if the child should be indented when not expandable. Otherwise FALSE..
get-item
Forwards the item set on the Gnome::Gtk4::TreeListRow that $self
is managing.
This call is essentially equivalent to calling:
method get-item (--> gpointer )
Return value; The item of the row.
get-list-row
Gets the list row managed by $self
.
method get-list-row (--> N-Object )
Return value; The list row displayed by $self
.
set-child
Sets the content widget to display.
method set-child ( N-Object() $child )
$child; a Gnome::Gtk4::Widget.
set-hide-expander
Sets whether the expander icon should be visible in a GtkTreeListRow.
method set-hide-expander ( Bool() $hide-expander )
$hide-expander; TRUE if the expander should be hidden. Otherwise FALSE..
set-indent-for-depth
Sets if the TreeExpander should indent the child according to its depth.
method set-indent-for-depth ( Bool() $indent-for-depth )
$indent-for-depth; TRUE if the child should be indented. Otherwise FALSE..
set-indent-for-icon
Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
method set-indent-for-icon ( Bool() $indent-for-icon )
$indent-for-icon; TRUE if the child should be indented without expander. Otherwise FALSE..
set-list-row
Sets the tree list row that this expander should manage.
method set-list-row ( N-Object() $list-row )
$list-row; a Gnome::Gtk4::TreeListRow.