[gnome-shell] [MessageTray] handle "urgent" notifications specially



commit 263261cc86d8536974a844b84596b8820c674bf1
Author: Dan Winship <danw gnome org>
Date:   Wed Apr 28 15:34:27 2010 -0400

    [MessageTray] handle "urgent" notifications specially
    
    Urgent notifications jump to the front of the tray's notification
    queue, and come up pre-expanded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=611612

 js/ui/messageTray.js        |   17 ++++++++++++++++-
 js/ui/notificationDaemon.js |   11 +++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 58e68a0..df695e8 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -70,6 +70,7 @@ Notification.prototype = {
         this.id = id;
         this.source = source;
         this._bannerBody = bannerBody;
+        this.urgent = false;
 
         source.connect('clicked', Lang.bind(this,
             function() {
@@ -265,6 +266,10 @@ Notification.prototype = {
         button.connect('clicked', Lang.bind(this, function() { this.emit('action-invoked', id); }));
     },
 
+    setUrgent: function(urgent) {
+        this.urgent = urgent;
+    },
+
     _styleChanged: function() {
         let [has_spacing, spacing] = this.actor.get_theme_node().get_length('spacing-columns', false);
         this._spacing = has_spacing ? spacing : 0;
@@ -611,7 +616,11 @@ MessageTray.prototype = {
         if (this._getNotification(notification.id, source) == null) {
             notification.connect('destroy',
                                  Lang.bind(this, this.removeNotification));
-            this._notificationQueue.push(notification);
+
+            if (notification.urgent)
+                this._notificationQueue.unshift(notification);
+            else
+                this._notificationQueue.push(notification);
         }
 
         this._updateState();
@@ -805,6 +814,12 @@ MessageTray.prototype = {
                       onComplete: this._showNotificationCompleted,
                       onCompleteScope: this
                     });
+
+        if (this._notification.urgent) {
+            // This will overwrite the y tween, but leave the opacity
+            // tween, and so the onComplete will remain as well.
+            this._expandNotification();
+        }
     },
 
     _showNotificationCompleted: function() {
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index dc8f08d..7054bdc 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -151,8 +151,11 @@ NotificationDaemon.prototype = {
             return id;
         }
 
-        // Source may be null if we have never received a notification from
-        // this app or if all notifications from this app have been acknowledged.
+        hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
+
+        // Source may be null if we have never received a notification
+        // from this app or if all notifications from this app have
+        // been acknowledged.
         if (source == null) {
             source = new Source(this._sourceId(appName), icon, hints);
             Main.messageTray.add(source);
@@ -211,6 +214,8 @@ NotificationDaemon.prototype = {
             notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
         }
 
+        notification.setUrgent(hints.urgency == Urgency.CRITICAL);
+
         source.notify(notification);
         return id;
     },
@@ -290,8 +295,6 @@ Source.prototype = {
     },
 
     update: function(icon, hints) {
-        hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
-
         this._icon = icon;
         this._iconData = hints.icon_data;
         this._urgency = hints.urgency;



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