84
85
vbox.add(this._calendar.actor);
86
item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop');
87
let separator = new PopupMenu.PopupSeparatorMenuItem();
88
separator.setColumnWidths(1);
89
vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false});
91
this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
92
this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
93
this._openCalendarItem.actor.can_focus = false;
94
vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
96
this._openClocksItem = new PopupMenu.PopupMenuItem(_("Open Clocks"));
97
this._openClocksItem.connect('activate', Lang.bind(this, this._onOpenClocksActivate));
98
this._openClocksItem.actor.can_focus = false;
99
vbox.add(this._openClocksItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
101
Shell.AppSystem.get_default().connect('installed-changed',
102
Lang.bind(this, this._appInstalledChanged));
104
item = this.menu.addSettingsAction(_("Date & Time Settings"), 'gnome-datetime-panel.desktop');
88
let separator = new PopupMenu.PopupSeparatorMenuItem();
89
separator.setColumnWidths(1);
90
vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false});
92
106
item.actor.show_on_set_parent = false;
93
107
item.actor.can_focus = false;
94
108
item.actor.reparent(vbox);
109
123
vbox.add(this._eventList.actor, { expand: true });
111
this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
112
this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
113
this._openCalendarItem.actor.can_focus = false;
114
vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
116
this._calendarSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.office.calendar' });
117
this._calendarSettings.connect('changed::exec',
118
Lang.bind(this, this._calendarSettingsChanged));
119
this._calendarSettingsChanged();
121
125
// Whenever the menu is opened, select today
122
126
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
151
155
this._sessionUpdated();
154
_calendarSettingsChanged: function() {
155
let exec = this._calendarSettings.get_string('exec');
156
let fullExec = GLib.find_program_in_path(exec);
157
this._openCalendarItem.actor.visible = fullExec != null;
158
_appInstalledChanged: function() {
159
this._calendarApp = undefined;
160
this._updateEventsVisibility();
160
_setEventsVisibility: function(visible) {
161
this._openCalendarItem.actor.visible = visible;
163
_updateEventsVisibility: function() {
164
let visible = this._eventSource.hasCalendars;
165
this._openCalendarItem.actor.visible = visible &&
166
(this._getCalendarApp() != null);
167
this._openClocksItem.actor.visible = visible &&
168
(this._getClockApp() != null);
162
169
this._separator.visible = visible;
164
171
let alignment = 0.25;
175
182
_setEventSource: function(eventSource) {
183
if (this._eventSource)
184
this._eventSource.destroy();
176
186
this._calendar.setEventSource(eventSource);
177
187
this._eventList.setEventSource(eventSource);
189
this._eventSource = eventSource;
190
this._eventSource.connect('notify::has-calendars', Lang.bind(this, function() {
191
this._updateEventsVisibility();
180
195
_sessionUpdated: function() {
183
198
if (showEvents) {
184
199
eventSource = new Calendar.DBusEventSource();
201
eventSource = new Calendar.EmptyEventSource();
188
203
this._setEventSource(eventSource);
189
this._setEventsVisibility(showEvents);
204
this._updateEventsVisibility();
191
206
// This needs to be handled manually, as the code to
192
207
// autohide separators doesn't work across the vbox
203
218
this._date.set_text(displayDate.toLocaleFormat(dateFormat));
221
_getCalendarApp: function() {
222
if (this._calendarApp !== undefined)
223
return this._calendarApp;
225
let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
226
if (apps && (apps.length > 0))
227
this._calendarApp = apps[0];
229
this._calendarApp = null;
230
return this._calendarApp;
233
_getClockApp: function() {
234
return Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
206
237
_onOpenCalendarActivate: function() {
207
238
this.menu.close();
208
let tool = this._calendarSettings.get_string('exec');
209
if (tool.length == 0 || tool.substr(0, 9) == 'evolution') {
210
// TODO: pass the selected day
211
let app = Shell.AppSystem.get_default().lookup_app('evolution-calendar.desktop');
214
let needTerm = this._calendarSettings.get_boolean('needs-term');
216
let terminalSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.terminal' });
217
let term = terminalSettings.get_string('exec');
218
let arg = terminalSettings.get_string('exec-arg');
220
Util.spawn([term, arg, tool]);
222
Util.spawn([term, tool]);
224
Util.spawnCommandLine(tool)
240
let app = this._getCalendarApp();
241
if (app.get_id() == 'evolution.desktop')
242
app = Gio.DesktopAppInfo.new('evolution-calendar.desktop');
243
app.launch([], global.create_app_launch_context());
246
_onOpenClocksActivate: function() {
248
let app = this._getClockApp();