messageTray: Make clear item insensetive when there is nothing to clear
There is no point in having a menu entry that does nothing so set the item to insensitive when there are no items to clear.
This commit is contained in:
parent
cdc8dd88e9
commit
2138fc2349
@ -1457,8 +1457,9 @@ const MessageTrayContextMenu = new Lang.Class({
|
||||
Main.uiGroup.add_actor(this._dummy);
|
||||
|
||||
this.parent(this._dummy, 0, St.Side.BOTTOM);
|
||||
this._tray = tray;
|
||||
|
||||
this.addAction(_("Clear"), function() {
|
||||
this._clearItem = this.addAction(_("Clear"), function() {
|
||||
let toDestroy = [];
|
||||
let sources = tray.getSources();
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
@ -1478,6 +1479,10 @@ const MessageTrayContextMenu = new Lang.Class({
|
||||
tray.close();
|
||||
});
|
||||
|
||||
tray.connect('source-added', Lang.bind(this, this._updateClearSensitivity));
|
||||
tray.connect('source-removed', Lang.bind(this, this._updateClearSensitivity));
|
||||
this._updateClearSensitivity();
|
||||
|
||||
let separator = new PopupMenu.PopupSeparatorMenuItem();
|
||||
this.addMenuItem(separator);
|
||||
|
||||
@ -1485,6 +1490,14 @@ const MessageTrayContextMenu = new Lang.Class({
|
||||
settingsItem.connect('activate', function() { tray.close(); });
|
||||
},
|
||||
|
||||
_updateClearSensitivity: function() {
|
||||
let sources = this._tray.getSources();
|
||||
sources = sources.filter(function(source) {
|
||||
return !source.trayIcon && !source.isChat && !source.resident;
|
||||
});
|
||||
this._clearItem.setSensitive(sources.length > 0);
|
||||
},
|
||||
|
||||
setPosition: function(x, y) {
|
||||
this._dummy.set_position(x, y);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user