[gnome-software/wip/iainl/ubuntu-xenial] Do not use the header bar on Unity



commit f18951bcf965cff164206999d93d7ecf2dbe563f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Apr 7 15:22:11 2016 +0100

    Do not use the header bar on Unity
    
    Based on a patch by Robert Ancell, many thanks.

 src/gs-shell.c |   19 +------------------
 src/gs-utils.c |   15 +++++++++++++++
 src/gs-utils.h |    2 ++
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index fb8a84b..1695d16 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -674,23 +674,6 @@ gs_shell_monitor_permission (GsShell *shell)
                                  G_CALLBACK (on_permission_changed), shell);
 }
 
-static gboolean
-in_desktop (const gchar *name)
-{
-       const gchar *desktop_name_list;
-       g_auto(GStrv) names = NULL;
-       gint i;
-
-       desktop_name_list = g_getenv ("XDG_CURRENT_DESKTOP");
-       if (desktop_name_list == NULL)
-               return FALSE;
-
-       names = g_strsplit (desktop_name_list, ":", -1);
-       for (i = 0; names[i] && strcmp (names[i], name) != 0; i++);
-
-       return names[i] != NULL;
-}
-
 /**
  * gs_shell_setup:
  */
@@ -724,7 +707,7 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
 
        /* fix up the header bar */
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));
-       if (in_desktop ("Unity")) {
+       if (gs_utils_is_current_desktop ("Unity")) {
                gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (widget), "");
        } else {
                g_object_ref (widget);
diff --git a/src/gs-utils.c b/src/gs-utils.c
index ea59161..4df50ef 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -525,4 +525,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..aa2925e 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -65,6 +65,8 @@ gchar         *gs_utils_get_cachedir          (const gchar    *kind,
 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
 
 #endif /* __GS_UTILS_H */


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