[gnome-shell/wip/fmuellner/notification-redux: 18/88] calendar: Move "Open Calendar" link into events section
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/notification-redux: 18/88] calendar: Move "Open Calendar" link into events section
- Date: Sun, 15 Feb 2015 17:32:17 +0000 (UTC)
commit 9afc0fb0ec91b8e74c1783a7e29697eef3b33d17
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 5 17:13:31 2015 +0100
calendar: Move "Open Calendar" link into events section
js/ui/calendar.js | 33 ++++++++++++++++++++++++++++++++-
js/ui/dateMenu.js | 37 +------------------------------------
2 files changed, 33 insertions(+), 37 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 437e1d6..969c169 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -808,7 +808,11 @@ const EventsSection = new Lang.Class({
this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents));
this._eventSource = new EmptyEventSource();
- this.parent('', null);
+ this.parent('', Lang.bind(this, this._openCalendar));
+
+ Shell.AppSystem.get_default().connect('installed-changed',
+ Lang.bind(this, this._appInstalledChanged));
+ this._appInstalledChanged();
},
setEventSource: function(eventSource) {
@@ -871,6 +875,33 @@ const EventsSection = new Lang.Class({
}
},
+ _appInstalledChanged: function() {
+ this._calendarApp = undefined;
+ this._title.reactive = (this._getCalendarApp() != null);
+ },
+
+ _getCalendarApp: function() {
+ if (this._calendarApp !== undefined)
+ return this._calendarApp;
+
+ let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
+ if (apps && (apps.length > 0)) {
+ let app = Gio.AppInfo.get_default_for_type('text/calendar', false);
+ let defaultInRecommended = apps.some(function(a) { return a.equal(app); });
+ this._calendarApp = defaultInRecommended ? app : apps[0];
+ } else {
+ this._calendarApp = null;
+ }
+ return this._calendarApp;
+ },
+
+ _openCalendar: function() {
+ let app = this._getCalendarApp();
+ if (app.get_id() == 'evolution.desktop')
+ app = Gio.DesktopAppInfo.new('evolution-calendar.desktop');
+ app.launch([], global.create_app_launch_context(0, -1));
+ },
+
setDate: function(date) {
this.parent(date);
this._updateTitle();
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 4d6bf0f..84fefee 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -150,16 +150,12 @@ const DateMenuButton = new Lang.Class({
let separator = new PopupMenu.PopupSeparatorMenuItem();
vbox.add(separator.actor, { y_align: St.Align.END, expand: true, y_fill: false });
- this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
- this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
- 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));
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));
+ Lang.bind(this, this._updateEventsVisibility));
item = this.menu.addSettingsAction(_("Date & Time Settings"), 'gnome-datetime-panel.desktop');
if (item) {
@@ -178,14 +174,7 @@ const DateMenuButton = new Lang.Class({
this._sessionUpdated();
},
- _appInstalledChanged: function() {
- this._calendarApp = undefined;
- this._updateEventsVisibility();
- },
-
_updateEventsVisibility: function() {
- this._openCalendarItem.actor.visible =
- (this._getCalendarApp() != null);
this._openClocksItem.actor.visible =
(this._getClockApp() != null);
},
@@ -223,34 +212,10 @@ const DateMenuButton = new Lang.Class({
this._dateAndTimeSeparator.actor.visible = Main.sessionMode.allowSettings;
},
- _getCalendarApp: function() {
- if (this._calendarApp !== undefined)
- return this._calendarApp;
-
- let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
- if (apps && (apps.length > 0)) {
- let app = Gio.AppInfo.get_default_for_type('text/calendar', false);
- let defaultInRecommended = apps.some(function(a) { return a.equal(app); });
- this._calendarApp = defaultInRecommended ? app : apps[0];
- } else {
- this._calendarApp = null;
- }
- return this._calendarApp;
- },
-
_getClockApp: function() {
return Shell.AppSystem.get_default().lookup_app('org.gnome.clocks.desktop');
},
- _onOpenCalendarActivate: function() {
- this.menu.close();
-
- let app = this._getCalendarApp();
- if (app.get_id() == 'evolution.desktop')
- app = Gio.DesktopAppInfo.new('evolution-calendar.desktop');
- app.launch([], global.create_app_launch_context(0, -1));
- },
-
_onOpenClocksActivate: function() {
this.menu.close();
let app = this._getClockApp();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]