gtktreemodel.h 11.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* gtktreemodel.h
 * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

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

24 25 26
#ifndef __GTK_TREE_MODEL_H__
#define __GTK_TREE_MODEL_H__

Manish Singh's avatar
Manish Singh committed
27
#include <glib-object.h>
28

29 30 31
/* Not needed, retained for compatibility -Yosh */
#include <gtk/gtkobject.h>

32
G_BEGIN_DECLS
33 34

#define GTK_TYPE_TREE_MODEL            (gtk_tree_model_get_type ())
35 36
#define GTK_TREE_MODEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
#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 40
#define GTK_TYPE_TREE_ITER             (gtk_tree_iter_get_type ())
#define GTK_TYPE_TREE_PATH             (gtk_tree_path_get_type ())
41
#define GTK_TYPE_TREE_ROW_REFERENCE    (gtk_tree_row_reference_get_type ())
42

43 44 45 46 47
typedef struct _GtkTreeIter         GtkTreeIter;
typedef struct _GtkTreePath         GtkTreePath;
typedef struct _GtkTreeRowReference GtkTreeRowReference;
typedef struct _GtkTreeModel        GtkTreeModel; /* Dummy typedef */
typedef struct _GtkTreeModelIface   GtkTreeModelIface;
48
typedef gboolean (* GtkTreeModelForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
49

50 51 52

typedef enum
{
53
  GTK_TREE_MODEL_ITERS_PERSIST = 1 << 0,
54
  GTK_TREE_MODEL_LIST_ONLY = 1 << 1
55 56
} GtkTreeModelFlags;

57 58 59
struct _GtkTreeIter
{
  gint stamp;
Havoc Pennington's avatar
Havoc Pennington committed
60 61 62
  gpointer user_data;
  gpointer user_data2;
  gpointer user_data3;
63 64
};

65
struct _GtkTreeModelIface
66
{
67
  GTypeInterface g_iface;
68

69
  /* Signals */
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
  void         (* row_changed)           (GtkTreeModel *tree_model,
					  GtkTreePath  *path,
					  GtkTreeIter  *iter);
  void         (* row_inserted)          (GtkTreeModel *tree_model,
					  GtkTreePath  *path,
					  GtkTreeIter  *iter);
  void         (* row_has_child_toggled) (GtkTreeModel *tree_model,
					  GtkTreePath  *path,
					  GtkTreeIter  *iter);
  void         (* row_deleted)           (GtkTreeModel *tree_model,
					  GtkTreePath  *path);
  void         (* rows_reordered)        (GtkTreeModel *tree_model,
					  GtkTreePath  *path,
					  GtkTreeIter  *iter,
					  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 93
  gboolean     (* get_iter)        (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter,
94 95
				    GtkTreePath  *path);
  GtkTreePath *(* get_path)        (GtkTreeModel *tree_model,
96
				    GtkTreeIter  *iter);
97
  void         (* get_value)       (GtkTreeModel *tree_model,
98
				    GtkTreeIter  *iter,
99 100
				    gint          column,
				    GValue       *value);
101 102 103 104
  gboolean     (* iter_next)       (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter);
  gboolean     (* iter_children)   (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter,
105
				    GtkTreeIter  *parent);
106 107 108 109 110 111 112
  gboolean     (* iter_has_child)  (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter);
  gint         (* iter_n_children) (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter);
  gboolean     (* iter_nth_child)  (GtkTreeModel *tree_model,
				    GtkTreeIter  *iter,
				    GtkTreeIter  *parent,
113
				    gint          n);
114 115
  gboolean     (* iter_parent)     (GtkTreeModel *tree_model,
				    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 */
125
GtkTreePath *gtk_tree_path_new              (void);
126
GtkTreePath *gtk_tree_path_new_from_string  (const gchar       *path);
127 128
GtkTreePath *gtk_tree_path_new_from_indices (gint               first_index,
					     ...);
129
gchar       *gtk_tree_path_to_string        (GtkTreePath       *path);
130
GtkTreePath *gtk_tree_path_new_first        (void);
131
void         gtk_tree_path_append_index     (GtkTreePath       *path,
132
					     gint               index_);
133
void         gtk_tree_path_prepend_index    (GtkTreePath       *path,
134
					     gint               index_);
135 136 137
gint         gtk_tree_path_get_depth        (GtkTreePath       *path);
gint        *gtk_tree_path_get_indices      (GtkTreePath       *path);
void         gtk_tree_path_free             (GtkTreePath       *path);
138
GtkTreePath *gtk_tree_path_copy             (const GtkTreePath *path);
Matthias Clasen's avatar
Matthias Clasen committed
139
GType        gtk_tree_path_get_type         (void) G_GNUC_CONST;
140 141 142
gint         gtk_tree_path_compare          (const GtkTreePath *a,
					     const GtkTreePath *b);
void         gtk_tree_path_next             (GtkTreePath       *path);
143 144
gboolean     gtk_tree_path_prev             (GtkTreePath       *path);
gboolean     gtk_tree_path_up               (GtkTreePath       *path);
145 146
void         gtk_tree_path_down             (GtkTreePath       *path);

147 148 149 150 151
gboolean     gtk_tree_path_is_ancestor      (GtkTreePath       *path,
                                             GtkTreePath       *descendant);
gboolean     gtk_tree_path_is_descendant    (GtkTreePath       *path,
                                             GtkTreePath       *ancestor);

152 153 154 155
#ifndef GTK_DISABLE_DEPRECATED
#define gtk_tree_path_new_root() gtk_tree_path_new_first()
#endif /* !GTK_DISABLE_DEPRECATED */

156 157 158
/* Row reference (an object that tracks model changes so it refers to the same
 * row always; a path refers to a position, not a fixed row).  You almost always
 * want to call gtk_tree_row_reference_new.
159 160
 */

Matthias Clasen's avatar
Matthias Clasen committed
161
GType                gtk_tree_row_reference_get_type (void) G_GNUC_CONST;
162 163 164 165 166 167
GtkTreeRowReference *gtk_tree_row_reference_new       (GtkTreeModel        *model,
						       GtkTreePath         *path);
GtkTreeRowReference *gtk_tree_row_reference_new_proxy (GObject             *proxy,
						       GtkTreeModel        *model,
						       GtkTreePath         *path);
GtkTreePath         *gtk_tree_row_reference_get_path  (GtkTreeRowReference *reference);
168
GtkTreeModel        *gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
169
gboolean             gtk_tree_row_reference_valid     (GtkTreeRowReference *reference);
170
GtkTreeRowReference *gtk_tree_row_reference_copy      (GtkTreeRowReference *reference);
171 172 173 174 175 176 177
void                 gtk_tree_row_reference_free      (GtkTreeRowReference *reference);
/* These two functions are only needed if you created the row reference with a
 * proxy object */
void                 gtk_tree_row_reference_inserted  (GObject     *proxy,
						       GtkTreePath *path);
void                 gtk_tree_row_reference_deleted   (GObject     *proxy,
						       GtkTreePath *path);
178 179 180 181
void                 gtk_tree_row_reference_reordered (GObject     *proxy,
						       GtkTreePath *path,
						       GtkTreeIter *iter,
						       gint        *new_order);
182

183
/* GtkTreeIter operations */
184 185
GtkTreeIter *     gtk_tree_iter_copy             (GtkTreeIter  *iter);
void              gtk_tree_iter_free             (GtkTreeIter  *iter);
Matthias Clasen's avatar
Matthias Clasen committed
186
GType             gtk_tree_iter_get_type         (void) G_GNUC_CONST;
187

Manish Singh's avatar
Manish Singh committed
188
GType             gtk_tree_model_get_type        (void) G_GNUC_CONST;
189 190 191
GtkTreeModelFlags gtk_tree_model_get_flags       (GtkTreeModel *tree_model);
gint              gtk_tree_model_get_n_columns   (GtkTreeModel *tree_model);
GType             gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
192
						  gint          index_);
193 194 195


/* Iterator movement */
196 197
gboolean          gtk_tree_model_get_iter        (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
198
						  GtkTreePath  *path);
199 200
gboolean          gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model,
						       GtkTreeIter  *iter,
201
						       const gchar  *path_string);
202 203
gchar *           gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model,
                                                       GtkTreeIter  *iter);
204
gboolean          gtk_tree_model_get_iter_first  (GtkTreeModel *tree_model,
205
						  GtkTreeIter  *iter);
206 207 208 209 210 211 212
GtkTreePath *     gtk_tree_model_get_path        (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter);
void              gtk_tree_model_get_value       (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
						  gint          column,
						  GValue       *value);
gboolean          gtk_tree_model_iter_next       (GtkTreeModel *tree_model,
213
						  GtkTreeIter  *iter);
214 215
gboolean          gtk_tree_model_iter_children   (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
216
						  GtkTreeIter  *parent);
217 218 219 220 221 222 223
gboolean          gtk_tree_model_iter_has_child  (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter);
gint              gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter);
gboolean          gtk_tree_model_iter_nth_child  (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
						  GtkTreeIter  *parent,
224
						  gint          n);
