messageTray: Add option to (un)mute conversations

Add "Mute"/"Unmute" option to the right click menu for chats to allow muting conversations
without blocking the sender or disabling all non-urgent notifications. Muting a conversation
prevents the pop up of notifications on new messages from the muted source, while these
messages are still available from the summary notification in the message tray.

https://bugzilla.gnome.org/show_bug.cgi?id=659962
This commit is contained in:
Ana Risteska 2011-11-03 15:48:09 +01:00 committed by Marina Zhurakhinskaya
parent 398489f661
commit 3652e42699

View File

@ -991,6 +991,7 @@ Source.prototype = {
this.isTransient = false; this.isTransient = false;
this.isChat = false; this.isChat = false;
this.isMuted = false;
this.notifications = []; this.notifications = [];
}, },
@ -1055,6 +1056,13 @@ Source.prototype = {
this.emit('title-changed'); this.emit('title-changed');
}, },
setMuted: function(muted) {
if (!this.isChat || this.isMuted == muted)
return;
this.isMuted = muted;
this.emit('muted-changed');
},
// Called to create a new icon actor (of size this.ICON_SIZE). // Called to create a new icon actor (of size this.ICON_SIZE).
// Must be overridden by the subclass if you do not pass icons // Must be overridden by the subclass if you do not pass icons
// explicitly to the Notification() constructor. // explicitly to the Notification() constructor.
@ -1093,6 +1101,7 @@ Source.prototype = {
notify: function(notification) { notify: function(notification) {
this.pushNotification(notification); this.pushNotification(notification);
if (!this.isMuted)
this.emit('notify', notification); this.emit('notify', notification);
}, },
@ -1209,6 +1218,18 @@ SummaryItem.prototype = {
})); }));
this.rightClickMenu.add(item.actor); this.rightClickMenu.add(item.actor);
if (source.isChat) {
item = new PopupMenu.PopupMenuItem('');
item.actor.connect('notify::mapped', Lang.bind(this, function() {
item.label.set_text(source.isMuted ? _("Unmute") : _("Mute"));
}));
item.connect('activate', Lang.bind(this, function() {
source.setMuted(!source.isMuted);
this.emit('done-displaying-content');
}));
this.rightClickMenu.add(item.actor);
}
let focusManager = St.FocusManager.get_for_stage(global.stage); let focusManager = St.FocusManager.get_for_stage(global.stage);
focusManager.add_group(this.rightClickMenu); focusManager.add_group(this.rightClickMenu);
}, },
@ -1517,6 +1538,14 @@ MessageTray.prototype = {
source.connect('notify', Lang.bind(this, this._onNotify)); source.connect('notify', Lang.bind(this, this._onNotify));
source.connect('muted-changed', Lang.bind(this,
function () {
if (source.isMuted)
this._notificationQueue = this._notificationQueue.filter(function(notification) {
return source != notification.source;
});
}));
summaryItem.actor.connect('notify::hover', Lang.bind(this, summaryItem.actor.connect('notify::hover', Lang.bind(this,
function () { function () {
this._onSummaryItemHoverChanged(summaryItem); this._onSummaryItemHoverChanged(summaryItem);