1 | /* |
2 | * Copyright © 2019 Benjamin Otte |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 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 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | * |
17 | * Authors: Benjamin Otte <otte@gnome.org> |
18 | */ |
19 | |
20 | #ifndef __GTK_FILTER_H__ |
21 | #define __GTK_FILTER_H__ |
22 | |
23 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
24 | #error "Only <gtk/gtk.h> can be included directly." |
25 | #endif |
26 | |
27 | #include <gdk/gdk.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | /** |
32 | * GtkFilterMatch: |
33 | * @GTK_FILTER_MATCH_SOME: The filter matches some items, |
34 | * gtk_filter_match() may return %TRUE or %FALSE |
35 | * @GTK_FILTER_MATCH_NONE: The filter does not match any item, |
36 | * gtk_filter_match() will always return %FALSE. |
37 | * @GTK_FILTER_MATCH_ALL: The filter matches all items, |
38 | * gtk_filter_match() will alays return %TRUE. |
39 | * |
40 | * Describes the known strictness of a filter. |
41 | * |
42 | * Note that for filters where the strictness is not known, |
43 | * %GTK_FILTER_MATCH_SOME is always an acceptable value, |
44 | * even if a filter does match all or no items. |
45 | */ |
46 | typedef enum { |
47 | GTK_FILTER_MATCH_SOME = 0, |
48 | GTK_FILTER_MATCH_NONE, |
49 | GTK_FILTER_MATCH_ALL |
50 | } GtkFilterMatch; |
51 | |
52 | /** |
53 | * GtkFilterChange: |
54 | * @GTK_FILTER_CHANGE_DIFFERENT: The filter change cannot be |
55 | * described with any of the other enumeration values. |
56 | * @GTK_FILTER_CHANGE_LESS_STRICT: The filter is less strict than |
57 | * it was before: All items that it used to return %TRUE for |
58 | * still return %TRUE, others now may, too. |
59 | * @GTK_FILTER_CHANGE_MORE_STRICT: The filter is more strict than |
60 | * it was before: All items that it used to return %FALSE for |
61 | * still return %FALSE, others now may, too. |
62 | * |
63 | * Describes changes in a filter in more detail and allows objects |
64 | * using the filter to optimize refiltering items. |
65 | * |
66 | * If you are writing an implementation and are not sure which |
67 | * value to pass, %GTK_FILTER_CHANGE_DIFFERENT is always a correct |
68 | * choice. |
69 | */ |
70 | typedef enum { |
71 | GTK_FILTER_CHANGE_DIFFERENT = 0, |
72 | GTK_FILTER_CHANGE_LESS_STRICT, |
73 | GTK_FILTER_CHANGE_MORE_STRICT, |
74 | } GtkFilterChange; |
75 | |
76 | #define GTK_TYPE_FILTER (gtk_filter_get_type ()) |
77 | |
78 | GDK_AVAILABLE_IN_ALL |
79 | G_DECLARE_DERIVABLE_TYPE (GtkFilter, gtk_filter, GTK, FILTER, GObject) |
80 | |
81 | struct _GtkFilterClass |
82 | { |
83 | GObjectClass parent_class; |
84 | |
85 | gboolean (* match) (GtkFilter *self, |
86 | gpointer item); |
87 | |
88 | /* optional */ |
89 | GtkFilterMatch (* get_strictness) (GtkFilter *self); |
90 | |
91 | /* Padding for future expansion */ |
92 | void (*_gtk_reserved1) (void); |
93 | void (*_gtk_reserved2) (void); |
94 | void (*_gtk_reserved3) (void); |
95 | void (*_gtk_reserved4) (void); |
96 | void (*_gtk_reserved5) (void); |
97 | void (*_gtk_reserved6) (void); |
98 | void (*_gtk_reserved7) (void); |
99 | void (*_gtk_reserved8) (void); |
100 | }; |
101 | |
102 | GDK_AVAILABLE_IN_ALL |
103 | gboolean gtk_filter_match (GtkFilter *self, |
104 | gpointer item); |
105 | GDK_AVAILABLE_IN_ALL |
106 | GtkFilterMatch gtk_filter_get_strictness (GtkFilter *self); |
107 | |
108 | /* for filter implementations */ |
109 | GDK_AVAILABLE_IN_ALL |
110 | void gtk_filter_changed (GtkFilter *self, |
111 | GtkFilterChange change); |
112 | |
113 | |
114 | G_END_DECLS |
115 | |
116 | #endif /* __GTK_FILTER_H__ */ |
117 | |