[california/wip/737299-unity] Fix candidate.



commit ef6bd8f9a54a1026540390bfcd4c15478f75a836
Author: Jim Nelson <jim yorba org>
Date:   Thu Nov 20 17:03:21 2014 -0800

    Fix candidate.

 configure.ac                                |   22 -------------------
 debian/rules                                |    2 +-
 src/Makefile.am                             |    4 ---
 src/application/california-application.vala |    7 ++++++
 src/host/host-main-window.vala              |   31 +++++++++++++--------------
 src/toolkit/toolkit-deck.vala               |    8 +++---
 6 files changed, 27 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2d9c27d..76c273e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,23 +69,6 @@ AC_CHECK_PROG([XDG_EMAIL], [xdg-email], [yes], [no])
 AS_IF([test "x$XDG_EMAIL" != xyes], [AC_MSG_ERROR([xdg-email required. Please install xdg-utils package.])])
 
 #
-# configure switches
-#
-# Unity support
-#
-
-AC_MSG_CHECKING([Unity support])
-AC_ARG_ENABLE(
-       unity,
-       [  --enable-unity          enable Unity support [[default=disabled]]],
-       [ unity=$enableval ],
-       [ unity=no ]
-)
-
-AC_MSG_RESULT($unity)
-AM_CONDITIONAL(ENABLE_UNITY, test "x$unity" = "xyes")
-
-#
 # /configure switches
 #
 
@@ -99,8 +82,3 @@ AC_CONFIG_FILES([
 
 AC_OUTPUT
 
-AC_MSG_RESULT([
-Options:
-       Unity support:          $unity
-])
-
diff --git a/debian/rules b/debian/rules
index 3693f5c..dcb03ae 100755
--- a/debian/rules
+++ b/debian/rules
@@ -13,7 +13,7 @@
        dh $@ --parallel
 
 configure:
-       ./autogen.sh --prefix=/usr --enable-unity
+       ./autogen.sh --prefix=/usr
 
 build-arch: configure
        dh $@
diff --git a/src/Makefile.am b/src/Makefile.am
index 2dd4438..d61054f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -216,10 +216,6 @@ california_RC = \
 
 california_OPTIONAL_VALAFLAGS =
 
-if ENABLE_UNITY
-california_OPTIONAL_VALAFLAGS += --define ENABLE_UNITY
-endif
-
 if HAVE__NL_TIME_FIRST_WEEKDAY
 california_OPTIONAL_VALAFLAGS += --define HAVE__NL_TIME_FIRST_WEEKDAY
 endif
diff --git a/src/application/california-application.vala b/src/application/california-application.vala
index 6e646ee..8bf8069 100644
--- a/src/application/california-application.vala
+++ b/src/application/california-application.vala
@@ -126,8 +126,15 @@ public class Application : Gtk.Application {
      */
     public Host.MainWindow? main_window { get; private set; default = null; }
     
+    /**
+     * Indicates application is running under Ubuntu's Unity shell.
+     */
+    public bool is_running_unity { get; private set; }
+    
     private Application() {
         Object (application_id: ID);
+        
+        is_running_unity = String.ci_equal(Environment.get_variable("XDG_CURRENT_DESKTOP"), "Unity");
     }
     
     ~Application() {
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 55ad35f..443b55a 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -149,12 +149,12 @@ public class MainWindow : Gtk.ApplicationWindow {
         
         // if not on Unity, use headerbar as the titlebar (removes window chrome) and provide close
         // button for users who might have trouble finding it otherwise
-#if !ENABLE_UNITY
-        // Unity doesn't support GtkHeaderBar-as-title-bar very well yet; when set, the main
-        // window can't be resized no matter what additional GtkWindow properties are set
-        set_titlebar(headerbar);
-        headerbar.show_close_button = true;
-#endif
+        if (!Application.instance.is_running_unity) {
+            // Unity doesn't support GtkHeaderBar-as-title-bar very well yet; when set, the main
+            // window can't be resized no matter what additional GtkWindow properties are set
+            set_titlebar(headerbar);
+            headerbar.show_close_button = true;
+        }
         
         // Use custom headerbar title
         headerbar.custom_title = custom_title;
@@ -211,9 +211,8 @@ public class MainWindow : Gtk.ApplicationWindow {
         
         Gtk.Box layout = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
         // if on Unity, since headerbar is not the titlebar, need to pack it like any other widget
-#if ENABLE_UNITY
-        layout.pack_start(headerbar, false, true, 0);
-#endif
+        if (Application.instance.is_running_unity)
+            layout.pack_start(headerbar, false, true, 0);
         layout.pack_end(view_stack, true, true, 0);
         
         add(layout);
@@ -370,13 +369,13 @@ public class MainWindow : Gtk.ApplicationWindow {
     }
     
     private void on_quick_create_event() {
-#if ENABLE_UNITY
-        // Unity/Ambiance has display problems with GtkPopovers attached to GtkHeaderBars, so use
-        // a DeckWindow
-        quick_create_event(null, null, null);
-#else
-        quick_create_event(null, quick_add_button, null);
-#endif
+        if (Application.instance.is_running_unity) {
+            // Unity/Ambiance has display problems with GtkPopovers attached to GtkHeaderBars, so use
+            // a DeckWindow
+            quick_create_event(null, null, null);
+        } else {
+            quick_create_event(null, quick_add_button, null);
+        }
     }
     
     private void on_jump_to_today() {
diff --git a/src/toolkit/toolkit-deck.vala b/src/toolkit/toolkit-deck.vala
index b1a5646..354da51 100644
--- a/src/toolkit/toolkit-deck.vala
+++ b/src/toolkit/toolkit-deck.vala
@@ -314,10 +314,10 @@ public class Deck : Gtk.Stack {
     // this overrides the color and uses the toplevel's background color for the Card.  See:
     // https://bugzilla.gnome.org/show_bug.cgi?id=735421
     private void on_card_realized(Gtk.Widget card) {
-#if ENABLE_UNITY
-        Gdk.RGBA bg = card.get_toplevel().get_style_context().get_background_color(Gtk.StateFlags.NORMAL);
-        card.override_background_color(Gtk.StateFlags.NORMAL, bg);
-#endif
+        if (Application.instance.is_running_unity) {
+            Gdk.RGBA bg = 
card.get_toplevel().get_style_context().get_background_color(Gtk.StateFlags.NORMAL);
+            card.override_background_color(Gtk.StateFlags.NORMAL, bg);
+        }
     }
 }
 


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