[gtk+] css: Make _gtk_css_selector_matches() take a path length
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Make _gtk_css_selector_matches() take a path length
- Date: Wed, 18 May 2011 20:32:11 +0000 (UTC)
commit d6f00427738906151a0f721217d49ce3b003503e
Author: Benjamin Otte <otte redhat com>
Date: Mon May 16 20:20:55 2011 +0200
css: Make _gtk_css_selector_matches() take a path length
This will be necessary when handling inherit.
gtk/gtkcssprovider.c | 4 ++--
gtk/gtkcssselector.c | 20 +++++++++++++++++---
gtk/gtkcssselectorprivate.h | 3 ++-
3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 2cf49ad..fd2696a 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1123,7 +1123,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
info = g_ptr_array_index (priv->selectors_info, i);
- if (!_gtk_css_selector_matches (info->selector, path))
+ if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
continue;
g_hash_table_iter_init (&iter, info->style);
@@ -1175,7 +1175,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
info = g_ptr_array_index (priv->selectors_info, i);
- if (!_gtk_css_selector_matches (info->selector, path))
+ if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
continue;
selector_state = _gtk_css_selector_get_state_flags (info->selector);
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 3850a9e..35db9ca 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -353,18 +353,32 @@ gtk_css_selector_matches_previous (const GtkCssSelector *selector,
return FALSE;
}
+/**
+ * _gtk_css_selector_matches:
+ * @selector: the selector
+ * @path: the path to check
+ * @length: How many elements of the path are to be used
+ *
+ * Checks if the @selector matches the given @path. If @length is
+ * smaller than the number of elements in @path, it is assumed that
+ * only the first @length element of @path are valid and the rest
+ * does not exist. This is useful for doing parent matches for the
+ * 'inherit' keyword.
+ *
+ * Returns: %TRUE if the selector matches @path
+ **/
gboolean
_gtk_css_selector_matches (const GtkCssSelector *selector,
- /* const */ GtkWidgetPath *path)
+ /* const */ GtkWidgetPath *path,
+ guint length)
{
GSList *list;
- guint length;
gboolean match;
g_return_val_if_fail (selector != NULL, FALSE);
g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (length <= gtk_widget_path_length (path), FALSE);
- length = gtk_widget_path_length (path);
if (length == 0)
return FALSE;
diff --git a/gtk/gtkcssselectorprivate.h b/gtk/gtkcssselectorprivate.h
index 70c5e60..5a15882 100644
--- a/gtk/gtkcssselectorprivate.h
+++ b/gtk/gtkcssselectorprivate.h
@@ -48,7 +48,8 @@ void _gtk_css_selector_print (const GtkCssSelector *sel
GtkStateFlags _gtk_css_selector_get_state_flags (GtkCssSelector *selector);
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
- /* const */ GtkWidgetPath *path);
+ /* const */ GtkWidgetPath *path,
+ guint length);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]