[Xfce4-commits] <xfconf:master> Add toggle option to xfconf-query.

Nick Schermer noreply at xfce.org
Wed May 25 21:44:01 CEST 2011


Updating branch refs/heads/master
         to 86f5002978a8a232e0e9b9048ac3db62c703c4c2 (commit)
       from 37b27c2f6be394cab983d987a155a80fd6f79213 (commit)

commit 86f5002978a8a232e0e9b9048ac3db62c703c4c2
Author: Nick Schermer <nick at xfce.org>
Date:   Wed May 25 21:42:21 2011 +0200

    Add toggle option to xfconf-query.
    
    This makes it easy to invert boolean values, something people
    often do.

 xfconf-query/main.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/xfconf-query/main.c b/xfconf-query/main.c
index b6febd1..cae5164 100644
--- a/xfconf-query/main.c
+++ b/xfconf-query/main.c
@@ -68,6 +68,7 @@ static gboolean reset = FALSE;
 static gboolean recursive = FALSE;
 static gboolean force_array = FALSE;
 static gboolean monitor = FALSE;
+static gboolean toggle = FALSE;
 static gchar *channel_name = NULL;
 static gchar *property_name = NULL;
 static gchar **set_value = NULL;
@@ -230,6 +231,10 @@ static GOptionEntry entries[] =
         N_("Force array even if only one element"),
         NULL
     },
+    {   "toggle", 'T', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &toggle,
+        N_("Invert an existing boolean property"),
+        NULL
+    },
 /*
     {   "export", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &export_file,
         N_("Export channel to file"),
@@ -371,7 +376,21 @@ main(int argc, char **argv)
                            property_name, channel_name);
                 return 1;
             }
-            
+
+            if (toggle)
+            {
+                if(G_VALUE_HOLDS_BOOLEAN(&value))
+                {
+                    xfconf_channel_set_bool (channel, property_name, !g_value_get_boolean (&value));
+                    return 0;
+                }
+                else
+                {
+                    g_printerr("%s\n%s", _("--toggle only works with boolean values"), _("aborting..."));
+                    return 1;
+                }
+            }
+
             if(XFCONF_TYPE_G_VALUE_ARRAY != G_VALUE_TYPE(&value))
             {
                 gchar *str_val = _xfconf_string_from_gvalue(&value);



More information about the Xfce4-commits mailing list