[gnome-shell] messageTray: Add option to (un)mute conversations



commit 3652e42699cd61627078c28b88bbb97168f3bd72
Author: Ana Risteska <a risteska gmail com>
Date:   Thu Nov 3 15:48:09 2011 +0100

    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

 js/ui/messageTray.js |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index ca12fb1..44c1fe1 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -991,6 +991,7 @@ Source.prototype = {
 
         this.isTransient = false;
         this.isChat = false;
+        this.isMuted = false;
 
         this.notifications = [];
     },
@@ -1055,6 +1056,13 @@ Source.prototype = {
         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).
     // Must be overridden by the subclass if you do not pass icons
     // explicitly to the Notification() constructor.
@@ -1093,7 +1101,8 @@ Source.prototype = {
 
     notify: function(notification) {
         this.pushNotification(notification);
-        this.emit('notify', notification);
+        if (!this.isMuted)
+             this.emit('notify', notification);
     },
 
     destroy: function(reason) {
@@ -1209,6 +1218,18 @@ SummaryItem.prototype = {
         }));
         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);
         focusManager.add_group(this.rightClickMenu);
     },
@@ -1517,6 +1538,14 @@ MessageTray.prototype = {
 
         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,
             function () {
                 this._onSummaryItemHoverChanged(summaryItem);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]