[gnome-shell] dateMenu: Add "Open Clocks" entry



commit 5e5798bee91c38e2f619dafffa4d8ace9a732c6e
Author: Mathieu Bridon <bochecha fedoraproject org>
Date:   Sat Dec 15 11:30:03 2012 +0100

    dateMenu: Add "Open Clocks" entry
    
    This is similar to how the dateMenu already allows opening the calendar
    application. However, the new entry only appears if GNOME Clocks is
    installed, as it is not a core GNOME application.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644390

 js/ui/dateMenu.js |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 7d027da..430ebfb 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -93,6 +93,15 @@ const DateMenuButton = new Lang.Class({
         this._openCalendarItem.actor.can_focus = false;
         vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
+        this._openClocksItem = new PopupMenu.PopupMenuItem(_("Open Clocks"));
+        this._openClocksItem.connect('activate', Lang.bind(this, this._onOpenClocksActivate));
+        this._openClocksItem.actor.can_focus = false;
+        vbox.add(this._openClocksItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
+
+        Shell.AppSystem.get_default().connect('installed-changed',
+                                              Lang.bind(this, this._appInstalledChanged));
+        this._appInstalledChanged();
+
         item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop');
         if (item) {
             item.actor.show_on_set_parent = false;
@@ -147,6 +156,11 @@ const DateMenuButton = new Lang.Class({
         this._sessionUpdated();
     },
 
+    _appInstalledChanged: function() {
+        let app = Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
+        this._openClocksItem.actor.visible = app !== null;
+    },
+
     _setEventsVisibility: function(visible) {
         this._openCalendarItem.actor.visible = visible;
         this._separator.visible = visible;
@@ -198,5 +212,11 @@ const DateMenuButton = new Lang.Class({
 
         let app = Gio.AppInfo.get_default_for_type('text/calendar', false);
         app.launch([], global.create_app_launch_context());
+    },
+
+    _onOpenClocksActivate: function() {
+        this.menu.close();
+        let app = Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
+        app.activate();
     }
 });



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