GtkTreeListModel

GtkTreeListModel — a List model that can create child models on demand

Functions

Types and Values

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 leave 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]


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

 

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]


gtk_tree_list_row_get_item ()

gpointer
gtk_tree_list_row_get_item (GtkTreeListRow *self);

Gets the item corresponding to this row,

The value returned by this function never changes until the row is destroyed.

Parameters

self

a GtkTreeListRow

 

Returns

The item of this row or NULL when the row was destroyed.

[nullable][type GObject][transfer full]


gtk_tree_list_row_set_expanded ()

void
gtk_tree_list_row_set_expanded (GtkTreeListRow *self,
                                gboolean expanded);

Expands or collapses a row.

If a row is expanded, the model of calling the GtkTreeListModelCreateModelFunc for the row's item will be inserted after this row. If a row is collapsed, those items will be removed from the model.

If the row is not expandable, this function does nothing.

Parameters

self

a GtkTreeListRow

 

expanded

TRUE if the row should be expanded

 

gtk_tree_list_row_get_expanded ()

gboolean
gtk_tree_list_row_get_expanded (GtkTreeListRow *self);

Gets if a row is currently expanded.

Parameters

self

a GtkTreeListRow

 

Returns

TRUE if the row is expanded


gtk_tree_list_row_is_expandable ()

gboolean
gtk_tree_list_row_is_expandable (GtkTreeListRow *self);

Checks if a row can be expanded. This does not mean that the row is actually expanded, this can be checked with gtk_tree_list_row_get_expanded()

If a row is expandable never changes until the row is destroyed.

Parameters

self

a GtkTreeListRow

 

Returns

TRUE if the row is expandable


gtk_tree_list_row_get_position ()

guint
gtk_tree_list_row_get_position (GtkTreeListRow *self);

Returns the position in the GtkTreeListModel that self occupies at the moment.

Parameters

self

a GtkTreeListRow

 

Returns

The position in the model


gtk_tree_list_row_get_depth ()

guint
gtk_tree_list_row_get_depth (GtkTreeListRow *self);

Gets the depth of this row. Rows that correspond to items in the root model have a depth of zero, rows corresponding to items of models of direct children of the root model have a depth of 1 and so on.

The depth of a row never changes until the row is destroyed.

Parameters

self

a GtkTreeListRow

 

Returns

The depth of this row


gtk_tree_list_row_get_children ()

GListModel *
gtk_tree_list_row_get_children (GtkTreeListRow *self);

If the row is expanded, gets the model holding the children of self .

This model is the model created by the GtkTreeListModelCreateModelFunc and contains the original items, no matter what value “passthrough” is set to.

Parameters

self

a GtkTreeListRow

 

Returns

The model containing the children.

[nullable][transfer none]


gtk_tree_list_row_get_parent ()

GtkTreeListRow *
gtk_tree_list_row_get_parent (GtkTreeListRow *self);

Gets the row representing the parent for self . That is the row that would need to be collapsed to make this row disappear.

If self is a row corresponding to the root model, NULL is returned.

The value returned by this function never changes until the row is destroyed.

Parameters

self

a GtkTreeListRow

 

Returns

The parent of self .

[nullable][transfer full]


gtk_tree_list_row_get_child_row ()

GtkTreeListRow *
gtk_tree_list_row_get_child_row (GtkTreeListRow *self,
                                 guint position);

If self is not expanded or position is greater than the number of children, NULL is returned.

Parameters

self

a GtkTreeListRow

 

position

position of the child to get

 

Returns

the child in position .

[nullable][transfer full]

Types and Values

GtkTreeListModel

typedef struct _GtkTreeListModel GtkTreeListModel;

GtkTreeListRow

typedef struct _GtkTreeListRow GtkTreeListRow;

See Also

GListModel