2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
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.
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.
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.
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
24 #ifndef __GTK_TREE_MODEL_H__
25 #define __GTK_TREE_MODEL_H__
27 #include <glib-object.h>
31 #define GTK_TYPE_TREE_MODEL (gtk_tree_model_get_type ())
32 #define GTK_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
33 #define GTK_IS_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL))
34 #define GTK_TREE_MODEL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModelIface))
36 #define GTK_TYPE_TREE_ITER (gtk_tree_iter_get_type ())
37 #define GTK_TYPE_TREE_PATH (gtk_tree_path_get_type ())
38 #define GTK_TYPE_TREE_ROW_REFERENCE (gtk_tree_row_reference_get_type ())
40 typedef struct _GtkTreeIter GtkTreeIter;
41 typedef struct _GtkTreePath GtkTreePath;
42 typedef struct _GtkTreeRowReference GtkTreeRowReference;
43 typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
44 typedef struct _GtkTreeModelIface GtkTreeModelIface;
47 * GtkTreeModelForeachFunc:
48 * @model: the #GtkTreeModel being iterated
49 * @path: the current #GtkTreePath
50 * @iter: the current #GtkTreeIter
51 * @data: The user data passed to gtk_tree_model_foreach()
53 * Type of the callback passed to gtk_tree_model_foreach() to
54 * iterate over the rows in a tree model.
56 * Return value: %TRUE to stop iterating, %FALSE to continue
59 typedef gboolean (* GtkTreeModelForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
63 * @GTK_TREE_MODEL_ITERS_PERSIST: iterators survive all signals
65 * @GTK_TREE_MODEL_LIST_ONLY: the model is a list only, and never
68 * These flags indicate various properties of a #GtkTreeModel.
70 * They are returned by gtk_tree_model_get_flags(), and must be
71 * static for the lifetime of the object. A more complete description
72 * of #GTK_TREE_MODEL_ITERS_PERSIST can be found in the overview of
77 GTK_TREE_MODEL_ITERS_PERSIST = 1 << 0,
78 GTK_TREE_MODEL_LIST_ONLY = 1 << 1
83 * @stamp: a unique stamp to catch invalid iterators
84 * @user_data: model-specific data
85 * @user_data2: model-specific data
86 * @user_data3: model-specific data
88 * The <structname>GtkTreeIter</structname> is the primary structure
89 * for accessing a #GtkTreeModel. Models are expected to put a unique
90 * integer in the <structfield>stamp</structfield> member, and put
91 * model-specific data in the three <structfield>user_data</structfield>
102 struct _GtkTreeModelIface
104 GTypeInterface g_iface;
107 void (* row_changed) (GtkTreeModel *tree_model,
110 void (* row_inserted) (GtkTreeModel *tree_model,
113 void (* row_has_child_toggled) (GtkTreeModel *tree_model,
116 void (* row_deleted) (GtkTreeModel *tree_model,
118 void (* rows_reordered) (GtkTreeModel *tree_model,
124 GtkTreeModelFlags (* get_flags) (GtkTreeModel *tree_model);
126 gint (* get_n_columns) (GtkTreeModel *tree_model);
127 GType (* get_column_type) (GtkTreeModel *tree_model,
129 gboolean (* get_iter) (GtkTreeModel *tree_model,
132 GtkTreePath *(* get_path) (GtkTreeModel *tree_model,
134 void (* get_value) (GtkTreeModel *tree_model,
138 gboolean (* iter_next) (GtkTreeModel *tree_model,
140 gboolean (* iter_previous) (GtkTreeModel *tree_model,
142 gboolean (* iter_children) (GtkTreeModel *tree_model,
144 GtkTreeIter *parent);
145 gboolean (* iter_has_child) (GtkTreeModel *tree_model,
147 gint (* iter_n_children) (GtkTreeModel *tree_model,
149 gboolean (* iter_nth_child) (GtkTreeModel *tree_model,
153 gboolean (* iter_parent) (GtkTreeModel *tree_model,
156 void (* ref_node) (GtkTreeModel *tree_model,
158 void (* unref_node) (GtkTreeModel *tree_model,
163 /* GtkTreePath operations */
164 GtkTreePath *gtk_tree_path_new (void);
165 GtkTreePath *gtk_tree_path_new_from_string (const gchar *path);
166 GtkTreePath *gtk_tree_path_new_from_indices (gint first_index,
168 gchar *gtk_tree_path_to_string (GtkTreePath *path);
169 GtkTreePath *gtk_tree_path_new_first (void);
170 void gtk_tree_path_append_index (GtkTreePath *path,
172 void gtk_tree_path_prepend_index (GtkTreePath *path,
174 gint gtk_tree_path_get_depth (GtkTreePath *path);
175 gint *gtk_tree_path_get_indices (GtkTreePath *path);
177 gint *gtk_tree_path_get_indices_with_depth (GtkTreePath *path,
180 void gtk_tree_path_free (GtkTreePath *path);
181 GtkTreePath *gtk_tree_path_copy (const GtkTreePath *path);
182 GType gtk_tree_path_get_type (void) G_GNUC_CONST;
183 gint gtk_tree_path_compare (const GtkTreePath *a,
184 const GtkTreePath *b);
185 void gtk_tree_path_next (GtkTreePath *path);
186 gboolean gtk_tree_path_prev (GtkTreePath *path);
187 gboolean gtk_tree_path_up (GtkTreePath *path);
188 void gtk_tree_path_down (GtkTreePath *path);
190 gboolean gtk_tree_path_is_ancestor (GtkTreePath *path,
191 GtkTreePath *descendant);
192 gboolean gtk_tree_path_is_descendant (GtkTreePath *path,
193 GtkTreePath *ancestor);
195 /* Row reference (an object that tracks model changes so it refers to the same
196 * row always; a path refers to a position, not a fixed row). You almost always
197 * want to call gtk_tree_row_reference_new.
200 GType gtk_tree_row_reference_get_type (void) G_GNUC_CONST;
201 GtkTreeRowReference *gtk_tree_row_reference_new (GtkTreeModel *model,
203 GtkTreeRowReference *gtk_tree_row_reference_new_proxy (GObject *proxy,
206 GtkTreePath *gtk_tree_row_reference_get_path (GtkTreeRowReference *reference);
207 GtkTreeModel *gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
208 gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference);
209 GtkTreeRowReference *gtk_tree_row_reference_copy (GtkTreeRowReference *reference);
210 void gtk_tree_row_reference_free (GtkTreeRowReference *reference);
211 /* These two functions are only needed if you created the row reference with a
213 void gtk_tree_row_reference_inserted (GObject *proxy,
215 void gtk_tree_row_reference_deleted (GObject *proxy,
217 void gtk_tree_row_reference_reordered (GObject *proxy,
222 /* GtkTreeIter operations */
223 GtkTreeIter * gtk_tree_iter_copy (GtkTreeIter *iter);
224 void gtk_tree_iter_free (GtkTreeIter *iter);
225 GType gtk_tree_iter_get_type (void) G_GNUC_CONST;
227 GType gtk_tree_model_get_type (void) G_GNUC_CONST;
228 GtkTreeModelFlags gtk_tree_model_get_flags (GtkTreeModel *tree_model);
229 gint gtk_tree_model_get_n_columns (GtkTreeModel *tree_model);
230 GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
234 /* Iterator movement */
235 gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model,
238 gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model,
240 const gchar *path_string);
241 gchar * gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model,
243 gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model,
245 GtkTreePath * gtk_tree_model_get_path (GtkTreeModel *tree_model,
247 void gtk_tree_model_get_value (GtkTreeModel *tree_model,
251 gboolean gtk_tree_model_iter_previous (GtkTreeModel *tree_model,
253 gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model,
255 gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model,
257 GtkTreeIter *parent);
258 gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model,
260 gint gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
262 gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
266 gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
269 void gtk_tree_model_ref_node (GtkTreeModel *tree_model,
271 void gtk_tree_model_unref_node (GtkTreeModel *tree_model,
273 void gtk_tree_model_get (GtkTreeModel *tree_model,
276 void gtk_tree_model_get_valist (GtkTreeModel *tree_model,
281 void gtk_tree_model_foreach (GtkTreeModel *model,
282 GtkTreeModelForeachFunc func,
286 void gtk_tree_model_row_changed (GtkTreeModel *tree_model,
289 void gtk_tree_model_row_inserted (GtkTreeModel *tree_model,
292 void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model,
295 void gtk_tree_model_row_deleted (GtkTreeModel *tree_model,
297 void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model,
304 #endif /* __GTK_TREE_MODEL_H__ */