popupMenu: Introduce a way of closing toplevels from sections

As the aggregate menu will be built out of sections from each
of the menus, we need to ensure that activating an item in one
of these sections can close the main menu, even when it is not
a menu item. The new API also needs to be flexible enough to
ensure that animations can be controlled, like the buttons that
lock the screen or launch a new session.

Port the user menu to use this new API as well.

https://bugzilla.gnome.org/show_bug.cgi?id=702539
This commit is contained in:
Jasper St. Pierre 2013-06-18 04:46:44 -04:00
parent c1e2d66abd
commit 7db0900cc8
2 changed files with 11 additions and 4 deletions

View File

@ -754,6 +754,13 @@ const PopupMenuBase = new Lang.Class({
return false; return false;
}, },
itemActivated: function(animate) {
if (animate == undefined)
animate = BoxPointer.PopupAnimation.FULL;
this._getTopMenu().close(animate);
},
/** /**
* _connectSubMenuSignals: * _connectSubMenuSignals:
* @object: a menu item, or a menu section * @object: a menu item, or a menu section
@ -800,7 +807,7 @@ const PopupMenuBase = new Lang.Class({
})); }));
menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) { menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
this.emit('activate', menuItem); this.emit('activate', menuItem);
this.close(BoxPointer.PopupAnimation.FULL); this.itemActivated(BoxPointer.PopupAnimation.FULL);
})); }));
// the weird name is to avoid a conflict with some random property // the weird name is to avoid a conflict with some random property
// the menuItem may have, called destroyId // the menuItem may have, called destroyId

View File

@ -803,13 +803,13 @@ const UserMenuButton = new Lang.Class({
}, },
_onLockScreenActivate: function() { _onLockScreenActivate: function() {
this.menu.close(BoxPointer.PopupAnimation.NONE); this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
Main.overview.hide(); Main.overview.hide();
Main.screenShield.lock(true); Main.screenShield.lock(true);
}, },
_onLoginScreenActivate: function() { _onLoginScreenActivate: function() {
this.menu.close(BoxPointer.PopupAnimation.NONE); this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
Main.overview.hide(); Main.overview.hide();
if (Main.screenShield) if (Main.screenShield)
Main.screenShield.lock(false); Main.screenShield.lock(false);
@ -937,7 +937,7 @@ const UserMenuButton = new Lang.Class({
this._session.ShutdownRemote(); this._session.ShutdownRemote();
})); }));
} else { } else {
this.menu.close(BoxPointer.PopupAnimation.NONE); this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._loginManager.suspend(); this._loginManager.suspend();
} }
} }