summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkcssmatcher.c40
-rw-r--r--gtk/gtkcssmatcherprivate.h10
-rw-r--r--gtk/gtkcssselector.c2
3 files changed, 33 insertions, 19 deletions
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index d371bd87ec..cb9f7338d8 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -73,11 +73,15 @@ gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
}
static gboolean
-gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher,
- GType type)
+gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
+ /*interned*/ const char *name,
+ GType type)
{
const GtkWidgetPath *siblings;
+ if (type == 0)
+ return FALSE;
+
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);
@@ -215,7 +219,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
gtk_css_matcher_widget_path_get_parent,
gtk_css_matcher_widget_path_get_previous,
gtk_css_matcher_widget_path_get_state,
- gtk_css_matcher_widget_path_has_type,
+ gtk_css_matcher_widget_path_has_name,
gtk_css_matcher_widget_path_has_class,
gtk_css_matcher_widget_path_has_id,
gtk_css_matcher_widget_path_has_regions,
@@ -296,10 +300,16 @@ gtk_css_matcher_node_get_state (const GtkCssMatcher *matcher)
}
static gboolean
-gtk_css_matcher_node_has_type (const GtkCssMatcher *matcher,
- GType type)
+gtk_css_matcher_node_has_name (const GtkCssMatcher *matcher,
+ /*interned*/ const char *name,
+ GType type)
{
- return g_type_is_a (gtk_css_node_get_widget_type (matcher->node.node), type);
+ const char *node_name = gtk_css_node_get_name (matcher->node.node);
+
+ if (node_name == NULL)
+ return g_type_is_a (gtk_css_node_get_widget_type (matcher->node.node), type);
+
+ return node_name == name;
}
static gboolean
@@ -401,7 +411,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
gtk_css_matcher_node_get_parent,
gtk_css_matcher_node_get_previous,
gtk_css_matcher_node_get_state,
- gtk_css_matcher_node_has_type,
+ gtk_css_matcher_node_has_name,
gtk_css_matcher_node_has_class,
gtk_css_matcher_node_has_id,
gtk_css_matcher_node_has_regions,
@@ -450,8 +460,9 @@ gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher)
}
static gboolean
-gtk_css_matcher_any_has_type (const GtkCssMatcher *matcher,
- GType type)
+gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher,
+ /*interned*/ const char *name,
+ GType type)
{
return TRUE;
}
@@ -497,7 +508,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
gtk_css_matcher_any_get_parent,
gtk_css_matcher_any_get_previous,
gtk_css_matcher_any_get_state,
- gtk_css_matcher_any_has_type,
+ gtk_css_matcher_any_has_name,
gtk_css_matcher_any_has_class,
gtk_css_matcher_any_has_id,
gtk_css_matcher_any_has_regions,
@@ -547,11 +558,12 @@ gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
}
static gboolean
-gtk_css_matcher_superset_has_type (const GtkCssMatcher *matcher,
- GType type)
+gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
+ /*interned*/ const char *name,
+ GType type)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
- return _gtk_css_matcher_has_type (matcher->superset.subset, type);
+ return _gtk_css_matcher_has_name (matcher->superset.subset, name, type);
else
return TRUE;
}
@@ -617,7 +629,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
gtk_css_matcher_superset_get_parent,
gtk_css_matcher_superset_get_previous,
gtk_css_matcher_superset_get_state,
- gtk_css_matcher_superset_has_type,
+ gtk_css_matcher_superset_has_name,
gtk_css_matcher_superset_has_class,
gtk_css_matcher_superset_has_id,
gtk_css_matcher_superset_has_regions,
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
index 1a788f3565..dce57b28a8 100644
--- a/gtk/gtkcssmatcherprivate.h
+++ b/gtk/gtkcssmatcherprivate.h
@@ -36,7 +36,8 @@ struct _GtkCssMatcherClass {
const GtkCssMatcher *next);
GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
- gboolean (* has_type) (const GtkCssMatcher *matcher,
+ gboolean (* has_name) (const GtkCssMatcher *matcher,
+ /*interned*/const char*name,
GType type);
gboolean (* has_class) (const GtkCssMatcher *matcher,
GQuark class_name);
@@ -111,10 +112,11 @@ _gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
}
static inline gboolean
-_gtk_css_matcher_has_type (const GtkCssMatcher *matcher,
- GType type)
+_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
+ /*interned*/ const char *name,
+ GType type)
{
- return matcher->klass->has_type (matcher, type);
+ return matcher->klass->has_name (matcher, name, type);
}
static inline gboolean
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index e987aa1292..ea4f252529 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -690,7 +690,7 @@ static gboolean
match_name (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
{
- return _gtk_css_matcher_has_type (matcher, selector->name.reference->type);
+ return _gtk_css_matcher_has_name (matcher, selector->name.reference->name, selector->name.reference->type);
}
static guint