Network Menu: fix pulling out the first element from the More... submenu.
PopupMenu.firstMenuItem returns a PopupMenuItem, not an apObj. We need to retrive the latter using the _apObj property. Also, somehow the property from the number of elements in a menu was changed from .length to .numMenuItems, and this broke the destruction of the menu upon emptying it. https://bugzilla.gnome.org/show_bug.cgi?id=659277
This commit is contained in:
parent
18541c447e
commit
70fc13500d
@ -1307,17 +1307,21 @@ NMDeviceWireless.prototype = {
|
|||||||
// we removed an item in the main menu, and we have a more submenu
|
// we removed an item in the main menu, and we have a more submenu
|
||||||
// we need to extract the first item in more and move it to the submenu
|
// we need to extract the first item in more and move it to the submenu
|
||||||
|
|
||||||
let apObj = this._overflowItem.menu.firstMenuItem;
|
let item = this._overflowItem.menu.firstMenuItem;
|
||||||
if (apObj.item) {
|
if (item && item._apObj) {
|
||||||
apObj.item.destroy();
|
item.destroy();
|
||||||
|
// clear the cycle, and allow the construction of the new item
|
||||||
|
item._apObj.item = null;
|
||||||
|
|
||||||
this._createNetworkItem(apObj, NUM_VISIBLE_NETWORKS-1);
|
this._createNetworkItem(item._apObj, NUM_VISIBLE_NETWORKS-1);
|
||||||
|
} else {
|
||||||
|
log('The more... menu was existing and empty! This should not happen');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can happen if the removed connection is from the overflow
|
// This can happen if the removed connection is from the overflow
|
||||||
// menu, or if we just moved the last connection out from the menu
|
// menu, or if we just moved the last connection out from the menu
|
||||||
if (this._overflowItem.menu.length == 0) {
|
if (this._overflowItem.menu.numMenuItems == 0) {
|
||||||
this._overflowItem.destroy();
|
this._overflowItem.destroy();
|
||||||
this._overflowItem = null;
|
this._overflowItem = null;
|
||||||
}
|
}
|
||||||
@ -1494,18 +1498,16 @@ NMDeviceWireless.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(apObj.connections.length > 0) {
|
if(apObj.connections.length > 0) {
|
||||||
if (apObj.connections.length == 1)
|
if (apObj.connections.length == 1) {
|
||||||
apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
|
apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
|
||||||
else {
|
} else {
|
||||||
let title = apObj.ssidText;
|
let title = apObj.ssidText;
|
||||||
apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
|
apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
|
||||||
apObj.item._apObj = apObj;
|
|
||||||
for (let i = 0; i < apObj.connections.length; i++)
|
for (let i = 0; i < apObj.connections.length; i++)
|
||||||
apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
|
apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
|
apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
|
||||||
apObj.item._apObj = apObj;
|
|
||||||
apObj.item.connect('activate', Lang.bind(this, function() {
|
apObj.item.connect('activate', Lang.bind(this, function() {
|
||||||
let accessPoints = sortAccessPoints(apObj.accessPoints);
|
let accessPoints = sortAccessPoints(apObj.accessPoints);
|
||||||
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
|
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
|
||||||
@ -1520,6 +1522,8 @@ NMDeviceWireless.prototype = {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
apObj.item._apObj = apObj;
|
||||||
|
|
||||||
if (position < NUM_VISIBLE_NETWORKS) {
|
if (position < NUM_VISIBLE_NETWORKS) {
|
||||||
apObj.isMore = false;
|
apObj.isMore = false;
|
||||||
this.section.addMenuItem(apObj.item, position);
|
this.section.addMenuItem(apObj.item, position);
|
||||||
|
Loading…
Reference in New Issue
Block a user