]> Pileus Git - ~andy/gtk/blob - gtk/gtktreemodelfilter.h
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __GTK_TREE_MODEL_FILTER_H__
20 #define __GTK_TREE_MODEL_FILTER_H__
21
22 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
24 #endif
25
26 #include <gtk/gtktreemodel.h>
27
28 G_BEGIN_DECLS
29
30 #define GTK_TYPE_TREE_MODEL_FILTER              (gtk_tree_model_filter_get_type ())
31 #define GTK_TREE_MODEL_FILTER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilter))
32 #define GTK_TREE_MODEL_FILTER_CLASS(vtable)     (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilterClass))
33 #define GTK_IS_TREE_MODEL_FILTER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL_FILTER))
34 #define GTK_IS_TREE_MODEL_FILTER_CLASS(vtable)  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_TREE_MODEL_FILTER))
35 #define GTK_TREE_MODEL_FILTER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_MODEL_FILTER, GtkTreeModelFilterClass))
36
37 /**
38  * GtkTreeModelFilterVisibleFunc:
39  * @model: the child model of the #GtkTreeModelFilter
40  * @iter: a #GtkTreeIter pointing to the row in @model whose visibility
41  *   is determined
42  * @data: (closure): user data given to gtk_tree_model_filter_set_visible_func()
43  *
44  * A function which decides whether the row indicated by @iter is visible.
45  *
46  * Returns: Whether the row indicated by @iter is visible.
47  */
48 typedef gboolean (* GtkTreeModelFilterVisibleFunc) (GtkTreeModel *model,
49                                                     GtkTreeIter  *iter,
50                                                     gpointer      data);
51
52 /**
53  * GtkTreeModelFilterModifyFunc:
54  * @model: the #GtkTreeModelFilter
55  * @iter: a #GtkTreeIter pointing to the row whose display values are determined
56  * @value: A #GValue which is already initialized for with the correct type for
57  *  the column @column.
58  * @column: the column whose display value is determined
59  * @data: (closure): user data given to gtk_tree_model_filter_set_modify_func()
60  *
61  * A function which calculates display values from raw values in the model.
62  * It must fill @value with the display value for the column @column in the
63  * row indicated by @iter.
64  *
65  * Since this function is called for each data access, it's not a
66  * particularly efficient operation.
67  */
68
69 typedef void (* GtkTreeModelFilterModifyFunc) (GtkTreeModel *model,
70                                                GtkTreeIter  *iter,
71                                                GValue       *value,
72                                                gint          column,
73                                                gpointer      data);
74
75 typedef struct _GtkTreeModelFilter          GtkTreeModelFilter;
76 typedef struct _GtkTreeModelFilterClass     GtkTreeModelFilterClass;
77 typedef struct _GtkTreeModelFilterPrivate   GtkTreeModelFilterPrivate;
78
79 struct _GtkTreeModelFilter
80 {
81   GObject parent;
82
83   /*< private >*/
84   GtkTreeModelFilterPrivate *priv;
85 };
86
87 struct _GtkTreeModelFilterClass
88 {
89   GObjectClass parent_class;
90
91   gboolean (* visible) (GtkTreeModelFilter *self,
92                         GtkTreeModel       *child_model,
93                         GtkTreeIter        *iter);
94   void (* modify) (GtkTreeModelFilter *self,
95                    GtkTreeModel       *child_model,
96                    GtkTreeIter        *iter,
97                    GValue             *value,
98                    gint                column);
99
100   /* Padding for future expansion */
101   void (*_gtk_reserved1) (void);
102   void (*_gtk_reserved2) (void);
103   void (*_gtk_reserved3) (void);
104   void (*_gtk_reserved4) (void);
105 };
106
107 /* base */
108 GType         gtk_tree_model_filter_get_type                   (void) G_GNUC_CONST;
109 GtkTreeModel *gtk_tree_model_filter_new                        (GtkTreeModel                 *child_model,
110                                                                 GtkTreePath                  *root);
111 void          gtk_tree_model_filter_set_visible_func           (GtkTreeModelFilter           *filter,
112                                                                 GtkTreeModelFilterVisibleFunc func,
113                                                                 gpointer                      data,
114                                                                 GDestroyNotify                destroy);
115 void          gtk_tree_model_filter_set_modify_func            (GtkTreeModelFilter           *filter,
116                                                                 gint                          n_columns,
117                                                                 GType                        *types,
118                                                                 GtkTreeModelFilterModifyFunc  func,
119                                                                 gpointer                      data,
120                                                                 GDestroyNotify                destroy);
121 void          gtk_tree_model_filter_set_visible_column         (GtkTreeModelFilter           *filter,
122                                                                 gint                          column);
123
124 GtkTreeModel *gtk_tree_model_filter_get_model                  (GtkTreeModelFilter           *filter);
125
126 /* conversion */
127 gboolean      gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter           *filter,
128                                                                 GtkTreeIter                  *filter_iter,
129                                                                 GtkTreeIter                  *child_iter);
130 void          gtk_tree_model_filter_convert_iter_to_child_iter (GtkTreeModelFilter           *filter,
131                                                                 GtkTreeIter                  *child_iter,
132                                                                 GtkTreeIter                  *filter_iter);
133 GtkTreePath  *gtk_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter           *filter,
134                                                                 GtkTreePath                  *child_path);
135 GtkTreePath  *gtk_tree_model_filter_convert_path_to_child_path (GtkTreeModelFilter           *filter,
136                                                                 GtkTreePath                  *filter_path);
137
138 /* extras */
139 void          gtk_tree_model_filter_refilter                   (GtkTreeModelFilter           *filter);
140 void          gtk_tree_model_filter_clear_cache                (GtkTreeModelFilter           *filter);
141
142 G_END_DECLS
143
144 #endif /* __GTK_TREE_MODEL_FILTER_H__ */