GtkTreeListModel

GtkTreeListModel — A list model that can create child models on demand

Properties

gboolean autoexpand Read / Write
GListModel * model Read
gboolean passthrough Read / Write / Construct Only
GListModel * children Read
guint depth Read
gboolean expandable Read
gboolean expanded Read / Write
GObject * item Read

Types and Values

Object Hierarchy

    GObject
    ├── GtkTreeListModel
    ╰── GtkTreeListRow

Implemented Interfaces

GtkTreeListModel implements GListModel.

Includes

#include <gtk/gtk.h>

Description

GtkTreeListModel is a GListModel implementation that can expand rows by creating new child list models on demand.

Functions

GtkTreeListModelCreateModelFunc ()

GListModel *
(*GtkTreeListModelCreateModelFunc) (gpointer item,
                                    gpointer user_data);

Prototype of the function called to create new child models when gtk_tree_list_row_set_expanded() is called.

This function can return NULL to indicate that item is guaranteed to be a leaf node and will never have children. If it does not have children but may get children later, it should return an empty model that is filled once children arrive.

Parameters

item

The item that is being expanded.

[type GObject]

user_data

User data passed when registering the function

 

Returns

The model tracking the children of item or NULL if item can never have children.

[nullable][transfer full]


gtk_tree_list_model_new ()

GtkTreeListModel *
gtk_tree_list_model_new (gboolean passthrough,
                         GListModel *root,
                         gboolean autoexpand,
                         GtkTreeListModelCreateModelFunc create_func,
                         gpointer user_data,
                         GDestroyNotify user_destroy);

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

Parameters

passthrough

TRUE to pass through items from the models

 

root

The GListModel to use as root

 

autoexpand

TRUE to set the autoexpand property and expand the root model

 

create_func

Function to call to create the GListModel for the children of an item

 

user_data

Data to pass to create_func .

[closure]

user_destroy

Function to call to free user_data

 

Returns

a newly created GtkTreeListModel.


gtk_tree_list_model_get_model ()

GListModel *
gtk_tree_list_model_get_model (GtkTreeListModel *self);

Gets the root model that self was created with.

Parameters

self

a GtkTreeListModel

 

Returns

the root model.

[transfer none]


gtk_tree_list_model_get_passthrough ()

gboolean
gtk_tree_list_model_get_passthrough (GtkTreeListModel *self);

If this function returns FALSE, the GListModel functions for self return custom GtkTreeListRow objects. You need to call gtk_tree_list_row_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 gtk_tree_list_model_get_row() to get the custom GtkTreeListRows.

Parameters

self

a GtkTreeListModel

 

Returns

TRUE if the model is passing through original row items


gtk_tree_list_model_set_autoexpand ()

void
gtk_tree_list_model_set_autoexpand (GtkTreeListModel *self,
                                    gboolean 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 gtk_tree_list_model_set_expanded().

Parameters

self

a GtkTreeListModel

 

autoexpand

TRUE to make the model autoexpand its rows

 

gtk_tree_list_model_get_autoexpand ()

gboolean
gtk_tree_list_model_get_autoexpand (GtkTreeListModel *self);

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 gtk_tree_list_model_set_expanded().

Parameters

self

a GtkTreeListModel

 

Returns

TRUE if the model is set to autoexpand


gtk_tree_list_model_get_child_row ()

GtkTreeListRow *
gtk_tree_list_model_get_child_row (GtkTreeListModel *self,
                                   guint position);

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, NULL is returned.

Do not confuse this function with gtk_tree_list_model_get_row().

Parameters

self

a GtkTreeListModel

 

position

position of the child to get

 

Returns

the child in position .

[nullable][transfer full]


gtk_tree_list_model_get_row ()

GtkTreeListRow *
gtk_tree_list_model_get_row (GtkTreeListModel *self,
                             guint position);

Gets the row object for the given row. If position is greater than the number of items in self , NULL 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 g_list_model_get_item().

Do not confuse this function with gtk_tree_list_model_get_child_row().

Parameters

self

a GtkTreeListModel

 

position

the position of the row to fetch

 

Returns

The row item.

[nullable][transfer full]

Types and Values

GtkTreeListModel

typedef struct _GtkTreeListModel GtkTreeListModel;

GtkTreeListRow

typedef struct _GtkTreeListRow GtkTreeListRow;

Property Details

The “autoexpand” property

  “autoexpand”               gboolean

If all rows should be expanded by default

Owner: GtkTreeListModel

Flags: Read / Write

Default value: FALSE


The “model” property

  “model”                    GListModel *

The root model displayed

Owner: GtkTreeListModel

Flags: Read


The “passthrough” property

  “passthrough”              gboolean

If FALSE, the GListModel functions for this object return custom GtkTreeListRow objects. If TRUE, the values of the child models are pass through unmodified.

Owner: GtkTreeListModel

Flags: Read / Write / Construct Only

Default value: FALSE


The “children” property

  “children”                 GListModel *

The model holding the row's children.

Owner: GtkTreeListRow

Flags: Read


The “depth” property

  “depth”                    guint

The depth in the tree of this row

Owner: GtkTreeListRow

Flags: Read

Default value: 0


The “expandable” property

  “expandable”               gboolean

If this row can ever be expanded

Owner: GtkTreeListRow

Flags: Read

Default value: FALSE


The “expanded” property

  “expanded”                 gboolean

If this row is currently expanded

Owner: GtkTreeListRow

Flags: Read / Write

Default value: FALSE


The “item” property

  “item”                     GObject *

The item held in this row

Owner: GtkTreeListRow

Flags: Read

See Also

GListModel