[Xfce4-commits] [xfce/xfconf] 19/31: Support g_type_uchar and convert it to g_variant_type_byte.

noreply at xfce.org noreply at xfce.org
Thu Jun 1 13:33:12 CEST 2017


This is an automated email from the git hooks/post-receive script.

a   l   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfconf.

commit 9e32ac764895564db65dd653ddac608cd44dd382
Author: Ali Abdallah <aliovx at gmail.com>
Date:   Mon Apr 25 10:24:58 2016 +0200

    Support g_type_uchar and convert it to g_variant_type_byte.
    
    Note: Strangely there is no g_variant_type_char for signed char, so
    use int16 instead... In the old dbus-glib based version this
    way working as follows:
    
    Send GPtrArray with a GValue of type schar
    xfconfd writes it as uchar to the xml
    Read the GPtrArray property---> xfconfd returns a schar type from the cached mem.
    Exit xfconfd
    Read the GPtrArray property---> xfconfd reads from the xml a uchar type.
    
    By using int16 for schar xfconfd always write int16 and returns int16 values,
    a bit more consistent.
---
 common/xfconf-gvaluefuncs.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/common/xfconf-gvaluefuncs.c b/common/xfconf-gvaluefuncs.c
index 8a19c98..0ceeba9 100644
--- a/common/xfconf-gvaluefuncs.c
+++ b/common/xfconf-gvaluefuncs.c
@@ -380,6 +380,9 @@ xfconf_basic_gvalue_to_gvariant (const GValue *value) {
     case G_TYPE_BOOLEAN:
         type = G_VARIANT_TYPE_BOOLEAN;
         break;
+    case G_TYPE_UCHAR:
+        type = G_VARIANT_TYPE_BYTE;
+        break;
     case G_TYPE_INT64:
         type = G_VARIANT_TYPE_INT64;
         break;
@@ -400,12 +403,15 @@ xfconf_basic_gvalue_to_gvariant (const GValue *value) {
         break;
     }
     
-    
     if (type) {
         return g_dbus_gvalue_to_gvariant (value, type);
     } 
-    
-    g_warning ("Unable toconvert GType '%s' to GVariant", _xfconf_string_from_gtype(G_VALUE_TYPE(value)));
+    /* there is no g_variant_type_char! */
+    else if (G_VALUE_TYPE(value) == G_TYPE_CHAR) {
+        return g_variant_new_int16(g_value_get_schar(value));
+    }
+        
+    g_warning ("Unable to convert GType '%s' to GVariant", _xfconf_string_from_gtype(G_VALUE_TYPE(value)));
 
     return NULL;
 }
@@ -441,6 +447,10 @@ void xfconf_basic_gvariant_to_gvalue (GVariant *variant, GValue *value)
         g_value_init(value, G_TYPE_BOOLEAN);
         g_value_set_boolean (value, g_variant_get_boolean (variant));
         break;
+    case G_VARIANT_CLASS_BYTE:
+        g_value_init(value, G_TYPE_UCHAR);
+        g_value_set_uchar (value, g_variant_get_byte (variant));
+        break;
     case G_VARIANT_CLASS_STRING:
         g_value_init(value, G_TYPE_STRING);
         g_value_set_string (value, g_variant_get_string (variant, NULL));

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list