[gtk+/parser] cssprovider: Add a new setter for rulesets



commit 0ea5f1f9679d91adb16acee54bbedc87f859843a
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 18 04:30:51 2011 +0200

    cssprovider: Add a new setter for rulesets
    
    We now have set-by-pspec (which is used for normal style properties) and
    set-by-name (which is used by widget properties).

 gtk/gtkcssprovider.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index dbb6a6c..f4282a0 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -955,6 +955,14 @@ gtk_css_ruleset_add_style (GtkCssRuleset *ruleset,
   g_hash_table_insert (ruleset->style, name, value);
 }
 
+static void
+gtk_css_ruleset_add (GtkCssRuleset *ruleset,
+                     GParamSpec    *pspec,
+                     GValue        *value)
+{
+  gtk_css_ruleset_add_style (ruleset, g_strdup (pspec->name), value);
+}
+
 static gboolean
 gtk_css_ruleset_matches (GtkCssRuleset *ruleset,
                          GtkWidgetPath *path,
@@ -1857,6 +1865,8 @@ parse_declaration (GtkCssScanner *scanner,
     {
       GValue *val;
 
+      g_free (name);
+
       val = g_slice_new0 (GValue);
       g_value_init (val, pspec->value_type);
 
@@ -1866,20 +1876,20 @@ parse_declaration (GtkCssScanner *scanner,
            * to override other style providers when merged
            */
           g_param_value_set_default (pspec, val);
-          gtk_css_ruleset_add_style (ruleset, name, val);
+          gtk_css_ruleset_add (ruleset, pspec, val);
         }
       else if (strcmp (name, "gtk-key-bindings") == 0)
         {
           /* Private property holding the binding sets */
           resolve_binding_sets (value_str, val);
-          gtk_css_ruleset_add_style (ruleset, name, val);
+          gtk_css_ruleset_add (ruleset, pspec, val);
         }
       else if (parse_func)
         {
           GError *error = NULL;
           
           if ((*parse_func) (value_str, val, &error))
-            gtk_css_ruleset_add_style (ruleset, name, val);
+            gtk_css_ruleset_add (ruleset, pspec, val);
           else
             gtk_css_provider_take_error (scanner->provider, scanner, error);
         }
@@ -1892,13 +1902,12 @@ parse_declaration (GtkCssScanner *scanner,
                                           value_str,
                                           &error))
             {
-              gtk_css_ruleset_add_style (ruleset, name, val);
+              gtk_css_ruleset_add (ruleset, pspec, val);
             }
           else
             {
               g_value_unset (val);
               g_slice_free (GValue, val);
-              g_free (name);
 
               gtk_css_provider_take_error (scanner->provider, scanner, error);
             }



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