[Xfce4-commits] r26810 - in xfconf/trunk: common po xfconf-query

Stephan Arts stephan at xfce.org
Wed Apr 9 22:41:20 CEST 2008


Author: stephan
Date: 2008-04-09 20:41:20 +0000 (Wed, 09 Apr 2008)
New Revision: 26810

Modified:
   xfconf/trunk/common/Makefile.am
   xfconf/trunk/po/xfconf.pot
   xfconf/trunk/xfconf-query/Makefile.am
   xfconf/trunk/xfconf-query/main.c
Log:
Improve xfconf-query support for gvalue types (use common-code for gvalue >< string conversion)
Fix compile-warning with make-distcheck inside common-libs, (add header to Makefile.am)
Update pot file.



Modified: xfconf/trunk/common/Makefile.am
===================================================================
--- xfconf/trunk/common/Makefile.am	2008-04-09 13:46:09 UTC (rev 26809)
+++ xfconf/trunk/common/Makefile.am	2008-04-09 20:41:20 UTC (rev 26810)
@@ -22,7 +22,8 @@
 
 
 libxfconf_gvaluefuncs_la_SOURCES = \
-	xfconf-gvaluefuncs.c
+	xfconf-gvaluefuncs.c \
+	xfconf-gvaluefuncs.h
 
 libxfconf_gvaluefuncs_la_CFLAGS = \
 	-DLIBXFCONF_COMPILATION \

Modified: xfconf/trunk/po/xfconf.pot
===================================================================
--- xfconf/trunk/po/xfconf.pot	2008-04-09 13:46:09 UTC (rev 26809)
+++ xfconf/trunk/po/xfconf.pot	2008-04-09 20:41:20 UTC (rev 26810)
@@ -9,7 +9,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-04-08 23:21-0700\n"
+"POT-Creation-Date: 2008-04-09 22:32+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -17,19 +17,19 @@
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: common/xfconf-gvaluefuncs.c:209
+#: common/xfconf-gvaluefuncs.c:222
 msgid "true"
 msgstr ""
 
-#: common/xfconf-gvaluefuncs.c:210
+#: common/xfconf-gvaluefuncs.c:223
 msgid "false"
 msgstr ""
 
-#: xfsettingsd/main.c:50 xfconf-query/main.c:51
+#: xfsettingsd/main.c:50 xfconf-query/main.c:52
 msgid "Version information"
 msgstr ""
 
-#: xfsettingsd/main.c:54 xfconf-query/main.c:55
+#: xfsettingsd/main.c:54 xfconf-query/main.c:56
 msgid "Verbose output"
 msgstr ""
 
@@ -130,14 +130,14 @@
 msgid "No backends could be started"
 msgstr ""
 
-#: xfconf-query/main.c:59
+#: xfconf-query/main.c:60
 msgid "pick the channel"
 msgstr ""
 
-#: xfconf-query/main.c:63
+#: xfconf-query/main.c:64
 msgid "pick the property"
 msgstr ""
 
-#: xfconf-query/main.c:67
+#: xfconf-query/main.c:68
 msgid "set (change the value)"
 msgstr ""

Modified: xfconf/trunk/xfconf-query/Makefile.am
===================================================================
--- xfconf/trunk/xfconf-query/Makefile.am	2008-04-09 13:46:09 UTC (rev 26809)
+++ xfconf/trunk/xfconf-query/Makefile.am	2008-04-09 20:41:20 UTC (rev 26810)
@@ -7,12 +7,14 @@
 xfconf_query_CFLAGS = \
 	$(GLIB_CFLAGS) \
 	$(DBUS_GLIB_CFLAGS) \
+	-I$(top_srcdir)/common \
 	-DDATADIR=\"$(datadir)\" \
 	-DSRCDIR=\"$(top_srcdir)\" \
 	-DLOCALEDIR=\"$(localedir)\"
 
 xfconf_query_LDADD = \
 	$(top_builddir)/xfconf/libxfconf-0.la \
+	$(top_builddir)/common/libxfconf-gvaluefuncs.la \
 	$(GLIB_LIBS) \
 	$(DBUS_GLIB_LIBS)
 

