[gnome-shell] NetworkMenu: make sure menu icons are updated at the end of connectivity checks



commit 5f4591e24c033fde1cb9cd50c70f9843528a5329
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Mar 15 12:40:13 2014 +0100

    NetworkMenu: make sure menu icons are updated at the end of connectivity checks
    
    Icons inside the menu are updated only for device state change,
    but for the main device they also depend on connectivity (which
    is a global property).
    Add a public method to force an update of the icon, and call it
    when connectivity changes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726401

 js/ui/status/network.js |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 7d68fbd..f3e568d 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -207,13 +207,23 @@ const NMConnectionSection = new Lang.Class({
         this.item.menu.addMenuItem(this._labelSection);
         this.item.menu.addMenuItem(this._radioSection);
 
-        this.connect('icon-changed', Lang.bind(this, this._sync));
+        this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, 
this._iconChanged));
     },
 
     destroy: function() {
+        if (this._notifyConnectivityId != 0) {
+            this._client.disconnect(this._notifyConnectivityId);
+            this._notifyConnectivityId = 0;
+        }
+
         this.item.destroy();
     },
 
+    _iconChanged: function() {
+        this._sync();
+        this.emit('icon-changed');
+    },
+
     _sync: function() {
         let nItems = this._connectionItems.size;
 
@@ -278,7 +288,7 @@ const NMConnectionSection = new Lang.Class({
             return;
 
         item.connect('icon-changed', Lang.bind(this, function() {
-            this.emit('icon-changed');
+            this._iconChanged();
         }));
         item.connect('activation-failed', Lang.bind(this, function(item, reason) {
             this.emit('activation-failed', reason);
@@ -523,7 +533,7 @@ const NMDeviceModem = new Lang.Class({
         if (this._mobileDevice) {
             this._operatorNameId = this._mobileDevice.connect('notify::operator-name', Lang.bind(this, 
this._sync));
             this._signalQualityId = this._mobileDevice.connect('notify::signal-quality', Lang.bind(this, 
function() {
-                this.emit('icon-changed');
+                this._iconChanged();
             }));
         }
     },
@@ -1145,10 +1155,16 @@ const NMDeviceWireless = new Lang.Class({
         this._wirelessHwEnabledChangedId = this._client.connect('notify::wireless-hardware-enabled', 
Lang.bind(this, this._sync));
         this._activeApChangedId = this._device.connect('notify::active-access-point', Lang.bind(this, 
this._activeApChanged));
         this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, 
this._deviceStateChanged));
+        this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, 
this._iconChanged));
 
         this._sync();
     },
 
+    _iconChanged: function() {
+        this._sync();
+        this.emit('icon-changed');
+    },
+
     destroy: function() {
         if (this._activeApChangedId) {
             GObject.Object.prototype.disconnect.call(this._device, this._activeApChangedId);
@@ -1174,6 +1190,10 @@ const NMDeviceWireless = new Lang.Class({
             this._dialog.destroy();
             this._dialog = null;
         }
+        if (this._notifyConnectivityId) {
+            this._client.disconnect(this._notifyConnectivityId);
+            this._notifyConnectivityId = 0;
+        }
 
         this.item.destroy();
     },
@@ -1211,7 +1231,7 @@ const NMDeviceWireless = new Lang.Class({
     },
 
     _strengthChanged: function() {
-        this.emit('icon-changed');
+        this._iconChanged();
     },
 
     _activeApChanged: function() {


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