[gtk+/nth-child: 6/33] styleproperty: Change _css_value_to_string()



commit 8d35e4048952c4971e52e790a5342d927777ec03
Author: Benjamin Otte <otte redhat com>
Date:   Mon May 23 07:16:17 2011 +0200

    styleproperty: Change _css_value_to_string()
    
    Name it _gtk_style_property_print_value() and actually pass it the style
    property. This way, we can later change it to use custom print functions
    for different style properties.

 gtk/gtkcssprovider.c          |    5 +----
 gtk/gtkstyleproperty.c        |   19 +++++++++++--------
 gtk/gtkstylepropertyprivate.h |    4 +++-
 3 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index d433573..0abd075 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2966,7 +2966,6 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
                        GString             *str)
 {
   GList *keys, *walk;
-  char *s;
 
   _gtk_css_selector_print (ruleset->selector, str);
 
@@ -2986,9 +2985,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
           g_string_append (str, "  ");
           g_string_append (str, prop->pspec->name);
           g_string_append (str, ": ");
-          s = _gtk_css_value_to_string (value);
-          g_string_append (str, s);
-          g_free (s);
+          _gtk_style_property_print_value (prop, value, str);
           g_string_append (str, ";\n");
         }
 
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 2bcb394..477b7c0 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -1402,8 +1402,10 @@ _gtk_css_value_parse (GValue       *value,
   return (*func) (parser, base, value);
 }
 
-char *
-_gtk_css_value_to_string (const GValue *value)
+void
+_gtk_style_property_print_value (const GtkStyleProperty *property,
+                                 const GValue           *value,
+                                 GString                *string)
 {
   PrintFunc func;
 
@@ -1415,14 +1417,15 @@ _gtk_css_value_to_string (const GValue *value)
     func = g_hash_table_lookup (print_funcs,
                                 GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
 
-  if (func)
+  if (func == NULL)
     {
-      GString *string = g_string_new (NULL);
-      func (value, string);
-      return g_string_free (string, FALSE);
+      char *s = g_strdup_value_contents (value);
+      g_string_append (string, s);
+      g_free (s);
+      return;
     }
-
-  return g_strdup_value_contents (value);
+  
+  func (value, string);
 }
 
 gboolean
diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h
index a1d222e..8ffe0ad 100644
--- a/gtk/gtkstylepropertyprivate.h
+++ b/gtk/gtkstylepropertyprivate.h
@@ -59,7 +59,9 @@ void                     _gtk_style_property_pack          (const GtkStyleProper
 gboolean                _gtk_css_value_parse              (GValue        *value,
                                                            GtkCssParser  *parser,
                                                            GFile         *base);
-char *                  _gtk_css_value_to_string          (const GValue  *value);
+void                     _gtk_style_property_print_value   (const GtkStyleProperty *property,
+                                                            const GValue           *value,
+                                                            GString                *string);
 
 G_END_DECLS
 



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