[gnome-shell] popupMenu: Add a simple way to get the toplevel for a submenu / section



commit c1e2d66abdb98962b903c413cbe5c490de2a47fd
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jul 8 15:19:34 2013 -0400

    popupMenu: Add a simple way to get the toplevel for a submenu / section
    
    This will be used to avoid some nasty signal propagation when wanting to
    rework how sections / submenus work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702539

 js/ui/popupMenu.js |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 4b9eb40..b0d219f 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -672,6 +672,7 @@ const PopupMenuBase = new Lang.Class({
 
     _init: function(sourceActor, styleClass) {
         this.sourceActor = sourceActor;
+        this._parent = null;
 
         if (styleClass !== undefined) {
             this.box = new St.BoxLayout({ style_class: styleClass,
@@ -694,6 +695,13 @@ const PopupMenuBase = new Lang.Class({
         this._sessionUpdatedId = Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
     },
 
+    _getTopMenu: function() {
+        if (this._parent)
+            return this._parent._getTopMenu();
+        else
+            return this;
+    },
+
     _sessionUpdated: function() {
         this._setSettingsVisibility(Main.sessionMode.allowSettings);
     },
@@ -903,6 +911,8 @@ const PopupMenuBase = new Lang.Class({
         else
             throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
 
+        menuItem._parent = this;
+
         this.length++;
     },
 
@@ -1154,18 +1164,6 @@ const PopupSubMenu = new Lang.Class({
         this.actor.hide();
     },
 
-    _getTopMenu: function() {
-        let actor = this.actor.get_parent();
-        while (actor) {
-            if (actor._delegate && actor._delegate instanceof PopupMenu)
-                return actor._delegate;
-
-            actor = actor.get_parent();
-        }
-
-        return null;
-    },
-
     _needsScrollbar: function() {
         let topMenu = this._getTopMenu();
         let [topMinHeight, topNaturalHeight] = topMenu.actor.get_preferred_height(-1);


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