[gnome-shell] Network Menu: fix pulling out the first element from the More... submenu.
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Network Menu: fix pulling out the first element from the More... submenu.
- Date: Thu, 3 Nov 2011 12:12:45 +0000 (UTC)
commit 70fc13500d0d40a6da4df1cf1c713e1509f1d9ab
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Oct 17 14:43:08 2011 +0200
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
js/ui/status/network.js | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 966e872..456b51f 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1307,17 +1307,21 @@ NMDeviceWireless.prototype = {
// 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
- let apObj = this._overflowItem.menu.firstMenuItem;
- if (apObj.item) {
- apObj.item.destroy();
+ let item = this._overflowItem.menu.firstMenuItem;
+ if (item && item._apObj) {
+ 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
// 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 = null;
}
@@ -1494,18 +1498,16 @@ NMDeviceWireless.prototype = {
}
if(apObj.connections.length > 0) {
- if (apObj.connections.length == 1)
+ if (apObj.connections.length == 1) {
apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
- else {
+ } else {
let title = apObj.ssidText;
apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
- apObj.item._apObj = apObj;
for (let i = 0; i < apObj.connections.length; i++)
apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
}
} else {
apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
- apObj.item._apObj = apObj;
apObj.item.connect('activate', Lang.bind(this, function() {
let accessPoints = sortAccessPoints(apObj.accessPoints);
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
@@ -1520,6 +1522,8 @@ NMDeviceWireless.prototype = {
}
}));
}
+ apObj.item._apObj = apObj;
+
if (position < NUM_VISIBLE_NETWORKS) {
apObj.isMore = false;
this.section.addMenuItem(apObj.item, position);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]