PopupMenu: fix addMenuItem with explicit position
Only real menu items should be considered, fix this using the new API in StBoxLayout. https://bugzilla.gnome.org/show_bug.cgi?id=637681
This commit is contained in:
parent
046308c582
commit
493844d005
@ -631,15 +631,22 @@ PopupMenuBase.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
addMenuItem: function(menuItem, position) {
|
addMenuItem: function(menuItem, position) {
|
||||||
if (position == undefined)
|
let before_item = null;
|
||||||
|
if (position == undefined) {
|
||||||
this.box.add(menuItem.actor);
|
this.box.add(menuItem.actor);
|
||||||
else
|
} else {
|
||||||
this.box.insert_actor(menuItem.actor, position);
|
let items = this.getMenuItems();
|
||||||
|
if (position < items.length) {
|
||||||
|
before_item = items[position].actor;
|
||||||
|
this.box.insert_before(menuItem.actor, before_item);
|
||||||
|
} else
|
||||||
|
this.box.add(menuItem.actor);
|
||||||
|
}
|
||||||
if (menuItem instanceof PopupSubMenuMenuItem) {
|
if (menuItem instanceof PopupSubMenuMenuItem) {
|
||||||
if (position == undefined)
|
if (before_item == null)
|
||||||
this.box.add(menuItem.menu.actor);
|
this.box.add(menuItem.menu.actor);
|
||||||
else
|
else
|
||||||
this.box.insert_actor(menuItem.menu.actor, position + 1);
|
this.box.insert_before(menuItem.menu.actor, before_item);
|
||||||
menuItem._subMenuActivateId = menuItem.menu.connect('activate', Lang.bind(this, function() {
|
menuItem._subMenuActivateId = menuItem.menu.connect('activate', Lang.bind(this, function() {
|
||||||
this.emit('activate');
|
this.emit('activate');
|
||||||
this.close(true);
|
this.close(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user