[geary/wip/721967-status-icon] Add status icon to Geary: Refs bgo#721967



commit a6608087572ebf2d6a0bf1bce943249c068363b1
Author: Gwendal Le Bihan <gwendal lebihan gmail com>
Date:   Tue Jan 14 12:17:20 2014 -0800

    Add status icon to Geary: Refs bgo#721967

 THANKS                                       |    1 +
 src/CMakeLists.txt                           |    1 +
 src/client/application/geary-controller.vala |    4 +++
 src/client/components/status-icon.vala       |   35 ++++++++++++++++++++++++++
 ui/CMakeLists.txt                            |    1 +
 ui/status_icon_menu.ui                       |    5 +++
 6 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/THANKS b/THANKS
index 84d8e17..b6a3b48 100644
--- a/THANKS
+++ b/THANKS
@@ -17,6 +17,7 @@ Michael George <mdgeorge cs cornell edu>
 Sven Hagemann <sven rednose nl>
 Mathias Hasselmann <mathias openismus com>
 Timo Kluck <tkluck infty nl>
+Gwendal Le Bihan <gwendal lebihan gmail com>
 Charles Lehner <rdm cel celehner com>
 Avi Levy <avi w levy gmail com>
 Brendan Long <self brendanlong com>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4c3a45a..1510d1c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -321,6 +321,7 @@ client/components/monitored-progress-bar.vala
 client/components/monitored-spinner.vala
 client/components/pill-toolbar.vala
 client/components/status-bar.vala
+client/components/status-icon.vala
 client/components/stock.vala
 
 client/composer/composer-toolbar.vala
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 2953d5b..be537ca 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -72,6 +72,7 @@ public class GearyController : Geary.BaseObject {
     private const string PROP_ATTEMPT_OPEN_ACCOUNT = "attempt-open-account";
     
     public MainWindow main_window { get; private set; }
+    public StatusIcon status_icon { get; private set; }
     
     public Geary.App.ConversationMonitor? current_conversations { get; private set; default = null; }
     
@@ -171,6 +172,9 @@ public class GearyController : Geary.BaseObject {
         Geary.Engine.instance.account_available.connect(on_account_available);
         Geary.Engine.instance.account_unavailable.connect(on_account_unavailable);
         
+        // Create the status icon        
+        status_icon = new StatusIcon();
+        
         // Connect to various UI signals.
         main_window.conversation_list_view.conversations_selected.connect(on_conversations_selected);
         main_window.conversation_list_view.conversation_activated.connect(on_conversation_activated);
diff --git a/src/client/components/status-icon.vala b/src/client/components/status-icon.vala
new file mode 100644
index 0000000..24f63d8
--- /dev/null
+++ b/src/client/components/status-icon.vala
@@ -0,0 +1,35 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+public class StatusIcon : Gtk.StatusIcon {
+    private Gtk.Menu context_menu;
+    
+    public StatusIcon() {
+        set_from_icon_name("geary");
+        
+        // Setup the context menu.
+        GearyApplication.instance.load_ui_file("status_icon_menu.ui");
+        context_menu = (Gtk.Menu) GearyApplication.instance.ui_manager.get_widget("/ui/StatusIconMenu");
+        context_menu.foreach(GtkUtil.show_menuitem_accel_labels);
+        context_menu.show_all();
+        
+        activate.connect(on_activate);
+        popup_menu.connect(on_popup_menu);
+    }
+    
+    private void on_activate() {
+        if (GearyApplication.instance.controller.main_window.is_active) {
+            GearyApplication.instance.controller.main_window.hide();
+        } else {
+            GearyApplication.instance.controller.main_window.show();
+            GearyApplication.instance.controller.main_window.present();
+        }
+    }
+    
+    private void on_popup_menu(uint button, uint activate_time) {
+        context_menu.popup(null, null, position_menu, button, activate_time);
+    }
+}
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index b04dbe2..ba0d5e2 100644
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -16,3 +16,4 @@ install(FILES remove_confirm.glade DESTINATION ${UI_DEST})
 install(FILES toolbar_mark_menu.ui DESTINATION ${UI_DEST})
 install(FILES toolbar_menu.ui DESTINATION ${UI_DEST})
 install(FILES upgrade_dialog.glade DESTINATION ${UI_DEST})
+install(FILES status_icon_menu.ui DESTINATION ${UI_DEST})
diff --git a/ui/status_icon_menu.ui b/ui/status_icon_menu.ui
new file mode 100644
index 0000000..1314ebf
--- /dev/null
+++ b/ui/status_icon_menu.ui
@@ -0,0 +1,5 @@
+<ui>
+    <popup name="StatusIconMenu">
+        <menuitem name="Quit" action="GearyQuit" />
+    </popup>
+</ui>


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