NetworkMenu: destroy More... submenu when empty

Add a .length property to PopupMenuBase, and use it from the network
menu to destroy the menu when removing a network without rebuilding.

https://bugzilla.gnome.org/show_bug.cgi?id=645981
This commit is contained in:
Giovanni Campagna 2011-03-28 21:27:03 +02:00 committed by Dan Winship
parent 3c3ea2f575
commit 625a4c0766
2 changed files with 10 additions and 0 deletions

View File

@ -766,6 +766,7 @@ PopupMenuBase.prototype = {
this.box = new St.BoxLayout({ vertical: true }); this.box = new St.BoxLayout({ vertical: true });
} }
this.box.connect_after('queue-relayout', Lang.bind(this, this._menuQueueRelayout)); this.box.connect_after('queue-relayout', Lang.bind(this, this._menuQueueRelayout));
this.length = 0;
this.isOpen = false; this.isOpen = false;
@ -855,6 +856,8 @@ PopupMenuBase.prototype = {
menuItem.connect('destroy', Lang.bind(this, function() { menuItem.connect('destroy', Lang.bind(this, function() {
menuItem.disconnect(menuItem._subMenuActivateId); menuItem.disconnect(menuItem._subMenuActivateId);
menuItem.disconnect(menuItem._subMenuActiveChangeId); menuItem.disconnect(menuItem._subMenuActiveChangeId);
this.length--;
})); }));
} else if (menuItem instanceof PopupSubMenuMenuItem) { } else if (menuItem instanceof PopupSubMenuMenuItem) {
if (before_item == null) if (before_item == null)
@ -871,6 +874,8 @@ PopupMenuBase.prototype = {
this._connectItemSignals(menuItem); this._connectItemSignals(menuItem);
else else
throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()"); throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
this.length++;
}, },
getColumnWidths: function() { getColumnWidths: function() {

View File

@ -1198,6 +1198,11 @@ NMDeviceWireless.prototype = {
if (apObj.item) if (apObj.item)
apObj.item.destroy(); apObj.item.destroy();
this._networks.splice(pos, 1); this._networks.splice(pos, 1);
if (this._overflowItem &&
this._overflowItem.menu.length == 0) {
this._overflowItem.destroy();
this._overflowItem = null;
}
} else if (apObj.item) } else if (apObj.item)
apObj.item.updateAccessPoints(apObj.accessPoints); apObj.item.updateAccessPoints(apObj.accessPoints);
}, },