popupMenu: Fix parenting implementation
I got confused between menus and menu items. https://bugzilla.gnome.org/show_bug.cgi?id=704336
This commit is contained in:
parent
658db43ad3
commit
a4a6e7cf53
@ -56,6 +56,7 @@ const PopupBaseMenuItem = new Lang.Class({
|
|||||||
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
|
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
|
||||||
this.actor._delegate = this;
|
this.actor._delegate = this;
|
||||||
|
|
||||||
|
this._parent = null;
|
||||||
this._children = [];
|
this._children = [];
|
||||||
this._ornament = Ornament.NONE;
|
this._ornament = Ornament.NONE;
|
||||||
this._ornamentLabel = new St.Label({ style_class: 'popup-menu-ornament' });
|
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));
|
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) {
|
_onStyleChanged: function (actor) {
|
||||||
this._spacing = Math.round(actor.get_theme_node().get_length('spacing'));
|
this._spacing = Math.round(actor.get_theme_node().get_length('spacing'));
|
||||||
},
|
},
|
||||||
@ -671,6 +683,10 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setParent: function(parent) {
|
||||||
|
this._parent = parent;
|
||||||
|
},
|
||||||
|
|
||||||
getSensitive: function() {
|
getSensitive: function() {
|
||||||
return this._sensitive && this.parentSensitive;
|
return this._sensitive && this.parentSensitive;
|
||||||
},
|
},
|
||||||
@ -908,7 +924,7 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
else
|
else
|
||||||
throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
|
throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
|
||||||
|
|
||||||
menuItem._parent = this;
|
menuItem._setParent(this);
|
||||||
|
|
||||||
this.length++;
|
this.length++;
|
||||||
},
|
},
|
||||||
@ -1342,6 +1358,11 @@ const PopupSubMenuMenuItem = new Lang.Class({
|
|||||||
this.menu.connect('open-state-changed', Lang.bind(this, this._subMenuOpenStateChanged));
|
this.menu.connect('open-state-changed', Lang.bind(this, this._subMenuOpenStateChanged));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setParent: function(parent) {
|
||||||
|
this.parent(parent);
|
||||||
|
this.menu._setParent(parent);
|
||||||
|
},
|
||||||
|
|
||||||
syncSensitive: function() {
|
syncSensitive: function() {
|
||||||
let sensitive = this.parent();
|
let sensitive = this.parent();
|
||||||
this._triangle.visible = sensitive;
|
this._triangle.visible = sensitive;
|
||||||
|
Loading…
Reference in New Issue
Block a user