1/*
2 * Copyright © 2018 Benjamin Otte
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <otte@gnome.org>
18 */
19
20#ifndef __GTK_TREE_LIST_MODEL_H__
21#define __GTK_TREE_LIST_MODEL_H__
22
23
24#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25#error "Only <gtk/gtk.h> can be included directly."
26#endif
27
28#include <gio/gio.h>
29#include <gtk/gtkwidget.h>
30
31
32G_BEGIN_DECLS
33
34#define GTK_TYPE_TREE_LIST_MODEL (gtk_tree_list_model_get_type ())
35#define GTK_TYPE_TREE_LIST_ROW (gtk_tree_list_row_get_type ())
36
37GDK_AVAILABLE_IN_ALL
38G_DECLARE_FINAL_TYPE (GtkTreeListModel, gtk_tree_list_model, GTK, TREE_LIST_MODEL, GObject)
39GDK_AVAILABLE_IN_ALL
40G_DECLARE_FINAL_TYPE (GtkTreeListRow, gtk_tree_list_row, GTK, TREE_LIST_ROW, GObject)
41
42/**
43 * GtkTreeListModelCreateModelFunc:
44 * @item: (type GObject): The item that is being expanded
45 * @user_data: User data passed when registering the function
46 *
47 * Prototype of the function called to create new child models when
48 * gtk_tree_list_row_set_expanded() is called.
49 *
50 * This function can return %NULL to indicate that @item is guaranteed to be
51 * a leaf node and will never have children. If it does not have children but
52 * may get children later, it should return an empty model that is filled once
53 * children arrive.
54 *
55 * Returns: (nullable) (transfer full): The model tracking the children of
56 * @item or %NULL if @item can never have children
57 */
58typedef GListModel * (* GtkTreeListModelCreateModelFunc) (gpointer item, gpointer user_data);
59
60GDK_AVAILABLE_IN_ALL
61GtkTreeListModel * gtk_tree_list_model_new (GListModel *root,
62 gboolean passthrough,
63 gboolean autoexpand,
64 GtkTreeListModelCreateModelFunc create_func,
65 gpointer user_data,
66 GDestroyNotify user_destroy);
67
68GDK_AVAILABLE_IN_ALL
69GListModel * gtk_tree_list_model_get_model (GtkTreeListModel *self);
70GDK_AVAILABLE_IN_ALL
71gboolean gtk_tree_list_model_get_passthrough (GtkTreeListModel *self);
72GDK_AVAILABLE_IN_ALL
73void gtk_tree_list_model_set_autoexpand (GtkTreeListModel *self,
74 gboolean autoexpand);
75GDK_AVAILABLE_IN_ALL
76gboolean gtk_tree_list_model_get_autoexpand (GtkTreeListModel *self);
77
78GDK_AVAILABLE_IN_ALL
79GtkTreeListRow * gtk_tree_list_model_get_child_row (GtkTreeListModel *self,
80 guint position);
81GDK_AVAILABLE_IN_ALL
82GtkTreeListRow * gtk_tree_list_model_get_row (GtkTreeListModel *self,
83 guint position);
84
85GDK_AVAILABLE_IN_ALL
86gpointer gtk_tree_list_row_get_item (GtkTreeListRow *self);
87GDK_AVAILABLE_IN_ALL
88void gtk_tree_list_row_set_expanded (GtkTreeListRow *self,
89 gboolean expanded);
90GDK_AVAILABLE_IN_ALL
91gboolean gtk_tree_list_row_get_expanded (GtkTreeListRow *self);
92GDK_AVAILABLE_IN_ALL
93gboolean gtk_tree_list_row_is_expandable (GtkTreeListRow *self);
94GDK_AVAILABLE_IN_ALL
95guint gtk_tree_list_row_get_position (GtkTreeListRow *self);
96GDK_AVAILABLE_IN_ALL
97guint gtk_tree_list_row_get_depth (GtkTreeListRow *self);
98GDK_AVAILABLE_IN_ALL
99GListModel * gtk_tree_list_row_get_children (GtkTreeListRow *self);
100GDK_AVAILABLE_IN_ALL
101GtkTreeListRow * gtk_tree_list_row_get_parent (GtkTreeListRow *self);
102GDK_AVAILABLE_IN_ALL
103GtkTreeListRow * gtk_tree_list_row_get_child_row (GtkTreeListRow *self,
104 guint position);
105
106
107G_END_DECLS
108
109#endif /* __GTK_TREE_LIST_MODEL_H__ */
110

source code of gtk/gtk/gtktreelistmodel.h