gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.TreeExpander

Contents

- Exported types
- Methods
  - getChild
  - getHideExpander
  - getIndentForDepth
  - getIndentForIcon
  - getItem
  - getListRow
  - new
  - setChild
  - setHideExpander
  - setIndentForDepth
  - setIndentForIcon
  - setListRow
- Properties
  - child
  - hideExpander
  - indentForDepth
  - indentForIcon
  - item
  - listRow

Description

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 `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 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 `treeExpanderSetListRow` on the expander. The expander will then watch that row item automatically. `treeExpanderSetChild` sets the widget that displays the actual row contents.

`GtkTreeExpander` can be modified with properties such as TreeExpander:indentForIcon, TreeExpander:indentForDepth, and TreeExpander:hideExpander to achieve a different appearance. This can even be done to influence individual rows, for example by binding the TreeExpander:hideExpander 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:

- <kbd>+</kbd> or <kbd>*</kbd> expands the expander.
- <kbd>-</kbd> or <kbd>/</kbd> collapses the expander.
- Left and right arrow keys, when combined with <kbd>Shift</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>, will expand or collapse, depending on the locale's text direction.
- <kbd>Ctrl</kbd>+<kbd>␣</kbd> 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 `AccessibleRoleGroup` role.

Since GTK 4.12, `GtkTreeExpander` uses the `AccessibleRoleButton` role. Toggling it will change the `GTK_ACCESSIBLE_STATE_EXPANDED` state.

Synopsis

- newtype TreeExpander = TreeExpander (ManagedPtr TreeExpander)
- class (GObject o, IsDescendantOf TreeExpander o) => IsTreeExpander o
- toTreeExpander :: (MonadIO m, IsTreeExpander o) => o -> m TreeExpander
- treeExpanderGetChild :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m (Maybe Widget)
- treeExpanderGetHideExpander :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m Bool
- treeExpanderGetIndentForDepth :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m Bool
- treeExpanderGetIndentForIcon :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m Bool
- treeExpanderGetItem :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m (Maybe Object)
- treeExpanderGetListRow :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> m (Maybe TreeListRow)
- treeExpanderNew :: (HasCallStack, MonadIO m) => m TreeExpander
- treeExpanderSetChild :: (HasCallStack, MonadIO m, IsTreeExpander a, IsWidget b) => a -> Maybe b -> m ()
- treeExpanderSetHideExpander :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> Bool -> m ()
- treeExpanderSetIndentForDepth :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> Bool -> m ()
- treeExpanderSetIndentForIcon :: (HasCallStack, MonadIO m, IsTreeExpander a) => a -> Bool -> m ()
- treeExpanderSetListRow :: (HasCallStack, MonadIO m, IsTreeExpander a, IsTreeListRow b) => a -> Maybe b -> m ()
- clearTreeExpanderChild :: (MonadIO m, IsTreeExpander o) => o -> m ()
- constructTreeExpanderChild :: (IsTreeExpander o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getTreeExpanderChild :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe Widget)
- setTreeExpanderChild :: (MonadIO m, IsTreeExpander o, IsWidget a) => o -> a -> m ()
- constructTreeExpanderHideExpander :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o)
- getTreeExpanderHideExpander :: (MonadIO m, IsTreeExpander o) => o -> m Bool
- setTreeExpanderHideExpander :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m ()
- constructTreeExpanderIndentForDepth :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o)
- getTreeExpanderIndentForDepth :: (MonadIO m, IsTreeExpander o) => o -> m Bool
- setTreeExpanderIndentForDepth :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m ()
- constructTreeExpanderIndentForIcon :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o)
- getTreeExpanderIndentForIcon :: (MonadIO m, IsTreeExpander o) => o -> m Bool
- setTreeExpanderIndentForIcon :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m ()
- getTreeExpanderItem :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe Object)
- clearTreeExpanderListRow :: (MonadIO m, IsTreeExpander o) => o -> m ()
- constructTreeExpanderListRow :: (IsTreeExpander o, MonadIO m, IsTreeListRow a) => a -> m (GValueConstruct o)
- getTreeExpanderListRow :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe TreeListRow)
- setTreeExpanderListRow :: (MonadIO m, IsTreeExpander o, IsTreeListRow a) => o -> a -> m ()

# Exported types

newtype TreeExpander Source #

Memory-managed wrapper type.

Constructors

TreeExpander (ManagedPtr TreeExpander) |

#### Instances

Instances details

Eq TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander Methods (==) :: TreeExpander -> TreeExpander -> Bool Source # (/=) :: TreeExpander -> TreeExpander -> Bool Source #
GObject TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander
ManagedPtrNewtype TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander Methods toManagedPtr :: TreeExpander -> ManagedPtr TreeExpander Source #
TypedObject TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander Methods glibType :: IO GType Source #
HasParentTypes TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander
IsGValue (Maybe TreeExpander) Source # | Convert `TreeExpander` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.TreeExpander Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe TreeExpander -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe TreeExpander) Source #
type ParentTypes TreeExpander Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander type ParentTypes TreeExpander = '[Widget, Object, Accessible, Buildable, ConstraintTarget]

class (GObject o, IsDescendantOf TreeExpander o) => IsTreeExpander o Source #

Type class for types which can be safely cast to `TreeExpander`, for instance with `toTreeExpander`.

#### Instances

Instances details

(GObject o, IsDescendantOf TreeExpander o) => IsTreeExpander o Source # |
Instance details Defined in GI.Gtk.Objects.TreeExpander

toTreeExpander :: (MonadIO m, IsTreeExpander o) => o -> m TreeExpander Source #

Cast to `TreeExpander`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState, watchClosure.

#### Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChild, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getHideExpander, getIndentForDepth, getIndentForIcon, getItem, getLastChild, getLayoutManager, getLimitEvents, getListRow, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

#### Setters

setAccessibleParent, setCanFocus, setCanTarget, setChild, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setHideExpander, setIndentForDepth, setIndentForIcon, setLayoutManager, setLimitEvents, setListRow, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.

## getChild

treeExpanderGetChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m (Maybe Widget) | Returns: The child displayed by `self`

Gets the child widget displayed by `self`.

## getHideExpander

treeExpanderGetHideExpander Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m Bool | Returns: TRUE if the expander icon should be hidden. Otherwise FALSE.

Gets whether the TreeExpander should be hidden in a GtkTreeListRow.

Since: 4.10

## getIndentForDepth

treeExpanderGetIndentForDepth Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m Bool | Returns: TRUE if the child should be indented . Otherwise FALSE.

TreeExpander indents each level of depth with an additional indent.

Since: 4.10

## getIndentForIcon

treeExpanderGetIndentForIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m Bool | Returns: TRUE if the child should be indented when not expandable. Otherwise FALSE.

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

Since: 4.6

## getItem

treeExpanderGetItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m (Maybe Object) | Returns: The item of the row

Forwards the item set on the `GtkTreeListRow` that `self` is managing.

This call is essentially equivalent to calling:

### c code

    gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));

## getListRow

treeExpanderGetListRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander`
-> m (Maybe TreeListRow) | Returns: The list row displayed by `self`

