[gnome-software/wip/rancell/ubuntu-3-20-rebase: 3/9] Do not use the header bar on Unity



commit ff9f70f33ad12aafa871c282c37658eb8679e498
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 |   12 ++++++++----
 src/gs-utils.c |   15 +++++++++++++++
 src/gs-utils.h |    2 ++
 3 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 154b4c0..67b124d 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -722,10 +722,14 @@ 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"));
-       g_object_ref (widget);
-       gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
-       gtk_window_set_titlebar (GTK_WINDOW (priv->main_window), widget);
-       g_object_unref (widget);
+       if (gs_utils_is_current_desktop ("Unity")) {
+               gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (widget), "");
+       } else {
+               g_object_ref (widget);
+               gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
+               gtk_window_set_titlebar (GTK_WINDOW (priv->main_window), widget);
+               g_object_unref (widget);
+       }
 
        /* global keynav */
        g_signal_connect_after (priv->main_window, "key_press_event",
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 86f99af..8c3e2b9 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -518,6 +518,21 @@ gs_utils_get_content_type (const gchar *filename,
 }
 
 /**
+ * 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);
+}
+
+/**
  * gs_utils_get_url_scheme:
  * @url: A URL, e.g. "appstream://gimp.desktop"
  *
diff --git a/src/gs-utils.h b/src/gs-utils.h
index 6882063..ad8e039 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);
+
 gchar          *gs_utils_get_url_scheme        (const gchar    *url);
 gchar          *gs_utils_get_url_path          (const gchar    *url);
 


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