[gnome-shell/wip/gdm-shell: 13/16] dateMenu: Make events list optional
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/gdm-shell: 13/16] dateMenu: Make events list optional
- Date: Wed, 24 Aug 2011 15:11:06 +0000 (UTC)
commit f5c8655c46ce36fb1f68157af2fdf758d3ea2f90
Author: Ray Strode <rstrode redhat com>
Date: Mon Aug 22 14:21:51 2011 -0400
dateMenu: Make events list optional
Right now, when a user clicks on the panel clock, a menu pops up with a
calendar and a list of events from the user's schedule. The list of
events only makes sense from within a user's session, however.
As part of the prep work for making the shell a platform for the login
screen, this commit makes the events list optional.
js/ui/calendar.js | 20 +++++++++++------
js/ui/dateMenu.js | 59 +++++++++++++++++++++++++++++++---------------------
2 files changed, 48 insertions(+), 31 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index f5448f0..57714b1 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -351,12 +351,14 @@ function Calendar(eventSource) {
Calendar.prototype = {
_init: function(eventSource) {
- this._eventSource = eventSource;
+ if (eventSource) {
+ this._eventSource = eventSource;
- this._eventSource.connect('changed', Lang.bind(this,
- function() {
- this._update(false);
- }));
+ this._eventSource.connect('changed', Lang.bind(this,
+ function() {
+ this._update(false);
+ }));
+ }
this._weekStart = Shell.util_get_week_start();
this._weekdate = NaN;
@@ -560,7 +562,7 @@ Calendar.prototype = {
this.setDate(newlySelectedDate, false);
}));
- let hasEvents = this._eventSource.hasEvents(iter);
+ let hasEvents = this._eventSource && this._eventSource.hasEvents(iter);
let styleClass = 'calendar-day-base calendar-day';
if (_isWorkDay(iter))
styleClass += ' calendar-work-day'
@@ -607,7 +609,8 @@ Calendar.prototype = {
}
// Signal to the event source that we are interested in events
// only from this date range
- this._eventSource.requestRange(beginDate, iter, forceReload);
+ if (this._eventSource)
+ this._eventSource.requestRange(beginDate, iter, forceReload);
}
};
@@ -644,6 +647,9 @@ EventsList.prototype = {
},
_addPeriod: function(header, begin, end, includeDayName, showNothingScheduled) {
+ if (!this._eventSource)
+ return;
+
let events = this._eventSource.getEvents(begin, end);
let clockFormat = this._desktopSettings.get_string(CLOCK_FORMAT_KEY);;
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index cb41ec2..7c0356c 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -9,6 +9,7 @@ const Clutter = imports.gi.Clutter;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
+const Params = imports.misc.params;
const Util = imports.misc.util;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
@@ -40,19 +41,19 @@ function _onVertSepRepaint (area)
};
function DateMenuButton() {
- this._init();
+ this._init.apply(this, arguments);
}
DateMenuButton.prototype = {
__proto__: PanelMenu.Button.prototype,
- _init: function() {
+ _init: function(params) {
+ let params = Params.parse(params, { showEvents: true });
+
let item;
let hbox;
let vbox;
- this._eventSource = new Calendar.DBusEventSource();
-
let menuAlignment = 0.25;
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
menuAlignment = 1.0 - menuAlignment;
@@ -74,14 +75,22 @@ DateMenuButton.prototype = {
this._date.style_class = 'datemenu-date-label';
vbox.add(this._date);
- this._eventList = new Calendar.EventsList(this._eventSource);
+ if (params.showEvents) {
+ this._eventSource = new Calendar.DBusEventSource();
+ this._eventList = new Calendar.EventsList(this._eventSource);
+ } else {
+ this._eventSource = null;
+ this._eventList = null;
+ }
// Calendar
this._calendar = new Calendar.Calendar(this._eventSource);
- this._calendar.connect('selected-date-changed',
- Lang.bind(this, function(calendar, date) {
- this._eventList.setDate(date);
- }));
+ if (this._eventList) {
+ this._calendar.connect('selected-date-changed',
+ Lang.bind(this, function(calendar, date) {
+ this._eventList.setDate(date);
+ }));
+ }
vbox.add(this._calendar.actor);
item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop');
@@ -95,25 +104,27 @@ DateMenuButton.prototype = {
item.actor.reparent(vbox);
}
- // Add vertical separator
+ if (params.showEvents) {
+ // Add vertical separator
- item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
- pseudo_class: 'highlighted' });
- item.connect('repaint', Lang.bind(this, _onVertSepRepaint));
- hbox.add(item);
+ item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
+ pseudo_class: 'highlighted' });
+ item.connect('repaint', Lang.bind(this, _onVertSepRepaint));
+ hbox.add(item);
- // Fill up the second column
- vbox = new St.BoxLayout({ name: 'calendarEventsArea',
- vertical: true});
- hbox.add(vbox, { expand: true });
+ // Fill up the second column
+ vbox = new St.BoxLayout({ name: 'calendarEventsArea',
+ vertical: true});
+ hbox.add(vbox, { expand: true });
- // Event list
- vbox.add(this._eventList.actor, { expand: true });
+ // Event list
+ vbox.add(this._eventList.actor, { expand: true });
- item = new PopupMenu.PopupMenuItem(_("Open Calendar"));
- item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
- item.actor.can_focus = false;
- vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
+ item = new PopupMenu.PopupMenuItem(_("Open Calendar"));
+ item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
+ item.actor.can_focus = false;
+ vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
+ }
// Whenever the menu is opened, select today
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]