1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
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 of the License, or (at your option) any later version.
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.
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/>.
18 #ifndef __GTK_CSS_MATCHER_PRIVATE_H__
19 #define __GTK_CSS_MATCHER_PRIVATE_H__
21 #include <gtk/gtkenums.h>
22 #include <gtk/gtktypes.h>
23 #include "gtk/gtkcsstypesprivate.h"
27 typedef union _GtkCssMatcher GtkCssMatcher;
28 typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
29 typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
30 typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
32 struct _GtkCssMatcherClass {
33 gboolean (* get_parent) (GtkCssMatcher *matcher,
34 const GtkCssMatcher *child);
35 gboolean (* get_previous) (GtkCssMatcher *matcher,
36 const GtkCssMatcher *next);
38 GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
39 gboolean (* has_type) (const GtkCssMatcher *matcher,
41 gboolean (* has_class) (const GtkCssMatcher *matcher,
43 gboolean (* has_id) (const GtkCssMatcher *matcher,
45 gboolean (* has_regions) (const GtkCssMatcher *matcher);
46 gboolean (* has_region) (const GtkCssMatcher *matcher,
48 GtkRegionFlags flags);
49 gboolean (* has_position) (const GtkCssMatcher *matcher,
56 struct _GtkCssMatcherWidgetPath {
57 const GtkCssMatcherClass *klass;
58 const GtkWidgetPath *path;
59 GtkStateFlags state_flags;
64 struct _GtkCssMatcherSuperset {
65 const GtkCssMatcherClass *klass;
66 const GtkCssMatcher *subset;
67 GtkCssChange relevant;
70 union _GtkCssMatcher {
71 const GtkCssMatcherClass *klass;
72 GtkCssMatcherWidgetPath path;
73 GtkCssMatcherSuperset superset;
76 gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
77 const GtkWidgetPath *path,
78 GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT;
79 void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
80 void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
81 const GtkCssMatcher *subset,
82 GtkCssChange relevant);
85 static inline gboolean
86 _gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
87 const GtkCssMatcher *child)
89 return child->klass->get_parent (matcher, child);
92 static inline gboolean
93 _gtk_css_matcher_get_previous (GtkCssMatcher *matcher,
94 const GtkCssMatcher *next)
96 return next->klass->get_previous (matcher, next);
99 static inline GtkStateFlags
100 _gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
102 return matcher->klass->get_state (matcher);
105 static inline gboolean
106 _gtk_css_matcher_has_type (const GtkCssMatcher *matcher,
109 return matcher->klass->has_type (matcher, type);
112 static inline gboolean
113 _gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
116 return matcher->klass->has_class (matcher, class_name);
119 static inline gboolean
120 _gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
123 return matcher->klass->has_id (matcher, id);
127 static inline gboolean
128 _gtk_css_matcher_has_regions (const GtkCssMatcher *matcher)
130 return matcher->klass->has_regions (matcher);
133 static inline gboolean
134 _gtk_css_matcher_has_region (const GtkCssMatcher *matcher,
136 GtkRegionFlags flags)
138 return matcher->klass->has_region (matcher, region, flags);
142 _gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
147 return matcher->klass->has_position (matcher, forward, a, b);
150 static inline gboolean
151 _gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
153 return matcher->klass->is_any;
159 #endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */