Gtk.TreeListModel

g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel GObject.Object GObject.Object Gtk.TreeListModel Gtk.TreeListModel GObject.Object->Gtk.TreeListModel Gio.ListModel->Gtk.TreeListModel

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.ListModel (4)

Structs:

GObject.ObjectClass (5)

class

new (root, passthrough, autoexpand, create_func, *user_data)

get_autoexpand ()

get_child_row (position)

get_model ()

get_passthrough ()

get_row (position)

set_autoexpand (autoexpand)

Virtual Methods

Inherited:

GObject.Object (7), Gio.ListModel (3)

Properties

Name

Type

Flags

Short Description

autoexpand

bool

r/w/en

item-type

GObject.GType

r

model

Gio.ListModel

r/en

n-items

int

r

passthrough

bool

r/w/co/en

Signals

Inherited:

GObject.Object (1), Gio.ListModel (1)

Fields

Inherited:

GObject.Object (1), Gio.ListModel (1)

Class Details

class Gtk.TreeListModel(**kwargs)
Bases:

GObject.Object, Gio.ListModel

Abstract:

No

Structure:

Gtk.TreeListModelClass

GtkTreeListModel is a list model that can create child models on demand.

classmethod new(root, passthrough, autoexpand, create_func, *user_data)[source]
Parameters:
  • root (Gio.ListModel) – The GListModel to use as root

  • passthrough (bool) – True to pass through items from the models

  • autoexpand (bool) – True to set the autoexpand property and expand the root model

  • create_func (Gtk.TreeListModelCreateModelFunc) – Function to call to create the GListModel for the children of an item

  • user_data (object or None) – Data to pass to create_func

Returns:

a newly created GtkTreeListModel.

Return type:

Gtk.TreeListModel

Creates a new empty GtkTreeListModel displaying root with all rows collapsed.

get_autoexpand()[source]
Returns:

True if the model is set to autoexpand

Return type:

bool

Gets whether the model is set to automatically expand new rows that get added.

This can be either rows added by changes to the underlying models or via [method`Gtk`.TreeListRow.set_expanded].

get_child_row(position)[source]
Parameters:

position (int) – position of the child to get

Returns:

the child in position

Return type:

Gtk.TreeListRow or None

Gets the row item corresponding to the child at index position for self's root model.

If position is greater than the number of children in the root model, None is returned.

Do not confuse this function with [method`Gtk`.TreeListModel.get_row].

get_model()[source]
Returns:

the root model

Return type:

Gio.ListModel

Gets the root model that self was created with.

get_passthrough()[source]
Returns:

True if the model is passing through original row items

Return type:

bool

Gets whether the model is passing through original row items.

If this function returns False, the GListModel functions for self return custom GtkTreeListRow objects. You need to call [method`Gtk`.TreeListRow.get_item] on these objects to get the original item.

If True, the values of the child models are passed through in their original state. You then need to call [method`Gtk`.TreeListModel.get_row] to get the custom ``GtkTreeListRow``s.

get_row(position)[source]
Parameters:

position (int) – the position of the row to fetch

Returns:

The row item

Return type:

Gtk.TreeListRow or None

Gets the row object for the given row.

If position is greater than the number of items in self, None is returned.

The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.

This row object is persistent and will refer to the current item as long as the row is present in self, independent of other rows being added or removed.

If self is set to not be passthrough, this function is equivalent to calling Gio.ListModel.get_item().

Do not confuse this function with [method`Gtk`.TreeListModel.get_child_row].

set_autoexpand(autoexpand)[source]
Parameters:

autoexpand (bool) – True to make the model autoexpand its rows

Sets whether the model should autoexpand.

If set to True, the model will recursively expand all rows that get added to the model. This can be either rows added by changes to the underlying models or via [method`Gtk`.TreeListRow.set_expanded].

Property Details

Gtk.TreeListModel.props.autoexpand
Name:

autoexpand

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If all rows should be expanded by default.

Gtk.TreeListModel.props.item_type
Name:

item-type

Type:

GObject.GType

Default Value:

<GType GObject>

Flags:

READABLE

The type of items. See [method`Gio`.ListModel.get_item_type].

New in version 4.8.

Gtk.TreeListModel.props.model
Name:

model

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

The root model displayed.

Gtk.TreeListModel.props.n_items
Name:

n-items

Type:

int

Default Value:

0

Flags:

READABLE

The number of items. See [method`Gio`.ListModel.get_n_items].

New in version 4.8.

Gtk.TreeListModel.props.passthrough
Name:

passthrough

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

Gets whether the model is in passthrough mode.

If False, the GListModel functions for this object return custom [class`Gtk`.TreeListRow] objects. If True, the values of the child models are pass through unmodified.