1/* gtktreemodel.h
2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <[email protected]>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef __GTK_TREE_MODEL_H__
21#define __GTK_TREE_MODEL_H__
22
23#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24#error "Only <gtk/gtk.h> can be included directly."
25#endif
26
27#include <glib-object.h>
28
29/* Not needed, retained for compatibility -Yosh */
30#include <gtk/gtkobject.h>
31
32G_BEGIN_DECLS
33
34#define GTK_TYPE_TREE_MODEL (gtk_tree_model_get_type ())
35#define GTK_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
36#define GTK_IS_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL))
37#define GTK_TREE_MODEL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModelIface))
38
39#define GTK_TYPE_TREE_ITER (gtk_tree_iter_get_type ())
40#define GTK_TYPE_TREE_PATH (gtk_tree_path_get_type ())
41#define GTK_TYPE_TREE_ROW_REFERENCE (gtk_tree_row_reference_get_type ())
42
43typedef struct _GtkTreeIter GtkTreeIter;
44typedef struct _GtkTreePath GtkTreePath;
45typedef struct _GtkTreeRowReference GtkTreeRowReference;
46typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
47typedef struct _GtkTreeModelIface GtkTreeModelIface;
48typedef gboolean (* GtkTreeModelForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
49
50
51typedef enum
52{
53 GTK_TREE_MODEL_ITERS_PERSIST = 1 << 0,
54 GTK_TREE_MODEL_LIST_ONLY = 1 << 1
55} GtkTreeModelFlags;
56
57struct _GtkTreeIter
58{
59 gint stamp;
60 gpointer user_data;
61 gpointer user_data2;
62 gpointer user_data3;
63};
64
65struct _GtkTreeModelIface
66{
67 GTypeInterface g_iface;
68
69 /* Signals */
70 void (* row_changed) (GtkTreeModel *tree_model,
71 GtkTreePath *path,
72 GtkTreeIter *iter);
73 void (* row_inserted) (GtkTreeModel *tree_model,
74 GtkTreePath *path,
75 GtkTreeIter *iter);
76 void (* row_has_child_toggled) (GtkTreeModel *tree_model,
77 GtkTreePath *path,
78 GtkTreeIter *iter);
79 void (* row_deleted) (GtkTreeModel *tree_model,
80 GtkTreePath *path);
81 void (* rows_reordered) (GtkTreeModel *tree_model,
82 GtkTreePath *path,
83 GtkTreeIter *iter,
84 gint *new_order);
85
86 /* Virtual Table */
87 GtkTreeModelFlags (* get_flags) (GtkTreeModel *tree_model);
88
89 gint (* get_n_columns) (GtkTreeModel *tree_model);
90 GType (* get_column_type) (GtkTreeModel *tree_model,
91 gint index_);
92 gboolean (* get_iter) (GtkTreeModel *tree_model,
93 GtkTreeIter *iter,
94 GtkTreePath *path);
95 GtkTreePath *(* get_path) (GtkTreeModel *tree_model,
96 GtkTreeIter *iter);
97 void (* get_value) (GtkTreeModel *tree_model,
98 GtkTreeIter *iter,
99 gint column,
100 GValue *value);
101 gboolean (* iter_next) (GtkTreeModel *tree_model,
102 GtkTreeIter *iter);
103 gboolean (* iter_children) (GtkTreeModel *tree_model,
104 GtkTreeIter *iter,
105 GtkTreeIter *parent);
106 gboolean (* iter_has_child) (GtkTreeModel *tree_model,
107 GtkTreeIter *iter);
108 gint (* iter_n_children) (GtkTreeModel *tree_model,
109 GtkTreeIter *iter);
110 gboolean (* iter_nth_child) (GtkTreeModel *tree_model,
111 GtkTreeIter *iter,
112 GtkTreeIter *parent,
113 gint n);
114 gboolean (* iter_parent) (GtkTreeModel *tree_model,
115 GtkTreeIter *iter,
116 GtkTreeIter *child);
117 void (* ref_node) (GtkTreeModel *tree_model,
118 GtkTreeIter *iter);
119 void (* unref_node) (GtkTreeModel *tree_model,
120 GtkTreeIter *iter);
121};
122
123
124/* GtkTreePath operations */
125GtkTreePath *gtk_tree_path_new (void);
126GtkTreePath *gtk_tree_path_new_from_string (const gchar *path);
127GtkTreePath *gtk_tree_path_new_from_indices (gint first_index,
128 ...);
129gchar *gtk_tree_path_to_string (GtkTreePath *path);
130GtkTreePath *gtk_tree_path_new_first (void);
131void gtk_tree_path_append_index (GtkTreePath *path,
132 gint index_);
133void gtk_tree_path_prepend_index (GtkTreePath *path,
134 gint index_);
135gint gtk_tree_path_get_depth (GtkTreePath *path);
136gint *gtk_tree_path_get_indices (GtkTreePath *path);
137gint *gtk_tree_path_get_indices_with_depth (GtkTreePath *path,
138 gint *depth);
139void gtk_tree_path_free (GtkTreePath *path);
140GtkTreePath *gtk_tree_path_copy (const GtkTreePath *path);
141GType gtk_tree_path_get_type (void) G_GNUC_CONST;
142gint gtk_tree_path_compare (const GtkTreePath *a,
143 const GtkTreePath *b);
144void gtk_tree_path_next (GtkTreePath *path);
145gboolean gtk_tree_path_prev (GtkTreePath *path);
146gboolean gtk_tree_path_up (GtkTreePath *path);
147void gtk_tree_path_down (GtkTreePath *path);
148
149gboolean gtk_tree_path_is_ancestor (GtkTreePath *path,
150 GtkTreePath *descendant);
151gboolean gtk_tree_path_is_descendant (GtkTreePath *path,
152 GtkTreePath *ancestor);
153
154#ifndef GTK_DISABLE_DEPRECATED
155#define gtk_tree_path_new_root() gtk_tree_path_new_first()
156#endif /* !GTK_DISABLE_DEPRECATED */
157
158/* Row reference (an object that tracks model changes so it refers to the same
159 * row always; a path refers to a position, not a fixed row). You almost always
160 * want to call gtk_tree_row_reference_new.
161 */
162
163GType gtk_tree_row_reference_get_type (void) G_GNUC_CONST;
164GtkTreeRowReference *gtk_tree_row_reference_new (GtkTreeModel *model,
165 GtkTreePath *path);
166GtkTreeRowReference *gtk_tree_row_reference_new_proxy (GObject *proxy,
167 GtkTreeModel *model,
168 GtkTreePath *path);
169GtkTreePath *gtk_tree_row_reference_get_path (GtkTreeRowReference *reference);
170GtkTreeModel *gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
171gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference);
172GtkTreeRowReference *gtk_tree_row_reference_copy (GtkTreeRowReference *reference);
173void gtk_tree_row_reference_free (GtkTreeRowReference *reference);
174/* These two functions are only needed if you created the row reference with a
175 * proxy object */
176void gtk_tree_row_reference_inserted (GObject *proxy,
177 GtkTreePath *path);
178void gtk_tree_row_reference_deleted (GObject *proxy,
179 GtkTreePath *path);
180void gtk_tree_row_reference_reordered (GObject *proxy,
181 GtkTreePath *path,
182 GtkTreeIter *iter,
183 gint *new_order);
184
185/* GtkTreeIter operations */
186GtkTreeIter * gtk_tree_iter_copy (GtkTreeIter *iter);
187void gtk_tree_iter_free (GtkTreeIter *iter);
188GType gtk_tree_iter_get_type (void) G_GNUC_CONST;
189
190GType gtk_tree_model_get_type (void) G_GNUC_CONST;
191GtkTreeModelFlags gtk_tree_model_get_flags (GtkTreeModel *tree_model);
192gint gtk_tree_model_get_n_columns (GtkTreeModel *tree_model);
193GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
194 gint index_);
195
196
197/* Iterator movement */
198gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model,
199 GtkTreeIter *iter,
200 GtkTreePath *path);
201gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model,
202 GtkTreeIter *iter,
203 const gchar *path_string);
204gchar * gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model,
205 GtkTreeIter *iter);
206gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model,
207 GtkTreeIter *iter);
208GtkTreePath * gtk_tree_model_get_path (GtkTreeModel *tree_model,
209 GtkTreeIter *iter);
210void gtk_tree_model_get_value (GtkTreeModel *tree_model,
211 GtkTreeIter *iter,
212 gint column,
213 GValue *value);
214gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model,
215 GtkTreeIter *iter);
216gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model,
217 GtkTreeIter *iter,
218 GtkTreeIter *parent);
219gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model,
220 GtkTreeIter *iter);
221gint gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
222 GtkTreeIter *iter);
223gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
224 GtkTreeIter *iter,
225 GtkTreeIter *parent,
226 gint n);
227gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
228 GtkTreeIter *iter,
229 GtkTreeIter *child);
230void gtk_tree_model_ref_node (GtkTreeModel *tree_model,
231 GtkTreeIter *iter);
232void gtk_tree_model_unref_node (GtkTreeModel *tree_model,
233 GtkTreeIter *iter);
234void gtk_tree_model_get (GtkTreeModel *tree_model,
235 GtkTreeIter *iter,
236 ...);
237void gtk_tree_model_get_valist (GtkTreeModel *tree_model,
238 GtkTreeIter *iter,
239 va_list var_args);
240
241
242void gtk_tree_model_foreach (GtkTreeModel *model,
243 GtkTreeModelForeachFunc func,
244 gpointer user_data);
245
246
247#ifndef GTK_DISABLE_DEPRECATED
248#define gtk_tree_model_get_iter_root(tree_model, iter) gtk_tree_model_get_iter_first(tree_model, iter)
249#endif /* !GTK_DISABLE_DEPRECATED */
250
251/* Signals */
252void gtk_tree_model_row_changed (GtkTreeModel *tree_model,
253 GtkTreePath *path,
254 GtkTreeIter *iter);
255void gtk_tree_model_row_inserted (GtkTreeModel *tree_model,
256 GtkTreePath *path,
257 GtkTreeIter *iter);
258void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model,
259 GtkTreePath *path,
260 GtkTreeIter *iter);
261void gtk_tree_model_row_deleted (GtkTreeModel *tree_model,
262 GtkTreePath *path);
263void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model,
264 GtkTreePath *path,
265 GtkTreeIter *iter,
266 gint *new_order);
267
268G_END_DECLS
269
270#endif /* __GTK_TREE_MODEL_H__ */
271