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
28G_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 */
48typedef 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: (out caller-allocates): A #GValue which is already initialized for
57 * with the correct type for 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
69typedef void (* GtkTreeModelFilterModifyFunc) (GtkTreeModel *model,
70 GtkTreeIter *iter,
71 GValue *value,
72 gint column,
73 gpointer data);
74
75typedef struct _GtkTreeModelFilter GtkTreeModelFilter;
76typedef struct _GtkTreeModelFilterClass GtkTreeModelFilterClass;
77typedef struct _GtkTreeModelFilterPrivate GtkTreeModelFilterPrivate;
78
79struct _GtkTreeModelFilter
80{
81 GObject parent;
82
83 /*< private >*/
84 GtkTreeModelFilterPrivate *priv;
85};
86
87struct _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 */
108GDK_AVAILABLE_IN_ALL
109GType gtk_tree_model_filter_get_type (void) G_GNUC_CONST;
110GDK_AVAILABLE_IN_ALL
111GtkTreeModel *gtk_tree_model_filter_new (GtkTreeModel *child_model,
112 GtkTreePath *root);
113GDK_AVAILABLE_IN_ALL
114void gtk_tree_model_filter_set_visible_func (GtkTreeModelFilter *filter,
115 GtkTreeModelFilterVisibleFunc func,
116 gpointer data,
117 GDestroyNotify destroy);
118GDK_AVAILABLE_IN_ALL
119void gtk_tree_model_filter_set_modify_func (GtkTreeModelFilter *filter,
120 gint n_columns,
121 GType *types,
122 GtkTreeModelFilterModifyFunc func,
123 gpointer data,
124 GDestroyNotify destroy);
125GDK_AVAILABLE_IN_ALL
126void gtk_tree_model_filter_set_visible_column (GtkTreeModelFilter *filter,
127 gint column);
128
129GDK_AVAILABLE_IN_ALL
130GtkTreeModel *gtk_tree_model_filter_get_model (GtkTreeModelFilter *filter);
131
132/* conversion */
133GDK_AVAILABLE_IN_ALL
134gboolean gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter *filter,
135 GtkTreeIter *filter_iter,
136 GtkTreeIter *child_iter);
137GDK_AVAILABLE_IN_ALL
138void gtk_tree_model_filter_convert_iter_to_child_iter (GtkTreeModelFilter *filter,
139 GtkTreeIter *child_iter,
140 GtkTreeIter *filter_iter);
141GDK_AVAILABLE_IN_ALL
142GtkTreePath *gtk_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter *filter,
143 GtkTreePath *child_path);
144GDK_AVAILABLE_IN_ALL
145GtkTreePath *gtk_tree_model_filter_convert_path_to_child_path (GtkTreeModelFilter *filter,
146 GtkTreePath *filter_path);
147
148/* extras */
149GDK_AVAILABLE_IN_ALL
150void gtk_tree_model_filter_refilter (GtkTreeModelFilter *filter);
151GDK_AVAILABLE_IN_ALL
152void gtk_tree_model_filter_clear_cache (GtkTreeModelFilter *filter);
153
154G_END_DECLS
155
156#endif /* __GTK_TREE_MODEL_FILTER_H__ */
157

source code of include/gtk-3.0/gtk/gtktreemodelfilter.h