Gets the list row managed by `self`.

## new

treeExpanderNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m TreeExpander | Returns: a new `GtkTreeExpander`

Creates a new `GtkTreeExpander`

## setChild

treeExpanderSetChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a, IsWidget b) |
=> a | `self`: a `GtkTreeExpander`
-> Maybe b | `child`: a `GtkWidget`
-> m () |

Sets the content widget to display.

## setHideExpander

treeExpanderSetHideExpander Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander` widget
-> Bool | `hideExpander`: TRUE if the expander should be hidden. Otherwise FALSE.
-> m () |

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

Since: 4.10

## setIndentForDepth

treeExpanderSetIndentForDepth Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander` widget
-> Bool | `indentForDepth`: TRUE if the child should be indented. Otherwise FALSE.
-> m () |

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

Since: 4.10

## setIndentForIcon

treeExpanderSetIndentForIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a) |
=> a | `self`: a `GtkTreeExpander` widget
-> Bool | `indentForIcon`: TRUE if the child should be indented without expander. Otherwise FALSE.
-> m () |

Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.

Since: 4.6

## setListRow

treeExpanderSetListRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeExpander a, IsTreeListRow b) |
=> a | `self`: a `GtkTreeExpander` widget
-> Maybe b | `listRow`: a `GtkTreeListRow`
-> m () |

