]> Pileus Git - ~andy/gtk/blob - gtk/gtktreemodel.h
ec5ba2b28c279b06198b882ceed73b0494c6124e
[~andy/gtk] / gtk / gtktreemodel.h
1 /* gtktreemodel.h
2  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
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 #include <gtk/gtkobject.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 #define GTK_TYPE_TREE_MODEL            (gtk_tree_model_get_type ())
30 #define GTK_TREE_MODEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
31 #define GTK_IS_TREE_MODEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL))
32 #define GTK_TREE_MODEL_GET_IFACE(obj)  ((GtkTreeModelIface *)g_type_interface_peek (((GTypeInstance *)GTK_TREE_MODEL (obj))->g_class, GTK_TYPE_TREE_MODEL))
33                                         
34
35 typedef struct _GtkTreeIter       GtkTreeIter;
36 typedef struct _GtkTreePath       GtkTreePath;
37 typedef struct _GtkTreeModel      GtkTreeModel; /* Dummy typedef */
38 typedef struct _GtkTreeModelIface GtkTreeModelIface;
39
40
41 typedef enum
42 {
43   GTK_TREE_MODEL_ITERS_PERSIST = 1 << 0
44 } GtkTreeModelFlags;
45
46 struct _GtkTreeIter
47 {
48   gint stamp;
49   gpointer tree_node;
50   gpointer tree_node2;
51   gpointer tree_node3;
52 };
53
54 struct _GtkTreeModelIface
55 {
56   GTypeInterface g_iface;
57
58   /* Signals */
59   /* Currently unimplemented as interfaces do not support signals yet, so
60    * objects implementing this interface need this.  Later, it will be moved
61    * back here.
62    */
63   void         (* changed)           (GtkTreeModel *tree_model,
64                                       GtkTreePath  *path,
65                                       GtkTreeIter  *iter);
66   void         (* inserted)          (GtkTreeModel *tree_model,
67                                       GtkTreePath  *path,
68                                       GtkTreeIter  *iter);
69   void         (* child_toggled)     (GtkTreeModel *tree_model,
70                                       GtkTreePath  *path,
71                                       GtkTreeIter  *iter);
72   void         (* deleted)           (GtkTreeModel *tree_model,
73                                       GtkTreePath  *path);
74
75   /* VTable - not signals */
76   guint        (* get_flags)       (GtkTreeModel *tree_model);   
77   gint         (* get_n_columns)   (GtkTreeModel *tree_model);
78   GType        (* get_column_type) (GtkTreeModel *tree_model,
79                                     gint          index);
80   gboolean     (* get_iter)        (GtkTreeModel *tree_model,
81                                     GtkTreeIter  *iter,
82                                     GtkTreePath  *path);
83   GtkTreePath *(* get_path)        (GtkTreeModel *tree_model,
84                                     GtkTreeIter  *iter);
85   void         (* get_value)       (GtkTreeModel *tree_model,
86                                     GtkTreeIter  *iter,
87                                     gint          column,
88                                     GValue       *value);
89   gboolean     (* iter_next)       (GtkTreeModel *tree_model,
90                                     GtkTreeIter  *iter);
91   gboolean     (* iter_children)   (GtkTreeModel *tree_model,
92                                     GtkTreeIter  *iter,
93                                     GtkTreeIter  *parent);
94   gboolean     (* iter_has_child)  (GtkTreeModel *tree_model,
95                                     GtkTreeIter  *iter);
96   gint         (* iter_n_children) (GtkTreeModel *tree_model,
97                                     GtkTreeIter  *iter);
98   gboolean     (* iter_nth_child)  (GtkTreeModel *tree_model,
99                                     GtkTreeIter  *iter,
100                                     GtkTreeIter  *parent,
101                                     gint          n);
102   gboolean     (* iter_parent)     (GtkTreeModel *tree_model,
103                                     GtkTreeIter  *iter,
104                                     GtkTreeIter  *child);
105   void         (* ref_iter)        (GtkTreeModel *tree_model,
106                                     GtkTreeIter  *iter);
107   void         (* unref_iter)      (GtkTreeModel *tree_model,
108                                     GtkTreeIter  *iter);
109 };
110
111
112 /* GtkTreePath operations */
113 GtkTreePath *gtk_tree_path_new              (void);
114 GtkTreePath *gtk_tree_path_new_from_string  (gchar             *path);
115 gchar       *gtk_tree_path_to_string        (GtkTreePath       *path);
116 GtkTreePath *gtk_tree_path_new_root         (void);
117 void         gtk_tree_path_append_index     (GtkTreePath       *path,
118                                              gint               index);
119 void         gtk_tree_path_prepend_index    (GtkTreePath       *path,
120                                              gint               index);
121 gint         gtk_tree_path_get_depth        (GtkTreePath       *path);
122 gint        *gtk_tree_path_get_indices      (GtkTreePath       *path);
123 void         gtk_tree_path_free             (GtkTreePath       *path);
124 GtkTreePath *gtk_tree_path_copy             (GtkTreePath       *path);
125 gint         gtk_tree_path_compare          (const GtkTreePath *a,
126                                              const GtkTreePath *b);
127 void         gtk_tree_path_next             (GtkTreePath       *path);
128 gint         gtk_tree_path_prev             (GtkTreePath       *path);
129 gint         gtk_tree_path_up               (GtkTreePath       *path);
130 void         gtk_tree_path_down             (GtkTreePath       *path);
131
132
133 /* GtkTreeIter operations */
134 GtkTreeIter *gtk_tree_iter_copy             (GtkTreeIter       *iter);
135 void         gtk_tree_iter_free             (GtkTreeIter       *iter);
136
137 /* GtkTreeModel stuff */
138 GtkType      gtk_tree_model_get_type        (void) G_GNUC_CONST;
139 guint        gtk_tree_model_get_flags       (GtkTreeModel      *tree_model);
140
141 /* Column information */
142 gint         gtk_tree_model_get_n_columns   (GtkTreeModel      *tree_model);
143 GType        gtk_tree_model_get_column_type (GtkTreeModel      *tree_model,
144                                              gint               index);
145
146
147 /* Iterator movement */
148 gboolean     gtk_tree_model_get_iter        (GtkTreeModel      *tree_model,
149                                              GtkTreeIter       *iter,
150                                              GtkTreePath       *path);
151 GtkTreePath *gtk_tree_model_get_path        (GtkTreeModel      *tree_model,
152                                              GtkTreeIter       *iter);
153 void         gtk_tree_model_get_value       (GtkTreeModel      *tree_model,
154                                              GtkTreeIter       *iter,
155                                              gint               column,
156                                              GValue            *value);
157 gboolean     gtk_tree_model_iter_next       (GtkTreeModel      *tree_model,
158                                              GtkTreeIter       *iter);
159 gboolean     gtk_tree_model_iter_children   (GtkTreeModel      *tree_model,
160                                              GtkTreeIter       *iter,
161                                              GtkTreeIter       *parent);
162 gboolean     gtk_tree_model_iter_has_child  (GtkTreeModel      *tree_model,
163                                              GtkTreeIter       *iter);
164 gint         gtk_tree_model_iter_n_children (GtkTreeModel      *tree_model,
165                                              GtkTreeIter       *iter);
166 gboolean     gtk_tree_model_iter_nth_child  (GtkTreeModel      *tree_model,
167                                              GtkTreeIter       *iter,
168                                              GtkTreeIter       *parent,
169                                              gint               n);
170 gboolean     gtk_tree_model_iter_parent     (GtkTreeModel      *tree_model,
171                                              GtkTreeIter       *iter,
172                                              GtkTreeIter       *child);
173 void         gtk_tree_model_ref_iter        (GtkTreeModel      *tree_model,
174                                              GtkTreeIter       *iter);
175 void         gtk_tree_model_unref_iter      (GtkTreeModel      *tree_model,
176                                              GtkTreeIter       *iter);
177
178 #ifdef __cplusplus
179 }
180 #endif /* __cplusplus */
181
182
183 #endif /* __GTK_TREE_MODEL_H__ */