[gconf] gsettings-data-convert: Attempt conversion to unsigned int



commit 132815e5f921e9b54d3e56d17fdf48fbe1732c06
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Aug 8 19:27:09 2011 +0300

    gsettings-data-convert: Attempt conversion to unsigned int
    
    When we find an integer in GConf, and the gsettings key has
    unsigned int type, try to do the right thing.

 gsettings/gsettings-data-convert.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gsettings/gsettings-data-convert.c b/gsettings/gsettings-data-convert.c
index 3c52bc2..0d3c8c2 100644
--- a/gsettings/gsettings-data-convert.c
+++ b/gsettings/gsettings-data-convert.c
@@ -37,6 +37,20 @@ static gboolean dry_run = FALSE;
 extern const gchar *gconf_value_type_to_string (int type);
 
 static gboolean
+type_uint32 (GSettings   *settings,
+             const gchar *key)
+{
+  const GVariantType *type;
+  GVariant *value;
+
+  value = g_settings_get_value (settings, key);
+  type = g_variant_get_type (value);
+  g_variant_unref (value);
+
+  return g_variant_type_equal (type, G_VARIANT_TYPE_UINT32);
+}
+
+static gboolean
 handle_file (const gchar *filename)
 {
   GKeyFile *keyfile;
@@ -166,6 +180,9 @@ handle_file (const gchar *filename)
                     g_settings_set_enum (settings, keys[j], gconf_value_get_int (value));
                   else if (strcmp (type, "flags") == 0)
                     g_settings_set_flags (settings, keys[j], gconf_value_get_int (value));
+                  else if (type_uint32 (settings, keys[j]))
+                    g_settings_set (settings, keys[j], "u",
+                                    gconf_value_get_int (value));
                   else
                     g_settings_set (settings, keys[j], "i",
                                     gconf_value_get_int (value));



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