NetworkMenu: fix some bugs for status items

When more than one device exists, we need to reset the section title's
device to null, and in that case we must show nothing (neither the switch
nor the label, but an empty label is OK anyway). Also, we need to
update the device statusItem immediately when constructing it, as we
may not get any state-changed.

https://bugzilla.gnome.org/show_bug.cgi?id=646074
This commit is contained in:
Giovanni Campagna 2011-03-31 23:23:29 +02:00 committed by Dan Winship
parent b2b685e46d
commit 2d855ce5cf

View File

@ -200,7 +200,7 @@ NMDeviceTitleMenuItem.prototype = {
},
setStatus: function(text) {
if (text) {
if (text != null) {
this._statusLabel.text = text;
this._statusBin.child = this._statusLabel;
this.actor.reactive = false;
@ -367,6 +367,8 @@ NMDevice.prototype = {
this.deactivate();
this.emit('enabled-changed');
}));
this._updateStatusItem();
}
this.section = new PopupMenu.PopupMenuSection();
@ -383,10 +385,19 @@ NMDevice.prototype = {
GObject.Object.prototype.disconnect.call(this.device, this._stateChangedId);
this._stateChangedId = 0;
}
if (this._carrierChangedId) {
// see above for why this is needed
GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId);
this._carrierChangedId = 0;
}
if (this._firmwareChangedId) {
GObject.Object.prototype.disconnect.call(this.device, this._firmwareChangedId);
this._firmwareChangedId = 0;
}
this._clearSection();
if (this.titleItem)
this.titleItem.destroy();
if (this.statusItem)
this.statusItem.destroy();
this.section.destroy();
},
@ -633,6 +644,14 @@ NMDevice.prototype = {
break;
}
this._updateStatusItem();
this._clearSection();
this._createSection();
this.emit('state-changed');
},
_updateStatusItem: function() {
if (this._carrierChangedId) {
// see above for why this is needed
GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId);
@ -645,10 +664,6 @@ NMDevice.prototype = {
this.statusItem.setStatus(this.getStatusLabel());
this.statusItem.setToggleState(this.connected);
this._clearSection();
this._createSection();
this.emit('state-changed');
},
_substateChanged: function() {
@ -1666,6 +1681,8 @@ NMApplet.prototype = {
managedDevices.forEach(function(dev) {
dev.statusItem.actor.show();
});
// remove status text from the section title item
item.updateForDevice(null);
}
}
},