messageTray: Close the notification on Escape

Now that the notifications can be focused with the keyboard, it's
important we can close the active one also this way.

https://bugzilla.gnome.org/show_bug.cgi?id=652082
This commit is contained in:
Stéphane Démurget 2012-11-08 15:38:57 +01:00
parent 7dc235511e
commit f30dcad8a7

View File

@ -1394,6 +1394,8 @@ const MessageTray = new Lang.Class({
y_expand: true,
x_expand: true,
layout_manager: new Clutter.BinLayout() });
this._notificationWidget.connect('key-release-event', Lang.bind(this, this._onNotificationKeyRelease));
this.actor.add_actor(this._notificationWidget);
this._notificationBin = new St.Bin({ y_expand: true });
@ -1443,7 +1445,7 @@ const MessageTray = new Lang.Class({
this._closeButton = makeCloseButton();
this._closeButton.hide();
this._closeButton.connect('clicked', Lang.bind(this, this._onCloseClicked));
this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
this._notificationWidget.add_actor(this._closeButton);
this._idleMonitorBecameActiveId = 0;
@ -1598,7 +1600,19 @@ const MessageTray = new Lang.Class({
return false;
},
_onCloseClicked: function() {
_onNotificationKeyRelease: function(actor, event) {
let ignoredModifiers = global.display.get_ignored_modifier_mask();
let modifierState = event.get_state() & ~ignoredModifiers;
if (event.get_key_symbol() == Clutter.KEY_Escape && modifierState == 0) {
this._closeNotification();
return true;
}
return false;
},
_closeNotification: function() {
if (this._notificationState == State.SHOWN) {
this._closeButton.hide();
this._notificationClosed = true;