[gnome-shell] userMenu: Indicate progress on status changes



commit e63f7e8779569d4edc4381cc76a3141840de62f7
Author: Florian MÃllner <fmuellner gnome org>
Date:   Wed Sep 14 15:06:48 2011 +0200

    userMenu: Indicate progress on status changes
    
    Depending on the number of accounts, the type or simply the network,
    there may be a noticable lag between setting the status and the actual
    status change.
    Use the new user-status-pending icon to indicate progress.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659067

 js/ui/userMenu.js |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index bc21fdf..68ac21f 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -474,13 +474,22 @@ const UserMenuButton = new Lang.Class({
                                        style_class: 'popup-menu-icon' });
         this._idleIcon = new St.Icon({ icon_name: 'user-idle',
                                        style_class: 'popup-menu-icon' });
+        this._pendingIcon = new St.Icon({ icon_name: 'user-status-pending',
+                                          style_class: 'popup-menu-icon' });
 
         this._accountMgr.connect('most-available-presence-changed',
                                   Lang.bind(this, this._updatePresenceIcon));
+        this._accountMgr.connect('account-enabled',
+                                  Lang.bind(this, this._onAccountEnabled));
+        this._accountMgr.connect('account-disabled',
+                                 Lang.bind(this, this._onAccountDisabled));
+        this._accountMgr.connect('account-removed',
+                                  Lang.bind(this, this._onAccountDisabled));
         this._accountMgr.prepare_async(null, Lang.bind(this,
             function(mgr) {
                 let [presence, s, msg] = mgr.get_most_available_presence();
                 this._updatePresenceIcon(mgr, presence, s, msg);
+                this._setupAccounts();
             }));
 
         this._name = new St.Label();
@@ -620,6 +629,46 @@ const UserMenuButton = new Lang.Class({
             this._iconBox.child = this._offlineIcon;
     },
 
+    _setupAccounts: function() {
+        let accounts = this._accountMgr.get_valid_accounts();
+        for (let i = 0; i < accounts.length; i++) {
+            accounts[i]._changingId = accounts[i].connect('notify::connection-status',
+                                                          Lang.bind(this, this._updateChangingPresence));
+        }
+        this._updateChangingPresence();
+    },
+
+    _onAccountEnabled: function(accountMgr, account) {
+        if (!account._changingId)
+            account._changingId = account.connect('notify::connection-status',
+                                                  Lang.bind(this, this._updateChangingPresence));
+        this._updateChangingPresence();
+    },
+
+    _onAccountDisabled: function(accountMgr, account) {
+        account.disconnect(account._changingId);
+        account._changingId = 0;
+        this._updateChangingPresence();
+    },
+
+    _updateChangingPresence: function() {
+        let accounts = this._accountMgr.get_valid_accounts();
+        let changing = false;
+        for (let i = 0; i < accounts.length; i++) {
+            if (accounts[i].connection_status == Tp.ConnectionStatus.CONNECTING) {
+                changing = true;
+                break;
+            }
+        }
+
+        if (changing) {
+            this._iconBox.child = this._pendingIcon;
+        } else {
+            let [presence, s, msg] = this._accountMgr.get_most_available_presence();
+            this._updatePresenceIcon(this._accountMgr, presence, s, msg);
+        }
+    },
+
     _createSubMenu: function() {
         let item;
 



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