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. https://bugzilla.gnome.org/show_bug.cgi?id=657082
This commit is contained in:
parent
5be9326192
commit
b6c2399a17
@ -351,12 +351,14 @@ function Calendar(eventSource) {
|
|||||||
|
|
||||||
Calendar.prototype = {
|
Calendar.prototype = {
|
||||||
_init: function(eventSource) {
|
_init: function(eventSource) {
|
||||||
|
if (eventSource) {
|
||||||
this._eventSource = eventSource;
|
this._eventSource = eventSource;
|
||||||
|
|
||||||
this._eventSource.connect('changed', Lang.bind(this,
|
this._eventSource.connect('changed', Lang.bind(this,
|
||||||
function() {
|
function() {
|
||||||
this._update(false);
|
this._update(false);
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
this._weekStart = Shell.util_get_week_start();
|
this._weekStart = Shell.util_get_week_start();
|
||||||
this._weekdate = NaN;
|
this._weekdate = NaN;
|
||||||
@ -554,13 +556,16 @@ Calendar.prototype = {
|
|||||||
while (true) {
|
while (true) {
|
||||||
let button = new St.Button({ label: iter.getDate().toString() });
|
let button = new St.Button({ label: iter.getDate().toString() });
|
||||||
|
|
||||||
|
if (!this._eventSource)
|
||||||
|
button.reactive = false;
|
||||||
|
|
||||||
let iterStr = iter.toUTCString();
|
let iterStr = iter.toUTCString();
|
||||||
button.connect('clicked', Lang.bind(this, function() {
|
button.connect('clicked', Lang.bind(this, function() {
|
||||||
let newlySelectedDate = new Date(iterStr);
|
let newlySelectedDate = new Date(iterStr);
|
||||||
this.setDate(newlySelectedDate, false);
|
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';
|
let styleClass = 'calendar-day-base calendar-day';
|
||||||
if (_isWorkDay(iter))
|
if (_isWorkDay(iter))
|
||||||
styleClass += ' calendar-work-day'
|
styleClass += ' calendar-work-day'
|
||||||
@ -607,6 +612,7 @@ Calendar.prototype = {
|
|||||||
}
|
}
|
||||||
// Signal to the event source that we are interested in events
|
// Signal to the event source that we are interested in events
|
||||||
// only from this date range
|
// only from this date range
|
||||||
|
if (this._eventSource)
|
||||||
this._eventSource.requestRange(beginDate, iter, forceReload);
|
this._eventSource.requestRange(beginDate, iter, forceReload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -644,6 +650,9 @@ EventsList.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_addPeriod: function(header, begin, end, includeDayName, showNothingScheduled) {
|
_addPeriod: function(header, begin, end, includeDayName, showNothingScheduled) {
|
||||||
|
if (!this._eventSource)
|
||||||
|
return;
|
||||||
|
|
||||||
let events = this._eventSource.getEvents(begin, end);
|
let events = this._eventSource.getEvents(begin, end);
|
||||||
|
|
||||||
let clockFormat = this._desktopSettings.get_string(CLOCK_FORMAT_KEY);;
|
let clockFormat = this._desktopSettings.get_string(CLOCK_FORMAT_KEY);;
|
||||||
|
@ -9,6 +9,7 @@ const Clutter = imports.gi.Clutter;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
|
const Params = imports.misc.params;
|
||||||
const Util = imports.misc.util;
|
const Util = imports.misc.util;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
@ -40,19 +41,19 @@ function _onVertSepRepaint (area)
|
|||||||
};
|
};
|
||||||
|
|
||||||
function DateMenuButton() {
|
function DateMenuButton() {
|
||||||
this._init();
|
this._init.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
DateMenuButton.prototype = {
|
DateMenuButton.prototype = {
|
||||||
__proto__: PanelMenu.Button.prototype,
|
__proto__: PanelMenu.Button.prototype,
|
||||||
|
|
||||||
_init: function() {
|
_init: function(params) {
|
||||||
|
params = Params.parse(params, { showEvents: true });
|
||||||
|
|
||||||
let item;
|
let item;
|
||||||
let hbox;
|
let hbox;
|
||||||
let vbox;
|
let vbox;
|
||||||
|
|
||||||
this._eventSource = new Calendar.DBusEventSource();
|
|
||||||
|
|
||||||
let menuAlignment = 0.25;
|
let menuAlignment = 0.25;
|
||||||
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
||||||
menuAlignment = 1.0 - menuAlignment;
|
menuAlignment = 1.0 - menuAlignment;
|
||||||
@ -74,12 +75,23 @@ DateMenuButton.prototype = {
|
|||||||
this._date.style_class = 'datemenu-date-label';
|
this._date.style_class = 'datemenu-date-label';
|
||||||
vbox.add(this._date);
|
vbox.add(this._date);
|
||||||
|
|
||||||
|
if (params.showEvents) {
|
||||||
|
this._eventSource = new Calendar.DBusEventSource();
|
||||||
this._eventList = new Calendar.EventsList(this._eventSource);
|
this._eventList = new Calendar.EventsList(this._eventSource);
|
||||||
|
} else {
|
||||||
|
this._eventSource = null;
|
||||||
|
this._eventList = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Calendar
|
// Calendar
|
||||||
this._calendar = new Calendar.Calendar(this._eventSource);
|
this._calendar = new Calendar.Calendar(this._eventSource);
|
||||||
|
|
||||||
this._calendar.connect('selected-date-changed',
|
this._calendar.connect('selected-date-changed',
|
||||||
Lang.bind(this, function(calendar, date) {
|
Lang.bind(this, function(calendar, date) {
|
||||||
|
// we know this._eventList is defined here, because selected-data-changed
|
||||||
|
// only gets emitted when the user clicks a date in the calendar,
|
||||||
|
// and the calender makes those dates unclickable when instantiated with
|
||||||
|
// a null event source
|
||||||
this._eventList.setDate(date);
|
this._eventList.setDate(date);
|
||||||
}));
|
}));
|
||||||
vbox.add(this._calendar.actor);
|
vbox.add(this._calendar.actor);
|
||||||
@ -93,6 +105,7 @@ DateMenuButton.prototype = {
|
|||||||
item.actor.can_focus = false;
|
item.actor.can_focus = false;
|
||||||
item.actor.reparent(vbox);
|
item.actor.reparent(vbox);
|
||||||
|
|
||||||
|
if (params.showEvents) {
|
||||||
// Add vertical separator
|
// Add vertical separator
|
||||||
|
|
||||||
item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
|
item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
|
||||||
@ -112,6 +125,7 @@ DateMenuButton.prototype = {
|
|||||||
item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
|
item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
|
||||||
item.actor.can_focus = false;
|
item.actor.can_focus = false;
|
||||||
vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
|
vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
|
||||||
|
}
|
||||||
|
|
||||||
// Whenever the menu is opened, select today
|
// Whenever the menu is opened, select today
|
||||||
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
|
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user