[gnome-shell] NetworkMenu: take out an item from More... when another is destroyed
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] NetworkMenu: take out an item from More... when another is destroyed
- Date: Tue, 12 Jul 2011 23:33:59 +0000 (UTC)
commit 5819dd3a5a011339a2d40617dc33bcc7c359c8ed
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Jun 27 17:45:24 2011 +0200
NetworkMenu: take out an item from More... when another is destroyed
When one of the networks in the main menu is removed and we have
a More... submenu, we can take the first out from the submenu and
show it in the main menu.
https://bugzilla.gnome.org/show_bug.cgi?id=647175
js/ui/popupMenu.js | 8 ++++++++
js/ui/status/network.js | 33 ++++++++++++++++++++++++++-------
2 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index e67729c..9e256b5 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -946,6 +946,14 @@ PopupMenuBase.prototype = {
});
},
+ get firstMenuItem() {
+ let items = this._getMenuItems();
+ if (items.length)
+ return items[0];
+ else
+ return null;
+ },
+
removeAll: function() {
let children = this._getMenuItems();
for (let i = 0; i < children.length; i++) {
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 348fcd4..a4372b5 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1281,12 +1281,29 @@ NMDeviceWireless.prototype = {
if (apObj.accessPoints.length == 0) {
if (apObj.item)
apObj.item.destroy();
- this._networks.splice(pos, 1);
- if (this._overflowItem &&
- this._overflowItem.menu.length == 0) {
- this._overflowItem.destroy();
- this._overflowItem = null;
+
+ if (this._overflowItem) {
+ if (!apObj.isMore) {
+ // 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();
+
+ this._createNetworkItem(apObj, NUM_VISIBLE_NETWORKS-1);
+ }
+ }
+
+ // 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) {
+ this._overflowItem.destroy();
+ this._overflowItem = null;
+ }
}
+ this._networks.splice(pos, 1);
+
} else if (apObj.item)
apObj.item.updateAccessPoints(apObj.accessPoints);
},
@@ -1482,14 +1499,16 @@ NMDeviceWireless.prototype = {
}
}));
}
- if (position < NUM_VISIBLE_NETWORKS)
+ if (position < NUM_VISIBLE_NETWORKS) {
+ apObj.isMore = false;
this.section.addMenuItem(apObj.item, position);
- else {
+ } else {
if (!this._overflowItem) {
this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More..."));
this.section.addMenuItem(this._overflowItem);
}
this._overflowItem.menu.addMenuItem(apObj.item, position - NUM_VISIBLE_NETWORKS);
+ apObj.isMore = true;
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]