PopupMenu: allow insertion of items at any point

Add a "position" argument to addMenuItem, and pass it to the
underlying box layout. If undefined or null, it adds at the end.
This commit is contained in:
Giovanni Campagna 2010-11-16 20:35:51 +01:00
parent c224e019fe
commit 0c5d87d79b

View File

@ -679,8 +679,11 @@ PopupMenu.prototype = {
})); }));
}, },
addMenuItem: function(menuItem) { addMenuItem: function(menuItem, position) {
this._box.add(menuItem.actor); if (position == undefined)
this._box.add(menuItem.actor);
else
this._box.insert_actor(menuItem.actor, position);
menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) { menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) {
if (active && this._activeMenuItem != menuItem) { if (active && this._activeMenuItem != menuItem) {
if (this._activeMenuItem) if (this._activeMenuItem)