[gnome-shell] popupMenu: Handle key-press events on sourceActor
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] popupMenu: Handle key-press events on sourceActor
- Date: Thu, 28 Aug 2014 17:13:05 +0000 (UTC)
commit 1d58ea25ab6f0472bdeffc9170ece37d5dd71e64
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Aug 28 17:04:23 2014 +0200
popupMenu: Handle key-press events on sourceActor
The behavior of opening/closing/navigating a menu from its source
actor is generic enough to not limit it to PanelMenu.Buttons, so
move the code into PopupMenu itself.
https://bugzilla.gnome.org/show_bug.cgi?id=735614
js/ui/panelMenu.js | 21 ---------------------
js/ui/popupMenu.js | 28 ++++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index 863e0d7..29acd29 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -101,7 +101,6 @@ const Button = new Lang.Class({
accessible_role: Atk.Role.MENU });
this.actor.connect('event', Lang.bind(this, this._onEvent));
- this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
this.actor.connect('notify::visible', Lang.bind(this, this._onVisibilityChanged));
if (dontCreateMenu)
@@ -140,26 +139,6 @@ const Button = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
- _onSourceKeyPress: function(actor, event) {
- if (!this.menu)
- return Clutter.EVENT_PROPAGATE;
-
- let symbol = event.get_key_symbol();
- if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
- this.menu.toggle();
- return Clutter.EVENT_STOP;
- } else if (symbol == Clutter.KEY_Escape && this.menu.isOpen) {
- this.menu.close();
- return Clutter.EVENT_STOP;
- } else if (symbol == Clutter.KEY_Down) {
- if (!this.menu.isOpen)
- this.menu.toggle();
- this.menu.actor.navigate_focus(this.actor, Gtk.DirectionType.DOWN, false);
- return Clutter.EVENT_STOP;
- } else
- return Clutter.EVENT_PROPAGATE;
- },
-
_onVisibilityChanged: function() {
if (!this.menu)
return;
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 0e9e0c4..3d41b73 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -731,6 +731,10 @@ const PopupMenu = new Lang.Class({
global.focus_manager.add_group(this.actor);
this.actor.reactive = true;
+ if (this.sourceActor)
+ this._keyPressId = this.sourceActor.connect('key-press-event',
+ Lang.bind(this, this._onKeyPress));
+
this._openedSubMenu = null;
},
@@ -741,6 +745,24 @@ const PopupMenu = new Lang.Class({
this._openedSubMenu = submenu;
},
+ _onKeyPress: function(actor, event) {
+ let symbol = event.get_key_symbol();
+ if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
+ this.toggle();
+ return Clutter.EVENT_STOP;
+ } else if (symbol == Clutter.KEY_Escape && this.isOpen) {
+ this.close();
+ return Clutter.EVENT_STOP;
+ } else if (symbol == Clutter.KEY_Down) {
+ if (!this.isOpen)
+ this.toggle();
+ this.actor.navigate_focus(actor, Gtk.DirectionType.DOWN, false);
+ return Clutter.EVENT_STOP;
+ } else
+ return Clutter.EVENT_PROPAGATE;
+ },
+
+
setArrowOrigin: function(origin) {
this._boxPointer.setArrowOrigin(origin);
},
@@ -781,6 +803,12 @@ const PopupMenu = new Lang.Class({
this.isOpen = false;
this.emit('open-state-changed', false);
+ },
+
+ destroy: function() {
+ if (this._keyPressId)
+ this.sourceActor.disconnect(this._keyPressId);
+ this.parent();
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]