[gtk+/parser] xxx: 29de92611e8e942a5e7352b1c521037fa7149640



commit 4a378d056a890cdd8c10544b39a77847182a9fbd
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 18 17:54:05 2011 +0200

    xxx: 29de92611e8e942a5e7352b1c521037fa7149640

 gtk/gtkcssprovider.c |   62 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 948160d..b8aa56b 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2829,6 +2829,12 @@ gtk_css_provider_get_named (const gchar *name,
   return provider;
 }
 
+static int
+compare_pspecs (gconstpointer a, gconstpointer b)
+{
+  return strcmp (((const GParamSpec *) a)->name, ((const GParamSpec *) b)->name);
+}
+
 static void
 gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
                        GString             *str)
@@ -2840,25 +2846,51 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
 
   g_string_append (str, " {\n");
 
-  keys = g_hash_table_get_keys (ruleset->style);
-  /* so the output is identical for identical selector styles */
-  keys = g_list_sort (keys, (GCompareFunc) strcmp);
-
-  for (walk = keys; walk; walk = walk->next)
+  if (ruleset->style)
     {
-      const char *name = walk->data;
-      const GValue *value = g_hash_table_lookup (ruleset->style, (gpointer) name);
+      keys = g_hash_table_get_keys (ruleset->style);
+      /* so the output is identical for identical selector styles */
+      keys = g_list_sort (keys, compare_pspecs);
 
-      g_string_append (str, "  ");
-      g_string_append (str, name);
-      g_string_append (str, ": ");
-      s = _gtk_css_value_to_string (value);
-      g_string_append (str, s);
-      g_free (s);
-      g_string_append (str, ";\n");
+      for (walk = keys; walk; walk = walk->next)
+        {
+          GParamSpec *pspec = walk->data;
+          const GValue *value = g_hash_table_lookup (ruleset->style, pspec);
+
+          g_string_append (str, "  ");
+          g_string_append (str, pspec->name);
+          g_string_append (str, ": ");
+          s = _gtk_css_value_to_string (value);
+          g_string_append (str, s);
+          g_free (s);
+          g_string_append (str, ";\n");
+        }
+
+      g_list_free (keys);
     }
 
-  g_list_free (keys);
+  if (ruleset->widget_style)
+    {
+      keys = g_hash_table_get_keys (ruleset->widget_style);
+      /* so the output is identical for identical selector styles */
+      keys = g_list_sort (keys, (GCompareFunc) strcmp);
+
+      for (walk = keys; walk; walk = walk->next)
+        {
+          const char *name = walk->data;
+          const GValue *value = g_hash_table_lookup (ruleset->style, (gpointer) name);
+
+          g_string_append (str, "  ");
+          g_string_append (str, name);
+          g_string_append (str, ": ");
+          s = _gtk_css_value_to_string (value);
+          g_string_append (str, s);
+          g_free (s);
+          g_string_append (str, ";\n");
+        }
+
+      g_list_free (keys);
+    }
 
   g_string_append (str, "}\n");
 }



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