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-added', Lang.bind(this, this._sync));
|
||||||
this._list.connect('actor-removed', 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._messages = new Map();
|
||||||
this._date = new Date();
|
this._date = new Date();
|
||||||
this.empty = true;
|
this.empty = true;
|
||||||
@ -1284,6 +1290,10 @@ const MessageListSection = new Lang.Class({
|
|||||||
this.emit('key-focus-in', actor);
|
this.emit('key-focus-in', actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get allowed() {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
setDate: function(date) {
|
setDate: function(date) {
|
||||||
if (_sameDay(date, this._date))
|
if (_sameDay(date, this._date))
|
||||||
return;
|
return;
|
||||||
@ -1391,8 +1401,8 @@ const MessageListSection = new Lang.Class({
|
|||||||
return _sameDay(this._date, today);
|
return _sameDay(this._date, today);
|
||||||
},
|
},
|
||||||
|
|
||||||
_syncVisible: function() {
|
_shouldShow: function() {
|
||||||
this.actor.visible = !this.empty;
|
return !this.empty;
|
||||||
},
|
},
|
||||||
|
|
||||||
_sync: function() {
|
_sync: function() {
|
||||||
@ -1404,7 +1414,7 @@ const MessageListSection = new Lang.Class({
|
|||||||
this.emit('empty-changed');
|
this.emit('empty-changed');
|
||||||
|
|
||||||
this._closeButton.visible = this._canClear();
|
this._closeButton.visible = this._canClear();
|
||||||
this._syncVisible();
|
this.actor.visible = this.allowed && this._shouldShow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Signals.addSignalMethods(MessageListSection.prototype);
|
Signals.addSignalMethods(MessageListSection.prototype);
|
||||||
@ -1430,6 +1440,10 @@ const EventsSection = new Lang.Class({
|
|||||||
this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents));
|
this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get allowed() {
|
||||||
|
return Main.sessionMode.showCalendarEvents;
|
||||||
|
},
|
||||||
|
|
||||||
_updateTitle: function() {
|
_updateTitle: function() {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
if (_sameDay(this._date, now)) {
|
if (_sameDay(this._date, now)) {
|
||||||
@ -1521,8 +1535,8 @@ const EventsSection = new Lang.Class({
|
|||||||
this._reloadEvents();
|
this._reloadEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
_syncVisible: function() {
|
_shouldShow: function() {
|
||||||
this.actor.visible = !this.empty || !this._isToday();
|
return !this.empty || !this._isToday();
|
||||||
},
|
},
|
||||||
|
|
||||||
_sync: function() {
|
_sync: function() {
|
||||||
@ -1549,9 +1563,11 @@ const NotificationSection = new Lang.Class({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
|
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
|
||||||
|
},
|
||||||
|
|
||||||
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
get allowed() {
|
||||||
this._sessionUpdated();
|
return Main.sessionMode.hasNotifications &&
|
||||||
|
!Main.sessionMode.isGreeter;
|
||||||
},
|
},
|
||||||
|
|
||||||
_sourceAdded: function(tray, source) {
|
_sourceAdded: function(tray, source) {
|
||||||
@ -1627,11 +1643,12 @@ const NotificationSection = new Lang.Class({
|
|||||||
app.activate();
|
app.activate();
|
||||||
},
|
},
|
||||||
|
|
||||||
_syncVisible: function() {
|
_shouldShow: function() {
|
||||||
this.actor.visible = !this.empty && this._isToday();
|
return !this.empty && this._isToday();
|
||||||
},
|
},
|
||||||
|
|
||||||
_sessionUpdated: function() {
|
_sync: function() {
|
||||||
|
this.parent();
|
||||||
this._title.reactive = Main.sessionMode.allowSettings;
|
this._title.reactive = Main.sessionMode.allowSettings;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user