panel: Change openAppMenu() to a toggle action

It makes sense to allow closing the app menu with the same shortcut
that is used to open it, so make it a toggle action and allow it
TOPBAR_POPUP mode.

https://bugzilla.gnome.org/show_bug.cgi?id=686756
This commit is contained in:
Florian Müllner 2013-04-26 16:14:55 +02:00
parent ad277a563c
commit 8b78032248
2 changed files with 10 additions and 8 deletions

View File

@ -1077,17 +1077,18 @@ const Panel = new Lang.Class({
return true; return true;
}, },
openAppMenu: function() { toggleAppMenu: function() {
let indicator = this.statusArea.appMenu; let indicator = this.statusArea.appMenu;
if (!indicator) // appMenu not supported by current session mode if (!indicator) // appMenu not supported by current session mode
return; return;
let menu = indicator.menu; let menu = indicator.menu;
if (!indicator.actor.reactive || menu.isOpen) if (!indicator.actor.reactive)
return; return;
menu.open(); menu.toggle();
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); if (menu.isOpen)
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
}, },
set boxOpacity(value) { set boxOpacity(value) {

View File

@ -172,8 +172,9 @@ const WindowManager = new Lang.Class({
this.addKeybinding('open-application-menu', this.addKeybinding('open-application-menu',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }), new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE, Meta.KeyBindingFlags.NONE,
Shell.KeyBindingMode.NORMAL, Shell.KeyBindingMode.NORMAL |
Lang.bind(this, this._openAppMenu)); Shell.KeyBindingMode.TOPBAR_POPUP,
Lang.bind(this, this._toggleAppMenu));
Main.overview.connect('showing', Lang.bind(this, function() { Main.overview.connect('showing', Lang.bind(this, function() {
for (let i = 0; i < this._dimmedWindows.length; i++) for (let i = 0; i < this._dimmedWindows.length; i++)
@ -679,8 +680,8 @@ const WindowManager = new Lang.Class({
Main.ctrlAltTabManager.popup(backwards, binding.get_name(), binding.get_mask()); Main.ctrlAltTabManager.popup(backwards, binding.get_name(), binding.get_mask());
}, },
_openAppMenu : function(display, screen, window, event, binding) { _toggleAppMenu : function(display, screen, window, event, binding) {
Main.panel.openAppMenu(); Main.panel.toggleAppMenu();
}, },
_showWorkspaceSwitcher : function(display, screen, window, binding) { _showWorkspaceSwitcher : function(display, screen, window, binding) {