[gtk+/wip/otte/tokenizer: 33/42] css: Add a token parser for engine values
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/tokenizer: 33/42] css: Add a token parser for engine values
- Date: Sun, 20 Mar 2016 05:03:48 +0000 (UTC)
commit 9a144cd64c3c3fecb86a57fb2efbe035b8e92f25
Author: Benjamin Otte <otte redhat com>
Date: Fri Mar 18 20:36:23 2016 +0100
css: Add a token parser for engine values
gtk/gtkcssenginevalue.c | 34 ++++++++++++++++++++++++++++++++++
gtk/gtkcssenginevalueprivate.h | 2 ++
gtk/gtkcssstylepropertyimpl.c | 2 +-
3 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssenginevalue.c b/gtk/gtkcssenginevalue.c
index 2d9a4da..54f668c 100644
--- a/gtk/gtkcssenginevalue.c
+++ b/gtk/gtkcssenginevalue.c
@@ -130,6 +130,40 @@ _gtk_css_engine_value_parse (GtkCssParser *parser)
return _gtk_css_engine_value_new (engine);
}
+GtkCssValue *
+gtk_css_engine_value_token_parse (GtkCssTokenSource *source)
+{
+ GtkThemingEngine *engine;
+ const GtkCssToken *token;
+
+ token = gtk_css_token_source_get_token (source);
+ if (gtk_css_token_is_ident (token, "none"))
+ {
+ gtk_css_token_source_consume_token (source);
+ return _gtk_css_engine_value_new (gtk_theming_engine_load (NULL));
+ }
+
+ if (!gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
+ {
+ gtk_css_token_source_error (source, "Expected a valid theme name");
+ gtk_css_token_source_consume_all (source);
+ return NULL;
+ }
+
+ engine = gtk_theming_engine_load (token->string.string);
+
+ if (engine == NULL)
+ {
+ gtk_css_token_source_error (source, "Theming engine '%s' not found", token->string.string);
+ gtk_css_token_source_consume_all (source);
+ return NULL;
+ }
+
+ gtk_css_token_source_consume_token (source);
+
+ return _gtk_css_engine_value_new (engine);
+}
+
GtkThemingEngine *
_gtk_css_engine_value_get_engine (const GtkCssValue *value)
{
diff --git a/gtk/gtkcssenginevalueprivate.h b/gtk/gtkcssenginevalueprivate.h
index 36f1101..b926ec4 100644
--- a/gtk/gtkcssenginevalueprivate.h
+++ b/gtk/gtkcssenginevalueprivate.h
@@ -21,6 +21,7 @@
#define __GTK_CSS_ENGINE_VALUE_PRIVATE_H__
#include "gtkcssparserprivate.h"
+#include "gtkcsstokensourceprivate.h"
#include "gtkcssvalueprivate.h"
#include "deprecated/gtkthemingengine.h"
@@ -28,6 +29,7 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_engine_value_new (GtkThemingEngine *engine);
GtkCssValue * _gtk_css_engine_value_parse (GtkCssParser *parser);
+GtkCssValue * gtk_css_engine_value_token_parse (GtkCssTokenSource *source);
GtkThemingEngine * _gtk_css_engine_value_get_engine (const GtkCssValue *engine);
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 8bf9889..6688515 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -2345,7 +2345,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
0,
0,
engine_parse,
- gtk_css_style_property_token_parse_default,
+ (GtkCssStylePropertyTokenParseFunc)
gtk_css_engine_value_token_parse,
engine_query,
engine_assign,
_gtk_css_engine_value_new (gtk_theming_engine_load (NULL)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]