[gnome-shell] dateMenu: Update message indicator on queue changes



commit 880b240ecbec90825179faa933545d842dd04382
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Feb 21 09:59:24 2015 +0100

    dateMenu: Update message indicator on queue changes
    
    The message indicator conveys that the message list contains unseen
    messages that will not be shown as banner. So its visibility depends
    on two factors: the number of unseen messages, and the number of
    messages waiting in the queue to be shown as banner. As we currently
    only update the visibility on changes to the former, the indicator is
    not always accurate - for instance sources notify count changes before
    passing on a notification to the message tray for display.
    To fix, add a signal to the message tray to notify when the queue
    changes and use it to update the indicator's visibility.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744880

 js/ui/dateMenu.js    |    1 +
 js/ui/messageTray.js |   11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 55b360b..a36da31 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -231,6 +231,7 @@ const MessagesIndicator = new Lang.Class({
 
         Main.messageTray.connect('source-added', Lang.bind(this, this._onSourceAdded));
         Main.messageTray.connect('source-removed', Lang.bind(this, this._onSourceRemoved));
+        Main.messageTray.connect('queue-changed', Lang.bind(this, this._updateCount));
 
         let sources = Main.messageTray.getSources();
         sources.forEach(Lang.bind(this, function(source) { this._onSourceAdded(null, source); }));
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 345dede..c66e7b9 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1662,8 +1662,10 @@ const MessageTray = new Lang.Class({
         }
 
         let index = this._notificationQueue.indexOf(notification);
-        if (index != -1)
+        if (index != -1) {
             this._notificationQueue.splice(index, 1);
+            this.emit('queue-changed');
+        }
     },
 
     _onNotify: function(source, notification) {
@@ -1686,6 +1688,7 @@ const MessageTray = new Lang.Class({
                 this._notificationQueue.sort(function(notification1, notification2) {
                     return (notification2.urgency - notification1.urgency);
                 });
+                this.emit('queue-changed');
             }
         }
         this._updateState();
@@ -1806,10 +1809,15 @@ const MessageTray = new Lang.Class({
         this._updatingState = true;
 
         // Filter out acknowledged notifications.
+        let changed = false;
         this._notificationQueue = this._notificationQueue.filter(function(n) {
+            changed = changed || n.acknowledged;
             return !n.acknowledged;
         });
 
+        if (changed)
+            this.emit('queue-changed');
+
         let hasNotifications = Main.sessionMode.hasNotifications;
 
         if (this._notificationState == State.HIDDEN) {
@@ -1881,6 +1889,7 @@ const MessageTray = new Lang.Class({
 
     _showNotification: function() {
         this._notification = this._notificationQueue.shift();
+        this.emit('queue-changed');
 
         this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME;
         if (!this._userActiveWhileNotificationShown) {


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