[gnome-shell] Show feedback notifications when the user is busy



commit 39d9838cc186b2bc71d96af3cdbd91c382ec7d52
Author: StÃphane DÃmurget <stephane demurget free fr>
Date:   Fri Nov 2 18:06:40 2012 +0100

    Show feedback notifications when the user is busy
    
    Notifications that are created in response to direct user actions like
    "is ready" or "'foo' has been removed from favorites" should always be
    displayed even though the user has marked him/herself busy.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=662900

 js/ui/appFavorites.js           |   17 +++++++++++------
 js/ui/messageTray.js            |    8 +++++++-
 js/ui/overview.js               |   25 ++++++++++++++++++-------
 js/ui/windowAttentionHandler.js |    2 ++
 4 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js
index 21257bc..2c572d0 100644
--- a/js/ui/appFavorites.js
+++ b/js/ui/appFavorites.js
@@ -84,9 +84,12 @@ const AppFavorites = new Lang.Class({
 
         let app = Shell.AppSystem.get_default().lookup_app(appId);
 
-        Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()), Lang.bind(this, function () {
-            this._removeFavorite(appId);
-        }));
+        Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()),
+                                 { forFeedback: true,
+                                   undoCallback: Lang.bind(this, function () {
+                                                               this._removeFavorite(appId);
+                                                           })
+                                 });
     },
 
     addFavorite: function(appId) {
@@ -116,9 +119,11 @@ const AppFavorites = new Lang.Class({
             return;
 
         Main.overview.setMessage(_("%s has been removed from your favorites.").format(app.get_name()),
-                                 Lang.bind(this, function () {
-            this._addFavorite(appId, pos);
-        }));
+                                 { forFeedback: true,
+                                   undoCallback: Lang.bind(this, function () {
+                                                               this._addFavorite(appId, pos);
+                                                           })
+                                 });
     }
 });
 Signals.addSignalMethods(AppFavorites.prototype);
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 20358e1..2bbdfe8 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -314,6 +314,7 @@ const Notification = new Lang.Class({
         this.resident = false;
         // 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
         this.isTransient = false;
+        this.forFeedback = false;
         this.expanded = false;
         this.focused = false;
         this.acknowledged = false;
@@ -713,6 +714,10 @@ const Notification = new Lang.Class({
         this.isTransient = isTransient;
     },
 
+    setForFeedback: function(forFeedback) {
+        this.forFeedback = forFeedback;
+    },
+
     setUseActionIcons: function(useIcons) {
         this._useActionIcons = useIcons;
     },
@@ -1949,8 +1954,9 @@ const MessageTray = new Lang.Class({
         // Notifications
         let notificationQueue = this._notificationQueue;
         let notificationUrgent = notificationQueue.length > 0 && notificationQueue[0].urgency == Urgency.CRITICAL;
+        let notificationForFeedback = notificationQueue.length > 0 && notificationQueue[0].forFeedback;
         let notificationsLimited = this._busy || this._inFullscreen;
-        let notificationsPending = notificationQueue.length > 0 && (!notificationsLimited || notificationUrgent) && Main.sessionMode.hasNotifications;
+        let notificationsPending = notificationQueue.length > 0 && (!notificationsLimited || notificationUrgent || notificationForFeedback) && Main.sessionMode.hasNotifications;
         let nextNotification = notificationQueue.length > 0 ? notificationQueue[0] : null;
         let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
         let notificationExpanded = this._notification && this._notification.expanded;
diff --git a/js/ui/overview.js b/js/ui/overview.js
index fdfc65c..303cad5 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -57,7 +57,14 @@ const ShellInfo = new Lang.Class({
             this._source.destroy();
     },
 
-    setMessage: function(text, undoCallback, undoLabel) {
+    setMessage: function(text, options) {
+        options = Params.parse(options, { undoCallback: null,
+                                          forFeedback: false
+                                        });
+
+        let undoCallback = options.undoCallback;
+        let forFeedback = options.forFeedback;
+
         if (this._source == null) {
             this._source = new MessageTray.SystemNotificationSource();
             this._source.connect('destroy', Lang.bind(this,
@@ -71,6 +78,7 @@ const ShellInfo = new Lang.Class({
         if (this._source.notifications.length == 0) {
             notification = new MessageTray.Notification(this._source, text, null);
             notification.setTransient(true);
+            notification.setForFeedback(forFeedback);
         } else {
             notification = this._source.notifications[0];
             notification.update(text, null, { clear: true });
@@ -78,10 +86,8 @@ const ShellInfo = new Lang.Class({
 
         this._undoCallback = undoCallback;
         if (undoCallback) {
-            notification.addButton('system-undo',
-                                   undoLabel ? undoLabel : _("Undo"));
-            notification.connect('action-invoked',
-                                 Lang.bind(this, this._onUndoClicked));
+            notification.addButton('system-undo', _("Undo"));
+            notification.connect('action-invoked', Lang.bind(this, this._onUndoClicked));
         }
 
         this._source.notify(notification);
@@ -233,11 +239,16 @@ const Overview = new Lang.Class({
         this._viewSelector.removeSearchProvider(provider);
     },
 
-    setMessage: function(text, undoCallback, undoLabel) {
+    //
+    // options:
+    //  - undoCallback (function): the callback to be called if undo support is needed
+    //  - forFeedback (boolean): whether the message is for direct feedback of a user action
+    //
+    setMessage: function(text, options) {
         if (this.isDummy)
             return;
 
-        this._shellInfo.setMessage(text, undoCallback, undoLabel);
+        this._shellInfo.setMessage(text, options);
     },
 
     _onDragBegin: function() {
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
index 93b39b9..78e2061 100644
--- a/js/ui/windowAttentionHandler.js
+++ b/js/ui/windowAttentionHandler.js
@@ -39,6 +39,8 @@ const WindowAttentionHandler = new Lang.Class({
         let [title, banner] = this._getTitleAndBanner(app, window);
 
         let notification = new MessageTray.Notification(source, title, banner);
+        notification.setForFeedback(true);
+
         source.notify(notification);
 
         source.signalIDs.push(window.connect('notify::title', Lang.bind(this, function() {



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