Modified: xfconf/trunk/xfconf-query/main.c
===================================================================
--- xfconf/trunk/xfconf-query/main.c	2008-04-09 13:46:09 UTC (rev 26809)
+++ xfconf/trunk/xfconf-query/main.c	2008-04-09 20:41:20 UTC (rev 26810)
@@ -37,7 +37,8 @@
 #include <glib/gi18n.h>
 #endif
 
-#include <xfconf/xfconf.h>
+#include "xfconf-gvaluefuncs.h"
+#include "xfconf/xfconf.h"
 
 static gboolean version = FALSE;
 static gboolean verbose = FALSE;
@@ -116,108 +117,22 @@
         GValue value = {0, };
         xfconf_channel_get_property(channel, property_name, &value);
 
-        GType prop_type = G_VALUE_TYPE(&value);
         /** Read value */
         if(set_value == NULL)
         {
-            switch(prop_type)
-            {
-                case G_TYPE_INT:
-                    {
-                        gint i_val = g_value_get_int(&value);
-                        g_print("%d\n", i_val);
-                    }
-                    break;
-                case G_TYPE_STRING:
-                    {
-                        const gchar *str_val = g_value_get_string(&value);
-                        g_print("%s\n", str_val);
-                    }
-                    break;
-                case G_TYPE_BOOLEAN:
-                    {
-                        gboolean b_val = g_value_get_boolean(&value);
-                        g_print("%d\n", b_val);
-                    }
-                    break;
-            }
-
+            const gchar *str_val = _xfconf_string_from_gvalue(&value);
+            g_print("%s\n", str_val);
         }
-
         /* Write value */
         else
         {
-            if (set_value[0] != NULL)
+            if(_xfconf_gvalue_from_string(&value, set_value[0]))
             {
-                gint i = 0;
-                if (set_value[1] != NULL)
-                {
-                    i++;
-                    /** Check if the type is the same as specified */
-                    switch(prop_type)
-                    {
-                        case G_TYPE_INT:
-                            if (g_strcasecmp(set_value[0], "int"))
-                            {
-                                /** ERROR */
-                                g_critical("Property '%s' is not of type '%s'", set_value[1], set_value[0]);
-                                return 1;
-                            }
-                            break;
-                        case G_TYPE_STRING:
-                            if (g_strcasecmp(set_value[0], "string"))
-                            {
-                                /** ERROR */
-                                g_critical("Property '%s' is not of type '%s'", set_value[1], set_value[0]);
-                                return 1;
-                            }
-                            break;
-                        case G_TYPE_BOOLEAN:
-                            if (g_strcasecmp(set_value[0], "boolean"))
-                            {
-                                /** ERROR */
-                                g_critical("Property '%s' is not of type '%s'", set_value[1], set_value[0]);
-                                return 1;
-                            }
-                            break;
-                    }
-                }
-
-                /** Set the value */
-                switch(prop_type)
-                {
-                    case G_TYPE_INT:
-                    case G_TYPE_UINT:
-                        {
-                        gint i_val = atoi(set_value[i]);
-                        xfconf_channel_set_int(channel, property_name, i_val);
-                        }
-                        break;
-                    case G_TYPE_STRING:
-                        xfconf_channel_set_string(channel, property_name, set_value[i]);
-                        break;
-                    case G_TYPE_BOOLEAN:
-                        if(!g_strcasecmp(set_value[i], "True") || !g_strcasecmp(set_value[i], "1"))
-                        {
-                            xfconf_channel_set_bool(channel, property_name, TRUE);
-                            return 0;
-                        }
-                        if(!g_strcasecmp(set_value[i], "False") || !g_strcasecmp(set_value[i], "0"))
-                        {
-                            xfconf_channel_set_bool(channel, property_name, FALSE);
-                            return 0;
-                        }
-                        break;
-                    case G_TYPE_DOUBLE:
-                        break;
-                    case G_TYPE_INT64:
-                    case G_TYPE_UINT64:
-                        break;
-                }
+                xfconf_channel_set_property(channel, property_name, &value);
             }
             else
             {
-                /** Error */
+                g_print("ERROR: Could not convert value\n");
             }
         }
         g_value_unset(&value);



More information about the Xfce4-commits mailing list