[gnome-shell] popupMenu: Fix parenting implementation



commit a4a6e7cf53d7b043538885e6ad74cf73b5a8dbad
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jul 15 18:47:16 2013 -0400

    popupMenu: Fix parenting implementation
    
    I got confused between menus and menu items.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704336

 js/ui/popupMenu.js |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 78f25db..824fe1d 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -56,6 +56,7 @@ const PopupBaseMenuItem = new Lang.Class({
         this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
         this.actor._delegate = this;
 
+        this._parent = null;
         this._children = [];
         this._ornament = Ornament.NONE;
         this._ornamentLabel = new St.Label({ style_class: 'popup-menu-ornament' });
@@ -84,6 +85,17 @@ const PopupBaseMenuItem = new Lang.Class({
         this.actor.connect('key-focus-out', Lang.bind(this, this._onKeyFocusOut));
     },
 
+    _getTopMenu: function() {
+        if (this._parent)
+            return this._parent._getTopMenu();
+        else
+            return this;
+    },
+
+    _setParent: function(parent) {
+        this._parent = parent;
+    },
+
     _onStyleChanged: function (actor) {
         this._spacing = Math.round(actor.get_theme_node().get_length('spacing'));
     },
@@ -671,6 +683,10 @@ const PopupMenuBase = new Lang.Class({
             return this;
     },
 
+    _setParent: function(parent) {
+        this._parent = parent;
+    },
+
     getSensitive: function() {
         return this._sensitive && this.parentSensitive;
     },
@@ -908,7 +924,7 @@ const PopupMenuBase = new Lang.Class({
         else
             throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
 
-        menuItem._parent = this;
+        menuItem._setParent(this);
 
         this.length++;
     },
@@ -1342,6 +1358,11 @@ const PopupSubMenuMenuItem = new Lang.Class({
         this.menu.connect('open-state-changed', Lang.bind(this, this._subMenuOpenStateChanged));
     },
 
+    _setParent: function(parent) {
+        this.parent(parent);
+        this.menu._setParent(parent);
+    },
+
     syncSensitive: function() {
         let sensitive = this.parent();
         this._triangle.visible = sensitive;


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