[gnome-shell] NetworkMenu: destroy More... submenu when empty



commit 625a4c0766ab21d0f5897f1537720cb6a60012fe
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Mar 28 21:27:03 2011 +0200

    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

 js/ui/popupMenu.js      |    5 +++++
 js/ui/status/network.js |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 8f76ed6..b1dcf49 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -766,6 +766,7 @@ PopupMenuBase.prototype = {
             this.box = new St.BoxLayout({ vertical: true });
         }
         this.box.connect_after('queue-relayout', Lang.bind(this, this._menuQueueRelayout));
+        this.length = 0;
 
         this.isOpen = false;
 
@@ -855,6 +856,8 @@ PopupMenuBase.prototype = {
             menuItem.connect('destroy', Lang.bind(this, function() {
                 menuItem.disconnect(menuItem._subMenuActivateId);
                 menuItem.disconnect(menuItem._subMenuActiveChangeId);
+
+                this.length--;
             }));
         } else if (menuItem instanceof PopupSubMenuMenuItem) {
             if (before_item == null)
@@ -871,6 +874,8 @@ PopupMenuBase.prototype = {
             this._connectItemSignals(menuItem);
         else
             throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
+
+        this.length++;
     },
 
     getColumnWidths: function() {
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 752a9f6..885c5d7 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1198,6 +1198,11 @@ NMDeviceWireless.prototype = {
             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;
+            }
         } else if (apObj.item)
             apObj.item.updateAccessPoints(apObj.accessPoints);
     },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]