GtkTreeListModel — A list model that can create child models on demand
GListModel * | (*GtkTreeListModelCreateModelFunc) () |
GtkTreeListModel * | gtk_tree_list_model_new () |
GListModel * | gtk_tree_list_model_get_model () |
gboolean | gtk_tree_list_model_get_passthrough () |
void | gtk_tree_list_model_set_autoexpand () |
gboolean | gtk_tree_list_model_get_autoexpand () |
GtkTreeListRow * | gtk_tree_list_model_get_child_row () |
GtkTreeListRow * | gtk_tree_list_model_get_row () |
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 |
GObject ├── GtkTreeListModel ╰── GtkTreeListRow
GtkTreeListModel implements GListModel.
#include <gtk/gtk.h>
GtkTreeListModel is a GListModel implementation that can expand rows by creating new child list models on demand.
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.
item | The item that is being expanded. | [type GObject] |
user_data | User data passed when registering the function |
The model tracking the children of item
or NULL
if item
can never have children.
[nullable][transfer full]
GtkTreeListModel * gtk_tree_list_model_new (GListModel *root
,gboolean passthrough
,gboolean autoexpand
,GtkTreeListModelCreateModelFunc create_func
,gpointer user_data
,GDestroyNotify user_destroy
);
Creates a new empty GtkTreeListModel displaying root
with all rows collapsed.
root | The GListModel to use as root. | [transfer full] |
passthrough |
| |
autoexpand |
| |
create_func | Function to call to create the GListModel for the children of an item | |
user_data | Data to pass to | [closure] |
user_destroy | Function to call to free |
a newly created GtkTreeListModel.
GListModel *
gtk_tree_list_model_get_model (GtkTreeListModel *self
);
Gets the root model that self
was created with.
self |
the root model.
[transfer none]
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.
self |
TRUE
if the model is passing through original row items
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_row_set_expanded()
.
self | ||
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_row_set_expanded()
.
self |
TRUE
if the model is set to autoexpand
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()
.
self | ||
position | position of the child to get |
the child in position
.
[nullable][transfer full]
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()
.
self | ||
position | the position of the row to fetch |
The row item.
[nullable][transfer full]
typedef struct _GtkTreeListModel GtkTreeListModel;
typedef struct _GtkTreeListRow GtkTreeListRow;
“autoexpand”
property“autoexpand” gboolean
If all rows should be expanded by default
Owner: GtkTreeListModel
Flags: Read / Write
Default value: FALSE
“model”
property“model” GListModel *
The root model displayed
Owner: GtkTreeListModel
Flags: Read
“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
“children”
property“children” GListModel *
The model holding the row's children.
Owner: GtkTreeListRow
Flags: Read
“depth”
property“depth” guint
The depth in the tree of this row
Owner: GtkTreeListRow
Flags: Read
Default value: 0
“expandable”
property“expandable” gboolean
If this row can ever be expanded
Owner: GtkTreeListRow
Flags: Read
Default value: FALSE
“expanded”
property“expanded” gboolean
If this row is currently expanded
Owner: GtkTreeListRow
Flags: Read / Write
Default value: FALSE
“item”
property“item” GObject *
The item held in this row
Owner: GtkTreeListRow
Flags: Read
GListModel
© 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/GtkTreeListModel.html