[Xfce4-commits] <garcon:master> Add garcon_set_environment_xdg() function.

Nick Schermer noreply at xfce.org
Fri Aug 2 22:04:03 CEST 2013


Updating branch refs/heads/master
         to 9d22a69a448799a8d68b203428a63ab34c7ed63f (commit)
       from b20e0f3cfe132808dcc36294bee765ee14af6ba2 (commit)

commit 9d22a69a448799a8d68b203428a63ab34c7ed63f
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Aug 2 21:57:33 2013 +0200

    Add garcon_set_environment_xdg() function.
    
    This set the environent to that one set with XDG_CURRENT_DESKTOP,
    and optionaly takes a fallback.
    
    Also add a define GARCON_ENVIRONMENT_XFCE for this.

 garcon/garcon-environment.c |   27 +++++++++++++++++++++++++++
 garcon/garcon-environment.h |   17 +++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/garcon/garcon-environment.c b/garcon/garcon-environment.c
index f6160cd..c9d9d09 100644
--- a/garcon/garcon-environment.c
+++ b/garcon/garcon-environment.c
@@ -75,3 +75,30 @@ garcon_get_environment (void)
 {
   return environment;
 }
+
+
+
+/**
+ * garcon_set_environment_xdg:
+ * @fallback_env: fallback value
+ *
+ * Set the desktop environment to the envvar XDG_CURRENT_DESKTOP.
+ * If this variables is not set, it falls back to @default_env.
+ *
+ * For @fallback_env you can use for example #GARCON_ENVIRONMENT_XFCE.
+ *
+ * Since: 0.3.0
+ */
+void
+garcon_set_environment_xdg (const gchar *fallback_env)
+{
+  const gchar *desktop;
+
+  desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+  if (G_LIKELY (desktop == NULL))
+    desktop = fallback_env;
+  else if (*desktop == '\0')
+    desktop = NULL;
+
+  garcon_set_environment (desktop);
+}
diff --git a/garcon/garcon-environment.h b/garcon/garcon-environment.h
index 2384cf1..8317165 100644
--- a/garcon/garcon-environment.h
+++ b/garcon/garcon-environment.h
@@ -25,12 +25,25 @@
 #ifndef __GARCON_MENU_ENVIRONMENT_H__
 #define __GARCON_MENU_ENVIRONMENT_H__
 
+/**
+ * GARCON_ENVIRONMENT_XFCE:
+ *
+ * Macro for garcon_set_environment or garcon_set_environment_xdg
+ * to set the Xfce Desktop Environment.
+ *
+ * Since: 0.3.0
+ **/
+#define GARCON_ENVIRONMENT_XFCE "XFCE"
+
 #include <glib.h>
 
 G_BEGIN_DECLS
 
-void         garcon_set_environment (const gchar *env);
-const gchar *garcon_get_environment (void);
+void         garcon_set_environment     (const gchar *env);
+
+const gchar *garcon_get_environment     (void);
+
+void         garcon_set_environment_xdg (const gchar *fallback_env);
 
 G_END_DECLS
 


More information about the Xfce4-commits mailing list