225 226
gboolean          gtk_tree_model_iter_parent     (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
227
						  GtkTreeIter  *child);
228
void              gtk_tree_model_ref_node        (GtkTreeModel *tree_model,
229
						  GtkTreeIter  *iter);
230
void              gtk_tree_model_unref_node      (GtkTreeModel *tree_model,
231 232 233 234 235 236 237 238
						  GtkTreeIter  *iter);
void              gtk_tree_model_get             (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
						  ...);
void              gtk_tree_model_get_valist      (GtkTreeModel *tree_model,
						  GtkTreeIter  *iter,
						  va_list       var_args);

239

240 241 242 243 244
void              gtk_tree_model_foreach         (GtkTreeModel            *model,
						  GtkTreeModelForeachFunc  func,
						  gpointer                 user_data);


245 246 247 248
#ifndef GTK_DISABLE_DEPRECATED
#define gtk_tree_model_get_iter_root(tree_model, iter) gtk_tree_model_get_iter_first(tree_model, iter)
#endif /* !GTK_DISABLE_DEPRECATED */

249
/* Signals */
250
void gtk_tree_model_row_changed           (GtkTreeModel *tree_model,
Jonathan Blandford's avatar
Jonathan Blandford committed
251 252
					   GtkTreePath  *path,
					   GtkTreeIter  *iter);
253 254 255 256 257 258 259 260 261 262 263 264 265
void gtk_tree_model_row_inserted          (GtkTreeModel *tree_model,
					   GtkTreePath  *path,
					   GtkTreeIter  *iter);
void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model,
					   GtkTreePath  *path,
					   GtkTreeIter  *iter);
void gtk_tree_model_row_deleted           (GtkTreeModel *tree_model,
					   GtkTreePath  *path);
void gtk_tree_model_rows_reordered        (GtkTreeModel *tree_model,
					   GtkTreePath  *path,
					   GtkTreeIter  *iter,
					   gint         *new_order);

266
G_END_DECLS
267 268

#endif /* __GTK_TREE_MODEL_H__ */