[gnome-settings-daemon/wip/xsettings-manager] xsettings: add XSETTINGS_VARIANT_TYPE_COLOR macro



commit afcf833025ceea3c6ab67bcbae2f1ca6a5fb66e5
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Mar 9 12:19:48 2012 -0500

    xsettings: add XSETTINGS_VARIANT_TYPE_COLOR macro
    
    This is the GVariantType corresponding to "(qqqq)".
    
    Double-check it at the spot we create the value using g_variant_new()
    for some extra safety against people making changes in one place and not
    the other.

 plugins/xsettings/xsettings-manager.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c
index 231a6e4..e71c3c0 100644
--- a/plugins/xsettings/xsettings-manager.c
+++ b/plugins/xsettings/xsettings-manager.c
@@ -29,6 +29,8 @@
 
 #include "xsettings-manager.h"
 
+#define XSETTINGS_VARIANT_TYPE_COLOR  (G_VARIANT_TYPE ("(qqqq)"))
+
 struct _XSettingsManager
 {
   Display *display;
@@ -243,6 +245,7 @@ xsettings_manager_set_color (XSettingsManager *manager,
   GVariant *tmp;
 
   tmp = g_variant_new ("(qqqq)", value->red, value->green, value->blue, value->alpha);
+  g_assert (g_variant_is_of_type (tmp, XSETTINGS_VARIANT_TYPE_COLOR)); /* paranoia... */
   xsettings_manager_set_setting (manager, name, 0, tmp);
 }
 
@@ -375,7 +378,7 @@ xsettings_manager_set_overrides (XSettingsManager *manager,
       /* only accept recognised types... */
       if (!g_variant_is_of_type (value, G_VARIANT_TYPE_STRING) &&
           !g_variant_is_of_type (value, G_VARIANT_TYPE_INT32) &&
-          !g_variant_is_of_type (value, G_VARIANT_TYPE ("(qqqq)")))
+          !g_variant_is_of_type (value, XSETTINGS_VARIANT_TYPE_COLOR))
         continue;
 
       xsettings_manager_set_setting (manager, key, 1, value);



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