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:
Giovanni Campagna 2010-12-20 19:10:43 +01:00
parent 046308c582
commit 493844d005

View File

@ -631,15 +631,22 @@ PopupMenuBase.prototype = {
},
addMenuItem: function(menuItem, position) {
if (position == undefined)
let before_item = null;
if (position == undefined) {
this.box.add(menuItem.actor);
else
this.box.insert_actor(menuItem.actor, position);
} else {
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 (position == undefined)
if (before_item == null)
this.box.add(menuItem.menu.actor);
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() {
this.emit('activate');
this.close(true);