[gnome-shell] Enables navigation using arrow keys in notifications with buttons.



commit 0e4a47c0aa145f9380ce7c56e8c4018895402325
Author: Hellyna Ng <hellyna hellyna com>
Date:   Thu Jan 20 13:16:47 2011 +0800

    Enables navigation using arrow keys in notifications with buttons.
    
    Users can now use the keyboard and mouse to navigate with buttons
    interchangeably, instead of entirely using only mouse.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630937

 data/theme/gnome-shell.css |    8 ++++++++
 js/ui/messageTray.js       |   14 +++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 73d2b5c..ba931ad 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -921,6 +921,10 @@ StTooltip StLabel {
     border: 1px solid #a1a1a1;
 }
 
+.notification-button:focus {
+    background-color: #666666;
+}
+
 .notification-button:active {
     border: 1px solid #a1a1a1;
     background-color: #2b2b2b;
@@ -933,6 +937,10 @@ StTooltip StLabel {
 }
 
 .notification-icon-button:hover {
+    border: 2px rgba(161,161,161,0.7);
+}
+
+.notification-icon-button:focus {
     background: rgba(192,192,192,0.7);
 }
 
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index baa11f0..1812983 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -262,6 +262,7 @@ Notification.prototype = {
         this._titleFitsInBannerMode = true;
         this._spacing = 0;
 
+        this._buttonFocusManager = null;
         this._hasFocus = false;
         this._lockTrayOnFocusGrab = false;
         // We use this._prevFocusedWindow and this._prevKeyFocusActor to return the
@@ -504,7 +505,7 @@ Notification.prototype = {
             this._buttonBox = box;
         }
 
-        let button = new St.Button();
+        let button = new St.Button({ can_focus: true });
 
         if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(id)) {
             button.add_style_class_name('notification-icon-button');
@@ -514,8 +515,15 @@ Notification.prototype = {
             button.label = label;
         }
 
+        if (!this._buttonFocusManager)
+            this._buttonFocusManager = St.FocusManager.get_for_stage(global.stage);
+        if (this._buttonBox.get_children().length > 0)
+            this._buttonFocusManager.remove_group(this._buttonBox);
+
         this._buttonBox.add(button);
+        this._buttonFocusManager.add_group(this._buttonBox);
         button.connect('clicked', Lang.bind(this, this._onActionInvoked, id));
+
         this._updated();
     },
 
@@ -665,6 +673,10 @@ Notification.prototype = {
         this._focusActorChangedId = global.stage.connect('notify::key-focus', Lang.bind(this, this._focusActorChanged));
 
         this._hasFocus = true;
+
+        if (this._buttonFocusManager)
+            this._buttonBox.get_children()[0].grab_key_focus();
+
         if (lockTray)
             Main.messageTray.lock();
     },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]