diff options
author | Benjamin Otte <otte@redhat.com> | 2012-03-17 14:32:52 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:07 +0200 |
commit | 53317aed55da7c48f27d1a0ed8be1cc04cb2f8f2 (patch) | |
tree | 115273940837cd09a90bf0e20ef76abf94d8b2ad /gtk/gtkcssmatcher.c | |
parent | b368c5f10aecc3c6fb9f0a09e9eaace3fd1c95dc (diff) | |
download | gtk+-53317aed55da7c48f27d1a0ed8be1cc04cb2f8f2.tar.gz |
matcher: Turn GtkCssMatcher into a union
That way, we can add more matchers as we need them.
Diffstat (limited to 'gtk/gtkcssmatcher.c')
-rw-r--r-- | gtk/gtkcssmatcher.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c index e796cfcee2..053280fac7 100644 --- a/gtk/gtkcssmatcher.c +++ b/gtk/gtkcssmatcher.c @@ -21,18 +21,20 @@ #include "gtkwidgetpath.h" +/* GTK_CSS_MATCHER_WIDGET_PATH */ + static gboolean gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher, const GtkCssMatcher *child) { - if (child->index == 0) + if (child->path.index == 0) return FALSE; - matcher->klass = child->klass; - matcher->path = child->path; - matcher->state_flags = 0; - matcher->index = child->index - 1; - matcher->sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index); + matcher->path.klass = child->path.klass; + matcher->path.path = child->path.path; + matcher->path.state_flags = 0; + matcher->path.index = child->path.index - 1; + matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index); return TRUE; } @@ -41,14 +43,14 @@ static gboolean gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher, const GtkCssMatcher *next) { - if (next->sibling_index == 0) + if (next->path.sibling_index == 0) return FALSE; - matcher->klass = next->klass; - matcher->path = next->path; - matcher->state_flags = 0; - matcher->index = next->index; - matcher->sibling_index = next->sibling_index - 1; + matcher->path.klass = next->path.klass; + matcher->path.path = next->path.path; + matcher->path.state_flags = 0; + matcher->path.index = next->path.index; + matcher->path.sibling_index = next->path.sibling_index - 1; return TRUE; } @@ -56,7 +58,7 @@ gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher, static GtkStateFlags gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher) { - return matcher->state_flags; + return matcher->path.state_flags; } static gboolean @@ -67,11 +69,11 @@ gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher, GType type; type = g_type_from_name (name); - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); - if (siblings && matcher->sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index)) - return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->sibling_index), type); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); + if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) + return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type); else - return g_type_is_a (gtk_widget_path_iter_get_object_type (matcher->path, matcher->index), type); + return g_type_is_a (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index), type); } static gboolean @@ -80,11 +82,11 @@ gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher, { const GtkWidgetPath *siblings; - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); - if (siblings && matcher->sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index)) - return gtk_widget_path_iter_has_class (siblings, matcher->sibling_index, class_name); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); + if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) + return gtk_widget_path_iter_has_class (siblings, matcher->path.sibling_index, class_name); else - return gtk_widget_path_iter_has_class (matcher->path, matcher->index, class_name); + return gtk_widget_path_iter_has_class (matcher->path.path, matcher->path.index, class_name); } static gboolean @@ -93,11 +95,11 @@ gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher, { const GtkWidgetPath *siblings; - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); - if (siblings && matcher->sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index)) - return gtk_widget_path_iter_has_name (siblings, matcher->sibling_index, id); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); + if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) + return gtk_widget_path_iter_has_name (siblings, matcher->path.sibling_index, id); else - return gtk_widget_path_iter_has_name (matcher->path, matcher->index, id); + return gtk_widget_path_iter_has_name (matcher->path.path, matcher->path.index, id); } static gboolean @@ -107,11 +109,11 @@ gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher) GSList *regions; gboolean result; - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); - if (siblings && matcher->sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index)) - regions = gtk_widget_path_iter_list_regions (siblings, matcher->sibling_index); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); + if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) + regions = gtk_widget_path_iter_list_regions (siblings, matcher->path.sibling_index); else - regions = gtk_widget_path_iter_list_regions (matcher->path, matcher->index); + regions = gtk_widget_path_iter_list_regions (matcher->path.path, matcher->path.index); result = regions != NULL; g_slist_free (regions); @@ -126,15 +128,15 @@ gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher, const GtkWidgetPath *siblings; GtkRegionFlags region_flags; - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); - if (siblings && matcher->sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path, matcher->index)) + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); + if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) { - if (!gtk_widget_path_iter_has_region (siblings, matcher->sibling_index, region, ®ion_flags)) + if (!gtk_widget_path_iter_has_region (siblings, matcher->path.sibling_index, region, ®ion_flags)) return FALSE; } else { - if (!gtk_widget_path_iter_has_region (matcher->path, matcher->index, region, ®ion_flags)) + if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, ®ion_flags)) return FALSE; } @@ -147,7 +149,7 @@ gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher, static guint gtk_css_matcher_widget_path_get_sibling_index (const GtkCssMatcher *matcher) { - return matcher->sibling_index; + return matcher->path.sibling_index; } static guint @@ -155,7 +157,7 @@ gtk_css_matcher_widget_path_get_n_siblings (const GtkCssMatcher *matcher) { const GtkWidgetPath *siblings; - siblings = gtk_widget_path_iter_get_siblings (matcher->path, matcher->index); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); if (!siblings) return 0; @@ -180,10 +182,10 @@ _gtk_css_matcher_init (GtkCssMatcher *matcher, const GtkWidgetPath *path, GtkStateFlags state) { - matcher->klass = >K_CSS_MATCHER_WIDGET_PATH; - matcher->path = path; - matcher->state_flags = state; - matcher->index = gtk_widget_path_length (path) - 1; - matcher->sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->index); + matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH; + matcher->path.path = path; + matcher->path.state_flags = state; + matcher->path.index = gtk_widget_path_length (path) - 1; + matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index); } |