messageList: Make canClear public and notify on changes

The latest mockups contain a button to clear all sections at once.
As some elements cannot be cleared, we need to provide that information
to avoid offering an action that has no effect.

https://bugzilla.gnome.org/show_bug.cgi?id=775763
This commit is contained in:
Florian Müllner 2017-02-26 22:23:11 +01:00
parent 0e0caee6ba
commit 239b67eff6

View File

@ -563,6 +563,7 @@ const MessageListSection = new Lang.Class({
this._messages = new Map(); this._messages = new Map();
this._date = new Date(); this._date = new Date();
this.empty = true; this.empty = true;
this.canClear = false;
this._sync(); this._sync();
}, },
@ -719,7 +720,14 @@ const MessageListSection = new Lang.Class({
if (changed) if (changed)
this.emit('empty-changed'); this.emit('empty-changed');
this._closeButton.visible = this._canClear(); let canClear = this._canClear();
changed = this.canClear !== canClear;
this.canClear = canClear;
if (changed)
this.emit('can-clear-changed');
this._closeButton.visible = this.canClear;
this.actor.visible = this.allowed && this._shouldShow(); this.actor.visible = this.allowed && this._shouldShow();
} }
}); });