[gtk+/wip/otte/tokenizer: 21/78] css: add token parser for icontheme values



commit 6c72e9423f203b3f82a6266ff5a737dfe7286cc3
Author: Benjamin Otte <otte redhat com>
Date:   Thu Mar 17 03:12:06 2016 +0100

    css: add token parser for icontheme values

 gtk/gtkcssiconthemevalue.c        |   26 ++++++++++++++++++++++++++
 gtk/gtkcssiconthemevalueprivate.h |    2 ++
 gtk/gtkcssstylepropertyimpl.c     |    2 +-
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssiconthemevalue.c b/gtk/gtkcssiconthemevalue.c
index e6633c5..2ae613f 100644
--- a/gtk/gtkcssiconthemevalue.c
+++ b/gtk/gtkcssiconthemevalue.c
@@ -162,6 +162,32 @@ gtk_css_icon_theme_value_parse (GtkCssParser *parser)
   return result;
 }
 
+GtkCssValue *
+gtk_css_icon_theme_value_token_parse (GtkCssTokenSource *source)
+{
+  const GtkCssToken *token = gtk_css_token_source_get_token (source);
+
+  if (gtk_css_token_is (token, GTK_CSS_TOKEN_STRING))
+    {
+      GtkIconTheme *icontheme;
+      GtkCssValue *value;
+      
+      icontheme = gtk_icon_theme_new ();
+      gtk_icon_theme_set_custom_theme (icontheme, token->string.string);
+      value = gtk_css_icon_theme_value_new (icontheme);
+      g_object_unref (icontheme);
+
+      gtk_css_token_source_consume_token (source);
+      return value;
+    }
+  else
+    {
+      gtk_css_token_source_error (source, "Expected a string");
+      gtk_css_token_source_consume_all (source);
+      return NULL;
+    }
+}
+
 GtkIconTheme *
 gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value)
 {
diff --git a/gtk/gtkcssiconthemevalueprivate.h b/gtk/gtkcssiconthemevalueprivate.h
index 420d490..6441533 100644
--- a/gtk/gtkcssiconthemevalueprivate.h
+++ b/gtk/gtkcssiconthemevalueprivate.h
@@ -23,6 +23,7 @@
 #include "gtkicontheme.h"
 
 #include "gtkcssparserprivate.h"
+#include "gtkcsstokensourceprivate.h"
 #include "gtkcssvalueprivate.h"
 
 G_BEGIN_DECLS
@@ -30,6 +31,7 @@ G_BEGIN_DECLS
 GtkCssValue *   gtk_css_icon_theme_value_new            (GtkIconTheme           *icontheme);
 
 GtkCssValue *   gtk_css_icon_theme_value_parse          (GtkCssParser           *parser);
+GtkCssValue *   gtk_css_icon_theme_value_token_parse    (GtkCssTokenSource      *source);
 
 GtkIconTheme *  gtk_css_icon_theme_value_get_icon_theme (GtkCssValue            *value);
 
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 81aca9f..20d019e 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -1445,7 +1445,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
                                           icon_theme_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_icon_theme_value_token_parse,
                                           NULL,
                                           NULL,
                                           gtk_css_icon_theme_value_new (NULL));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]