Class TreeExpander
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
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
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
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 TreeListRow
items which can be set via
setListRow(org.gnome.gtk.TreeListRow)
on the expander.
The expander will then watch that row item automatically.
setChild(org.gnome.gtk.Widget)
sets the widget that displays
the actual row contents.
GtkTreeExpander
can be modified with properties such as
Gtk.TreeExpander:indent-for-icon
,
Gtk.TreeExpander:indent-for-depth
, and
Gtk.TreeExpander:hide-expander
to achieve a different appearance.
This can even be done to influence individual rows, for example by binding
the 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
orCtrl
+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 GTK_ACCESSIBLE_ROLE_GROUP
role.
Since GTK 4.12, GtkTreeExpander
uses the GTK_ACCESSIBLE_ROLE_BUTTON
role.
Toggling it will change the GTK_ACCESSIBLE_STATE_EXPANDED
state.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
TreeExpander.Builder<B extends TreeExpander.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
-
Constructor Summary
ConstructorDescriptionCreates a newGtkTreeExpander
TreeExpander
(MemorySegment address) Create a TreeExpander proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected TreeExpander
asParent()
Returns this instance as if it were its parent type.static TreeExpander.Builder
<? extends TreeExpander.Builder> builder()
ATreeExpander.Builder
object constructs aTreeExpander
with the specified properties.getChild()
Gets the child widget displayed by this TreeExpander.boolean
Gets whether the TreeExpander should be hidden in a GtkTreeListRow.boolean
TreeExpander indents each level of depth with an additional indent.boolean
TreeExpander indents the child by the width of an expander-icon if it is not expandable.getItem()
Forwards the item set on theGtkTreeListRow
that this TreeExpander is managing.Gets the list row managed by this TreeExpander.static Type
getType()
Get the GType of the TreeExpander classvoid
Sets the content widget to display.void
setHideExpander
(boolean hideExpander) Sets whether the expander icon should be visible in a GtkTreeListRow.void
setIndentForDepth
(boolean indentForDepth) Sets if the TreeExpander should indent the child according to its depth.void
setIndentForIcon
(boolean indentForIcon) Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.void
setListRow
(@Nullable TreeListRow listRow) Sets the tree list row that this expander should manage.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
TreeExpander
Create a TreeExpander proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
TreeExpander
public TreeExpander()Creates a newGtkTreeExpander
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getChild
Gets the child widget displayed by this TreeExpander.- Returns:
- The child displayed by this TreeExpander
-
getHideExpander
public boolean getHideExpander()Gets whether the TreeExpander should be hidden in a GtkTreeListRow.- Returns:
- TRUE if the expander icon should be hidden. Otherwise FALSE.
-
getIndentForDepth
public boolean getIndentForDepth()TreeExpander indents each level of depth with an additional indent.- Returns:
- TRUE if the child should be indented . Otherwise FALSE.
-
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
Forwards the item set on theGtkTreeListRow
that this TreeExpander is managing.This call is essentially equivalent to calling:
gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));
- Returns:
- The item of the row
-
getListRow
Gets the list row managed by this TreeExpander.- Returns:
- The list row displayed by this TreeExpander
-
setChild
Sets the content widget to display.- Parameters:
child
- aGtkWidget
-
setHideExpander
public void setHideExpander(boolean hideExpander) Sets whether the expander icon should be visible in a GtkTreeListRow.- Parameters:
hideExpander
- TRUE if the expander should be hidden. Otherwise FALSE.
-
setIndentForDepth
public void setIndentForDepth(boolean indentForDepth) Sets if the TreeExpander should indent the child according to its depth.- Parameters:
indentForDepth
- TRUE if the child should be indented. Otherwise FALSE.
-
setIndentForIcon
public void setIndentForIcon(boolean indentForIcon) Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.- Parameters:
indentForIcon
- TRUE if the child should be indented without expander. Otherwise FALSE.
-
setListRow
Sets the tree list row that this expander should manage.- Parameters:
listRow
- aGtkTreeListRow
-
builder
ATreeExpander.Builder
object constructs aTreeExpander
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withTreeExpander.Builder.build()
.
-