calendar: Respect session mode for section visibility
It doesn't make much sense to show a section if it must remain empty due to the session mode - there won't be any events if the session mode disallows events, or notifications if those are disallowed. So take the session mode into account and update the sections' visibility accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=745494
This commit is contained in:
parent
61c5f259ec
commit
313ee70cf7
@ -1269,6 +1269,12 @@ const MessageListSection = new Lang.Class({
|
||||
this._list.connect('actor-added', Lang.bind(this, this._sync));
|
||||
this._list.connect('actor-removed', Lang.bind(this, this._sync));
|
||||
|
||||
let id = Main.sessionMode.connect('updated',
|
||||
Lang.bind(this, this._sync));
|
||||
this.actor.connect('destroy', function() {
|
||||
Main.sessionMode.disconnect(id);
|
||||
});
|
||||
|
||||
this._messages = new Map();
|
||||
this._date = new Date();
|
||||
this.empty = true;
|
||||
@ -1284,6 +1290,10 @@ const MessageListSection = new Lang.Class({
|
||||
this.emit('key-focus-in', actor);
|
||||
},
|
||||
|
||||
get allowed() {
|
||||
return true;
|
||||
},
|
||||
|
||||
setDate: function(date) {
|
||||
if (_sameDay(date, this._date))
|
||||
return;
|
||||
@ -1391,8 +1401,8 @@ const MessageListSection = new Lang.Class({
|
||||
return _sameDay(this._date, today);
|
||||
},
|
||||
|
||||
_syncVisible: function() {
|
||||
this.actor.visible = !this.empty;
|
||||
_shouldShow: function() {
|
||||
return !this.empty;
|
||||
},
|
||||
|
||||
_sync: function() {
|
||||
@ -1404,7 +1414,7 @@ const MessageListSection = new Lang.Class({
|
||||
this.emit('empty-changed');
|
||||
|
||||
this._closeButton.visible = this._canClear();
|
||||
this._syncVisible();
|
||||
this.actor.visible = this.allowed && this._shouldShow();
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(MessageListSection.prototype);
|
||||
@ -1430,6 +1440,10 @@ const EventsSection = new Lang.Class({
|
||||
this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents));
|
||||
},
|
||||
|
||||
get allowed() {
|
||||
return Main.sessionMode.showCalendarEvents;
|
||||
},
|
||||
|
||||
_updateTitle: function() {
|
||||
let now = new Date();
|
||||
if (_sameDay(this._date, now)) {
|
||||
@ -1521,8 +1535,8 @@ const EventsSection = new Lang.Class({
|
||||
this._reloadEvents();
|
||||
},
|
||||
|
||||
_syncVisible: function() {
|
||||
this.actor.visible = !this.empty || !this._isToday();
|
||||
_shouldShow: function() {
|
||||
return !this.empty || !this._isToday();
|
||||
},
|
||||
|
||||
_sync: function() {
|
||||
@ -1549,9 +1563,11 @@ const NotificationSection = new Lang.Class({
|
||||
}));
|
||||
|
||||
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
|
||||
},
|
||||
|
||||
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
||||
this._sessionUpdated();
|
||||
get allowed() {
|
||||
return Main.sessionMode.hasNotifications &&
|
||||
!Main.sessionMode.isGreeter;
|
||||
},
|
||||
|
||||
_sourceAdded: function(tray, source) {
|
||||
@ -1627,11 +1643,12 @@ const NotificationSection = new Lang.Class({
|
||||
app.activate();
|
||||
},
|
||||
|
||||
_syncVisible: function() {
|
||||
this.actor.visible = !this.empty && this._isToday();
|
||||
_shouldShow: function() {
|
||||
return !this.empty && this._isToday();
|
||||
},
|
||||
|
||||
_sessionUpdated: function() {
|
||||
_sync: function() {
|
||||
this.parent();
|
||||
this._title.reactive = Main.sessionMode.allowSettings;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user