[gnome-mahjongg] Correctly check XDG_CURRENT_DESKTOP environment variable.



commit 1e83ce74444aee3ff272cc89e42697ea1f1ff448
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Nov 4 10:10:06 2014 +1300

    Correctly check XDG_CURRENT_DESKTOP environment variable.
    
    The XDG_CURRENT_DESKTOP environment variable can contain a list of desktop names.
    The existing code assumed it could only contain one name.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739592

 src/gnome-mahjongg.vala |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 9a13419..46aca0e 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -172,7 +172,7 @@ public class Mahjongg : Gtk.Application
         header_bar.pack_end (pause_button);
 
         var desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP");
-        if (desktop == null || desktop != "Unity")
+        if (!is_desktop ("Unity"))
         {
             header_bar.set_show_close_button (true);
             window.set_titlebar (header_bar);
@@ -182,7 +182,6 @@ public class Mahjongg : Gtk.Application
             vbox.pack_start (header_bar, false, false, 0);
         }
 
-
         vbox.pack_start (game_view, true, true, 0);
 
         window.add (vbox);
@@ -199,6 +198,19 @@ public class Mahjongg : Gtk.Application
         tick_cb ();
     }
 
+    private bool is_desktop (string name)
+    {
+        var desktop_name_list = Environment.get_variable ("XDG_CURRENT_DESKTOP");
+        if (desktop_name_list == null)
+            return false;
+
+        foreach (var n in desktop_name_list.split (":"))
+            if (n == name)
+                return true;
+
+        return false;
+    }
+
     private bool window_configure_event_cb (Gdk.EventConfigure event)
     {
         if (!is_maximized)


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