[gnome-software/gnome-3-20] trivial: Add gs_utils_is_current_desktop()



commit 8ab0446d2f6cfcc36d31c2dd072ed1462016a762
Author: Richard Hughes <richard hughsie com>
Date:   Thu Apr 14 12:29:16 2016 +0100

    trivial: Add gs_utils_is_current_desktop()
    
    This reduces the delta against master.

 src/gs-utils.c |   15 +++++++++++++++
 src/gs-utils.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 6a0a8f1..ee63e82 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -517,4 +517,19 @@ gs_utils_get_content_type (const gchar *filename,
        return g_strdup (tmp);
 }
 
+/**
+ * gs_utils_is_current_desktop:
+ */
+gboolean
+gs_utils_is_current_desktop (const gchar *name)
+{
+       const gchar *tmp;
+       g_auto(GStrv) names = NULL;
+       tmp = g_getenv ("XDG_CURRENT_DESKTOP");
+       if (tmp == NULL)
+               return FALSE;
+       names = g_strsplit (tmp, ":", -1);
+       return g_strv_contains ((const gchar * const *) names, name);
+}
+
 /* vim: set noexpandtab: */
diff --git a/src/gs-utils.h b/src/gs-utils.h
index 561054c..a0e4c94 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -64,6 +64,7 @@ gchar         *gs_utils_get_cachedir          (const gchar    *kind,
                                                 GError         **error);
 gchar          *gs_utils_get_user_hash         (GError         **error);
 GPermission    *gs_utils_get_permission        (const gchar    *id);
+gboolean        gs_utils_is_current_desktop    (const gchar    *name);
 
 G_END_DECLS
 


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