summaryrefslogtreecommitdiff
path: root/gtk/gtktreelistmodel.h
blob: 367ead75ab829ee836e9b0fef6b6865c594c4b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * Copyright © 2018 Benjamin Otte
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */

#pragma once


#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gio/gio.h>
#include <gtk/gtkwidget.h>


G_BEGIN_DECLS

#define GTK_TYPE_TREE_LIST_MODEL (gtk_tree_list_model_get_type ())
#define GTK_TYPE_TREE_LIST_ROW (gtk_tree_list_row_get_type ())

GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkTreeListModel, gtk_tree_list_model, GTK, TREE_LIST_MODEL, GObject)
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkTreeListRow, gtk_tree_list_row, GTK, TREE_LIST_ROW, GObject)

/**
 * GtkTreeListModelCreateModelFunc:
 * @item: (type GObject): The item that is being expanded
 * @user_data: User data passed when registering the function
 *
 * 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.
 *
 * Returns: (nullable) (transfer full): The model tracking the children of
 *   @item or %NULL if @item can never have children
 */
typedef GListModel * (* GtkTreeListModelCreateModelFunc) (gpointer item, gpointer user_data);

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

GDK_AVAILABLE_IN_ALL
GListModel *            gtk_tree_list_model_get_model           (GtkTreeListModel       *self);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_tree_list_model_get_passthrough     (GtkTreeListModel       *self);
GDK_AVAILABLE_IN_ALL
void                    gtk_tree_list_model_set_autoexpand      (GtkTreeListModel       *self,
                                                                 gboolean                autoexpand);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_tree_list_model_get_autoexpand      (GtkTreeListModel       *self);

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

GDK_AVAILABLE_IN_ALL
gpointer                gtk_tree_list_row_get_item              (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
void                    gtk_tree_list_row_set_expanded          (GtkTreeListRow         *self,
                                                                 gboolean                expanded);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_tree_list_row_get_expanded          (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
gboolean                gtk_tree_list_row_is_expandable         (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
guint                   gtk_tree_list_row_get_position          (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
guint                   gtk_tree_list_row_get_depth             (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
GListModel *            gtk_tree_list_row_get_children          (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
GtkTreeListRow *        gtk_tree_list_row_get_parent            (GtkTreeListRow         *self);
GDK_AVAILABLE_IN_ALL
GtkTreeListRow *        gtk_tree_list_row_get_child_row         (GtkTreeListRow         *self,
                                                                 guint                   position);


G_END_DECLS