[gtk+/wip/otte/tokenizer: 12/42] cssdeclaration: Store the style property



commit 24a1591a9bbe4d39be9488595306a393f353b4f9
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 15 03:06:18 2016 +0100

    cssdeclaration: Store the style property
    
    That way, we can error if a property name isn't valid.

 gtk/gtkcssdeclaration.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssdeclaration.c b/gtk/gtkcssdeclaration.c
index 50245d9..319c1fa 100644
--- a/gtk/gtkcssdeclaration.c
+++ b/gtk/gtkcssdeclaration.c
@@ -21,10 +21,13 @@
 
 #include "gtkcssdeclarationprivate.h"
 
+#include "gtkstylepropertyprivate.h"
+
 typedef struct _GtkCssDeclarationPrivate GtkCssDeclarationPrivate;
 struct _GtkCssDeclarationPrivate {
   GtkCssStyleDeclaration *style;
   char *name;
+  GtkStyleProperty *prop;
   char *value;
 };
 
@@ -86,15 +89,24 @@ gtk_css_declaration_new_parse (GtkCssStyleDeclaration *style,
 
   gtk_css_token_source_set_consumer (source, G_OBJECT (decl));
 
+  gtk_css_token_source_consume_whitespace (source);
   priv->style = style;
   token = gtk_css_token_source_get_token (source);
   if (!gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
     {
+      gtk_css_token_source_error (source, "Expected a property name");
       gtk_css_token_source_consume_all (source);
       g_object_unref (decl);
       return NULL;
     }
   priv->name = g_strdup (token->string.string);
+  priv->prop = _gtk_style_property_lookup (priv->name);
+  if (priv->prop == NULL)
+    gtk_css_token_source_unknown (source, "Unknown property name '%s'", priv->name);
+  else if (!g_str_equal (priv->name, _gtk_style_property_get_name (priv->prop)))
+    gtk_css_token_source_deprecated (source,
+                                     "The '%s' property has been renamed to '%s'",
+                                     priv->name, _gtk_style_property_get_name (priv->prop));
   gtk_css_token_source_consume_token (source);
   gtk_css_token_source_consume_whitespace (source);
   token = gtk_css_token_source_get_token (source);


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