]> Pileus Git - ~andy/gtk/blob - gtk/gtktreemodelfilter.h
1dc097a5d8c320275aa8a886a10fce6dbdf9aed4
[~andy/gtk] / gtk / gtktreemodelfilter.h
1 /* gtktreemodelfilter.h
2  * Copyright (C) 2000,2001  Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
3  * Copyright (C) 2001-2003  Kristian Rietveld <kris@gtk.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #ifndef __GTK_TREE_MODEL_FILTER_H__
26 #define __GTK_TREE_MODEL_FILTER_H__
27
28 #include <gdkconfig.h>
29 #include <gtk/gtktreemodel.h>
30
31 G_BEGIN_DECLS
32
33 #define GTK_TYPE_TREE_MODEL_FILTER              (gtk_tree_model_filter_get_type ())
34 #define GTK_TREE_MODEL_FILTER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilter))
35 #define GTK_TREE_MODEL_FILTER_CLASS(vtable)     (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilterClass))
36 #define GTK_IS_TREE_MODEL_FILTER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL_FILTER))
37 #define GTK_IS_TREE_MODEL_FILTER_CLASS(vtable)  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_TREE_MODEL_FILTER))
38 #define GTK_TREE_MODEL_FILTER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilterClass))
39
40 /**
41  * GtkTreeModelFilterVisibleFunc:
42  * @model: the child model of the #GtkTreeModelFilter
43  * @iter: a #GtkTreeIter pointing to the row in @model whose visibility
44  *   is determined
45  * @data: user data given to gtk_tree_model_filter_set_visible_func()
46  *
47  * A function which decides whether the row indicated by @iter is visible.
48  *
49  * Returns: Whether the row indicated by @iter is visible.
50  */
51 typedef gboolean (* GtkTreeModelFilterVisibleFunc) (GtkTreeModel *model,
52                                                     GtkTreeIter  *iter,
53                                                     gpointer      data);
54
55 /**
56  * GtkTreeModelFilterModifyFunc:
57  * @model: the #GtkTreeModelFilter
58  * @iter: a #GtkTreeIter pointing to the row whose display values are determined
59  * @value: A #GValue which is already initialized for with the correct type for
60  *  the column @column.
61  * @column: the column whose display value is determined
62  * @data: user data given to gtk_tree_model_filter_set_modify_func()
63  *
64  * A function which calculates display values from raw values in the model.
65  * It must fill @value with the display value for the column @column in the
66  * row indicated by @iter.
67  *
68  * Since this function is called for each data access, it's not a
69  * particularly efficient operation.
70  */
71
72 typedef void (* GtkTreeModelFilterModifyFunc) (GtkTreeModel *model,
73                                                GtkTreeIter  *iter,
74                                                GValue       *value,
75                                                gint          column,
76                                                gpointer      data);
77
78 typedef struct _GtkTreeModelFilter          GtkTreeModelFilter;
79 typedef struct _GtkTreeModelFilterClass     GtkTreeModelFilterClass;
80 typedef struct _GtkTreeModelFilterPrivate   GtkTreeModelFilterPrivate;
81
82 struct _GtkTreeModelFilter
83 {
84   GObject parent;
85
86   /*< private >*/
87   GtkTreeModelFilterPrivate *priv;
88 };
89
90 struct _GtkTreeModelFilterClass
91 {
92   GObjectClass parent_class;
93
94   gboolean (* visible) (GtkTreeModelFilter *self,
95                         GtkTreeModel       *child_model,
96                         GtkTreeIter        *iter);
97   void (* modify) (GtkTreeModelFilter *self,
98                    GtkTreeModel       *child_model,
99                    GtkTreeIter        *iter,
100                    GValue             *value,
101                    gint                column);
102
103   /* Padding for future expansion */
104   void (*_gtk_reserved1) (void);
105   void (*_gtk_reserved2) (void);
106   void (*_gtk_reserved3) (void);
107   void (*_gtk_reserved4) (void);
108 };
109
110 /* base */
111 GType         gtk_tree_model_filter_get_type                   (void) G_GNUC_CONST;
112 GtkTreeModel *gtk_tree_model_filter_new                        (GtkTreeModel                 *child_model,
113                                                                 GtkTreePath                  *root);
114 void          gtk_tree_model_filter_set_visible_func           (GtkTreeModelFilter           *filter,
115                                                                 GtkTreeModelFilterVisibleFunc func,
116                                                                 gpointer                      data,
117                                                                 GDestroyNotify                destroy);
118 void          gtk_tree_model_filter_set_modify_func            (GtkTreeModelFilter           *filter,
119                                                                 gint                          n_columns,
120                                                                 GType                        *types,
121                                                                 GtkTreeModelFilterModifyFunc  func,
122                                                                 gpointer                      data,
123                                                                 GDestroyNotify                destroy);
124 void          gtk_tree_model_filter_set_visible_column         (GtkTreeModelFilter           *filter,
125                                                                 gint                          column);
126
127 GtkTreeModel *gtk_tree_model_filter_get_model                  (GtkTreeModelFilter           *filter);
128
129 /* conversion */
130 gboolean      gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter           *filter,
131                                                                 GtkTreeIter                  *filter_iter,
132                                                                 GtkTreeIter                  *child_iter);
133 void          gtk_tree_model_filter_convert_iter_to_child_iter (GtkTreeModelFilter           *filter,
134                                                                 GtkTreeIter                  *child_iter,
135                                                                 GtkTreeIter                  *filter_iter);
136 GtkTreePath  *gtk_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter           *filter,
137                                                                 GtkTreePath                  *child_path);
138 GtkTreePath  *gtk_tree_model_filter_convert_path_to_child_path (GtkTreeModelFilter           *filter,
139                                                                 GtkTreePath                  *filter_path);
140
141 /* extras */
142 void          gtk_tree_model_filter_refilter                   (GtkTreeModelFilter           *filter);
143 void          gtk_tree_model_filter_clear_cache                (GtkTreeModelFilter           *filter);
144
145 G_END_DECLS
146
147 #endif /* __GTK_TREE_MODEL_FILTER_H__ */