[gnome-shell] viewSelector: Allow to start navigating results using arrow keys



commit 384c7e2c170e8908d48138a7d73b0f377f81ff6a
Author: Florian MÃllner <fmuellner gnome org>
Date:   Sat Mar 10 03:40:46 2012 +0100

    viewSelector: Allow to start navigating results using arrow keys
    
    We currently require users to tab away from the search entry before
    search results can be navigated using arrow keys. For convenience,
    support using arrow keys directly from the entry.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663901

 js/ui/searchDisplay.js |   17 +++++++++++++----
 js/ui/viewSelector.js  |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/searchDisplay.js b/js/ui/searchDisplay.js
index 07984a4..aeb6cf7 100644
--- a/js/ui/searchDisplay.js
+++ b/js/ui/searchDisplay.js
@@ -266,6 +266,7 @@ const SearchResults = new Lang.Class({
         button.activate = Lang.bind(this, function() {
             this._openSearchSystem.activateResult(provider.id);
         });
+        button.actor = button;
 
         this._searchProvidersBox.add(button);
     },
@@ -450,13 +451,21 @@ const SearchResults = new Lang.Class({
     },
 
     navigateFocus: function(direction) {
-        if (direction == Gtk.DirectionType.TAB_FORWARD && this._defaultResult) {
+        let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL;
+        if (direction == Gtk.DirectionType.TAB_BACKWARD ||
+            direction == (rtl ? Gtk.DirectionType.RIGHT
+                              : Gtk.DirectionType.LEFT) ||
+            direction == Gtk.DirectionType.UP) {
+            this.actor.navigate_focus(null, direction, false);
+            return;
+        }
+
+        let from = this._defaultResult ? this._defaultResult.actor : null;
+        this.actor.navigate_focus(from, direction, false);
+        if (this._defaultResult) {
             // The default result appears focused, so navigate directly to the
             // next result.
-            this.actor.navigate_focus(null, direction, false);
             this.actor.navigate_focus(global.stage.key_focus, direction, false);
-        } else {
-            this.actor.navigate_focus(null, direction, false);
         }
     }
 });
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 795f9fc..c4a6009 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -292,6 +292,15 @@ const SearchTab = new Lang.Class({
                 return true;
             }
         } else if (this.active) {
+            let arrowNext, nextDirection;
+            if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
+                arrowNext = Clutter.Left;
+                nextDirection = Gtk.DirectionType.LEFT;
+            } else {
+                arrowNext = Clutter.Right;
+                nextDirection = Gtk.DirectionType.RIGHT;
+            }
+
             if (symbol == Clutter.Tab) {
                 this._searchResults.navigateFocus(Gtk.DirectionType.TAB_FORWARD);
                 return true;
@@ -300,6 +309,12 @@ const SearchTab = new Lang.Class({
                 this._searchResults.navigateFocus(Gtk.DirectionType.TAB_BACKWARD);
                 this._focusTrap.can_focus = true;
                 return true;
+            } else if (symbol == Clutter.Down) {
+                this._searchResults.navigateFocus(Gtk.DirectionType.DOWN);
+                return true;
+            } else if (symbol == arrowNext && this._text.position == -1) {
+                this._searchResults.navigateFocus(nextDirection);
+                return true;
             }
         }
         return false;



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