[glib] GVariant: add bind map for strings to byte arrays



commit 5e6e7cbadf2ee48c0e439a416e5fb74e8e5d8dee
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Apr 25 19:10:44 2010 -0500

    GVariant: add bind map for strings to byte arrays

 gio/gsettings-mapping.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gio/gsettings-mapping.c b/gio/gsettings-mapping.c
index 0290f6f..6b17bfb 100644
--- a/gio/gsettings-mapping.c
+++ b/gio/gsettings-mapping.c
@@ -369,6 +369,8 @@ g_settings_set_mapping (const GValue       *value,
         return NULL;
       else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING))
         return g_variant_new_string (g_value_get_string (value));
+      else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE ("ay")))
+        return g_variant_new_byte_array (g_value_get_string (value), -1);
       else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_OBJECT_PATH))
         return g_variant_new_object_path (g_value_get_string (value));
       else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_SIGNATURE))
@@ -427,6 +429,11 @@ g_settings_get_mapping (GValue   *value,
       g_value_set_string (value, g_variant_get_string (variant, NULL));
       return TRUE;
     }
+  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE ("ay")))
+    {
+      g_value_set_string (value, g_variant_get_byte_array (variant, NULL));
+      return TRUE;
+    }
 
   g_critical ("No GSettings bind handler for type \"%s\".",
               g_variant_get_type_string (variant));
@@ -460,6 +467,7 @@ g_settings_mapping_is_compatible (GType               gvalue_type,
           g_variant_type_equal (variant_type, G_VARIANT_TYPE_DOUBLE));
   else if (gvalue_type == G_TYPE_STRING)
     ok = (g_variant_type_equal (variant_type, G_VARIANT_TYPE_STRING)      ||
+          g_variant_type_equal (variant_type, G_VARIANT_TYPE ("ay")) ||
           g_variant_type_equal (variant_type, G_VARIANT_TYPE_OBJECT_PATH) ||
           g_variant_type_equal (variant_type, G_VARIANT_TYPE_SIGNATURE));
 



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