GtkTreeExpander

GtkTreeExpander — An indenting expander button for use in a tree list

Properties

GtkWidget * child Read / Write
GObject * item Read
GtkTreeListRow * list-row Read / Write

Actions

listitem.toggle-expand
listitem.collapse
listitem.expand

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkTreeExpander

Implemented Interfaces

GtkTreeExpander implements GtkAccessible, GtkBuildable and GtkConstraintTarget.

Includes

#include <gtk/gtk.h>

Description

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 GtkTreeListModel. It will provide 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 GtkTreeListRow items which can be set via gtk_tree_expander_set_list_row() on the expander. The expander will then watch that row item automatically. gtk_tree_expander_set_child() sets the widget that displays the actual row contents.

CSS nodes

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.

Functions

gtk_tree_expander_new ()

GtkWidget *
gtk_tree_expander_new (void);

Creates a new GtkTreeExpander

Returns

a new GtkTreeExpander

gtk_tree_expander_get_child ()

GtkWidget *
gtk_tree_expander_get_child (GtkTreeExpander *self);

Gets the child widget displayed by self .

Parameters

Returns

The child displayed by self .

[nullable][transfer none]

gtk_tree_expander_set_child ()

void
gtk_tree_expander_set_child (GtkTreeExpander *self,
                             GtkWidget *child);

Sets the content widget to display.

Parameters

self

a GtkTreeExpander widget

child

a GtkWidget, or NULL.

[nullable]

gtk_tree_expander_get_item ()

gpointer
gtk_tree_expander_get_item (GtkTreeExpander *self);

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

This call is essentially equivalent to calling:

treeexpander
├── [indent]*
├── [expander]
╰── <child>

Parameters

Returns

The item of the row.

[nullable][transfer full][type GObject]

gtk_tree_expander_get_list_row ()

GtkTreeListRow *
gtk_tree_expander_get_list_row (GtkTreeExpander *self);

Gets the list row managed by self .

Parameters

Returns

The list row displayed by self .

[nullable][transfer none]

gtk_tree_expander_set_list_row ()

void
gtk_tree_expander_set_list_row (GtkTreeExpander *self,
                                GtkTreeListRow *list_row);

Sets the tree list row that this expander should manage.

Parameters

self

a GtkTreeExpander widget

list_row

a GtkTreeListRow, or NULL.

[nullable]

Types and Values

GtkTreeExpander

typedef struct _GtkTreeExpander GtkTreeExpander;

Property Details

The “child” property

  “child”                    GtkWidget *

The child widget with the actual contents

Owner: GtkTreeExpander

Flags: Read / Write

The “item” property

  “item”                     GObject *

The item held by this expander's row

Owner: GtkTreeExpander

Flags: Read

The “list-row” property

  “list-row”                 GtkTreeListRow *

The list row to track for expander state

Owner: GtkTreeExpander

Flags: Read / Write

Action Details

The “listitem.toggle-expand” action

Tries to expand the expander if it was collapsed or collapses it if it was expanded.

The “listitem.collapse” action

Collapses the expander.

The “listitem.expand” action

Expands the expander if it can be expanded.

See Also

GtkTreeListModel

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkTreeExpander.html