static gboolean gtk_css_matcher_widget_path_has_position (const GtkCssMatcher *matcher, gboolean forward, int a, int b) { const GtkWidgetPath *siblings; int x; siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); if (!siblings) return FALSE; if (forward) x = matcher->path.sibling_index + 1; else x = gtk_widget_path_length (siblings) - matcher->path.sibling_index; x -= b; if (a == 0) return x == 0; if (x % a) return FALSE; return x / a > 0; }
static gboolean gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher) { const GtkWidgetPath *siblings; GSList *regions; gboolean result; if (matcher->path.decl) { GList *list = gtk_css_node_declaration_list_regions (matcher->path.decl); if (list) { g_list_free (list); return TRUE; } } G_GNUC_BEGIN_IGNORE_DEPRECATIONS 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.path, matcher->path.index); result = regions != NULL; g_slist_free (regions); return result; G_GNUC_END_IGNORE_DEPRECATIONS }
static gboolean gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher, /*interned*/ const char *name) { const GtkWidgetPath *siblings; 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)) { const char *path_name = gtk_widget_path_iter_get_object_name (siblings, matcher->path.sibling_index); if (path_name == NULL) path_name = g_type_name (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index)); return path_name == name; } else { const char *path_name = gtk_widget_path_iter_get_object_name (matcher->path.path, matcher->path.index); if (path_name == NULL) path_name = g_type_name (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index)); return path_name == name; } }
static gboolean gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher, const char *region, GtkRegionFlags flags) { const GtkWidgetPath *siblings; GtkRegionFlags region_flags; 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->path.sibling_index, region, ®ion_flags)) return FALSE; } else { if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, ®ion_flags)) return FALSE; } if ((flags & region_flags) != flags) return FALSE; return TRUE; }
static gboolean gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher, GType type) { const GtkWidgetPath *siblings; 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.path, matcher->path.index), type); }
static gboolean gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher, const char *id) { const GtkWidgetPath *siblings; 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.path, matcher->path.index, id); }
static gboolean gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher, GQuark class_name) { const GtkWidgetPath *siblings; 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_qclass (siblings, matcher->path.sibling_index, class_name); else return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name); }
static GtkStateFlags gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher) { const GtkWidgetPath *siblings; if (matcher->path.decl) return gtk_css_node_declaration_get_state (matcher->path.decl); 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_get_state (siblings, matcher->path.sibling_index); else return gtk_widget_path_iter_get_state (matcher->path.path, matcher->path.index); }
static gboolean gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher) { const GtkWidgetPath *siblings; GSList *regions; gboolean result; 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.path, matcher->path.index); result = regions != NULL; g_slist_free (regions); return result; }
static gboolean gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher, const char *region, GtkRegionFlags flags) { const GtkWidgetPath *siblings; GtkRegionFlags region_flags; if (matcher->path.decl) { GQuark q = g_quark_try_string (region); if (q && gtk_css_node_declaration_has_region (matcher->path.decl, q, ®ion_flags)) goto found; } G_GNUC_BEGIN_IGNORE_DEPRECATIONS 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->path.sibling_index, region, ®ion_flags)) return FALSE; } else { if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, ®ion_flags)) return FALSE; } G_GNUC_END_IGNORE_DEPRECATIONS found: if ((flags & region_flags) != flags) return FALSE; return TRUE; }