From 7db0900cc86049578315e80eb104e300fba8fcdc Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 18 Jun 2013 04:46:44 -0400 Subject: [PATCH] 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 --- js/ui/popupMenu.js | 9 ++++++++- js/ui/userMenu.js | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index b0d219f5a..b5b156db6 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -754,6 +754,13 @@ const PopupMenuBase = new Lang.Class({ return false; }, + itemActivated: function(animate) { + if (animate == undefined) + animate = BoxPointer.PopupAnimation.FULL; + + this._getTopMenu().close(animate); + }, + /** * _connectSubMenuSignals: * @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) { 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 menuItem may have, called destroyId diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 86980c5a6..68a300a4d 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -803,13 +803,13 @@ const UserMenuButton = new Lang.Class({ }, _onLockScreenActivate: function() { - this.menu.close(BoxPointer.PopupAnimation.NONE); + this.menu.itemActivated(BoxPointer.PopupAnimation.NONE); Main.overview.hide(); Main.screenShield.lock(true); }, _onLoginScreenActivate: function() { - this.menu.close(BoxPointer.PopupAnimation.NONE); + this.menu.itemActivated(BoxPointer.PopupAnimation.NONE); Main.overview.hide(); if (Main.screenShield) Main.screenShield.lock(false); @@ -937,7 +937,7 @@ const UserMenuButton = new Lang.Class({ this._session.ShutdownRemote(); })); } else { - this.menu.close(BoxPointer.PopupAnimation.NONE); + this.menu.itemActivated(BoxPointer.PopupAnimation.NONE); this._loginManager.suspend(); } }