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