[gtk+] cssprovider: Names starting with -gtk- aren't style props



commit aa6652aac7f6bcf61df111f5ce81c656086e3249
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jun 16 22:13:07 2014 +0200

    cssprovider: Names starting with -gtk- aren't style props
    
    We want to have the "-gtk-" prefix for our custom CSS properties. But
    we also want to parse names starting with a "-" as style properties.
    So make sure that "-gtk-" is treated like a normal property and we emit
    errors when somebody uses it wrong.
    
    This is to catch errors with people typing
      -gtk-iconsource: none;
    instead of the correct
      -gtk-icon-source: none;

 gtk/gtkcssprovider.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 242f1b9..30881be 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2342,6 +2342,18 @@ parse_selector_list (GtkCssScanner *scanner)
   return selectors;
 }
 
+static gboolean
+name_is_style_property (const char *name)
+{
+  if (name[0] != '-')
+    return FALSE;
+
+  if (g_str_has_prefix (name, "-gtk-"))
+    return FALSE;
+
+  return TRUE;
+}
+
 static void
 parse_declaration (GtkCssScanner *scanner,
                    GtkCssRuleset *ruleset)
@@ -2356,7 +2368,7 @@ parse_declaration (GtkCssScanner *scanner,
     goto check_for_semicolon;
 
   property = _gtk_style_property_lookup (name);
-  if (property == NULL && name[0] != '-')
+  if (property == NULL && !name_is_style_property (name))
     {
       gtk_css_provider_error (scanner->provider,
                               scanner,
@@ -2441,7 +2453,7 @@ parse_declaration (GtkCssScanner *scanner,
 
       gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
     }
-  else if (name[0] == '-')
+  else if (name_is_style_property (name))
     {
       char *value_str;
 


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