cssmatcher: Marshal name to matcher

... and use it in the node matcher.

Also rename function from _gtk_css_matcher_get_type() to
_gtk_css_matcher_get_name().
This commit is contained in:
Benjamin Otte 2015-09-05 06:39:10 +02:00
parent efff9c8edb
commit 385fda80b4
3 changed files with 33 additions and 19 deletions

View File

@ -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,

View File

@ -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

View File

@ -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