Sets the tree list row that this expander should manage.

# Properties

## child

The child widget with the actual contents.

clearTreeExpanderChild :: (MonadIO m, IsTreeExpander o) => o -> m () Source #

Set the value of the “`child`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #child

constructTreeExpanderChild :: (IsTreeExpander o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`child`” property. This is rarely needed directly, but it is used by `new`.

getTreeExpanderChild :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe Widget) Source #

Get the value of the “`child`” property. When overloading is enabled, this is equivalent to

    get treeExpander #child

setTreeExpanderChild :: (MonadIO m, IsTreeExpander o, IsWidget a) => o -> a -> m () Source #

Set the value of the “`child`” property. When overloading is enabled, this is equivalent to

    set treeExpander [ #child := value ]

## hideExpander

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.

Since: 4.10

constructTreeExpanderHideExpander :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`hide-expander`” property. This is rarely needed directly, but it is used by `new`.

getTreeExpanderHideExpander :: (MonadIO m, IsTreeExpander o) => o -> m Bool Source #

Get the value of the “`hide-expander`” property. When overloading is enabled, this is equivalent to

    get treeExpander #hideExpander

setTreeExpanderHideExpander :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m () Source #

Set the value of the “`hide-expander`” property. When overloading is enabled, this is equivalent to

    set treeExpander [ #hideExpander := value ]

## indentForDepth

TreeExpander indents the child according to its depth.

Since: 4.10

constructTreeExpanderIndentForDepth :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`indent-for-depth`” property. This is rarely needed directly, but it is used by `new`.

getTreeExpanderIndentForDepth :: (MonadIO m, IsTreeExpander o) => o -> m Bool Source #

Get the value of the “`indent-for-depth`” property. When overloading is enabled, this is equivalent to

    get treeExpander #indentForDepth

setTreeExpanderIndentForDepth :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m () Source #

Set the value of the “`indent-for-depth`” property. When overloading is enabled, this is equivalent to

    set treeExpander [ #indentForDepth := value ]

## indentForIcon

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

Since: 4.6

constructTreeExpanderIndentForIcon :: (IsTreeExpander o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`indent-for-icon`” property. This is rarely needed directly, but it is used by `new`.

getTreeExpanderIndentForIcon :: (MonadIO m, IsTreeExpander o) => o -> m Bool Source #

Get the value of the “`indent-for-icon`” property. When overloading is enabled, this is equivalent to

    get treeExpander #indentForIcon

setTreeExpanderIndentForIcon :: (MonadIO m, IsTreeExpander o) => o -> Bool -> m () Source #

Set the value of the “`indent-for-icon`” property. When overloading is enabled, this is equivalent to

    set treeExpander [ #indentForIcon := value ]

## item

The item held by this expander's row.

getTreeExpanderItem :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe Object) Source #

Get the value of the “`item`” property. When overloading is enabled, this is equivalent to

    get treeExpander #item

## listRow

The list row to track for expander state.

clearTreeExpanderListRow :: (MonadIO m, IsTreeExpander o) => o -> m () Source #

Set the value of the “`list-row`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #listRow

constructTreeExpanderListRow :: (IsTreeExpander o, MonadIO m, IsTreeListRow a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`list-row`” property. This is rarely needed directly, but it is used by `new`.

getTreeExpanderListRow :: (MonadIO m, IsTreeExpander o) => o -> m (Maybe TreeListRow) Source #

Get the value of the “`list-row`” property. When overloading is enabled, this is equivalent to

    get treeExpander #listRow

setTreeExpanderListRow :: (MonadIO m, IsTreeExpander o, IsTreeListRow a) => o -> a -> m () Source #

Set the value of the “`list-row`” property. When overloading is enabled, this is equivalent to

    set treeExpander [ #listRow := value ]