Calendar: clean up code by always having an event source

Instead of sometimes having an event source and sometimes not, use
the empty event source when the session mode says the calendar is
disabled. This way, the code can assume an event source object and
avoid checks.

https://bugzilla.gnome.org/show_bug.cgi?id=641383
This commit is contained in:
Giovanni Campagna
2013-03-04 17:04:28 +01:00
parent 443fe813c3
commit beb0fdf4b8
2 changed files with 23 additions and 29 deletions

View File

@ -177,8 +177,13 @@ const DateMenuButton = new Lang.Class({
},
_setEventSource: function(eventSource) {
if (this._eventSource)
this._eventSource.destroy();
this._calendar.setEventSource(eventSource);
this._eventList.setEventSource(eventSource);
this._eventSource = eventSource;
},
_sessionUpdated: function() {
@ -187,7 +192,7 @@ const DateMenuButton = new Lang.Class({
if (showEvents) {
eventSource = new Calendar.DBusEventSource();
} else {
eventSource = null;
eventSource = new Calendar.EmptyEventSource();
}
this._setEventSource(eventSource);
this._setEventsVisibility(showEvents);