[polari/wip/fmuellner/network-keynav: 2/2] joinDialog: Improve network selection via keyboard



commit 19a831502d711eff76d71c7d7f2f952ec414e291
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Aug 2 01:46:08 2017 +0100

    joinDialog: Improve network selection via keyboard
    
    In order to allow for keyboard-friendly network selection, we currently
    activate the first one when the filter entry is activated. While this
    is generally what we want, it's not very obvious that this will happen.
    So instead, keep the first row selected while filtering, and activate
    the selected entry when hitting enter.

 src/connections.js | 14 ++++++++++----
 src/joinDialog.js  |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 86f7b4a..9509085 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -139,13 +139,19 @@ var ConnectionsList = GObject.registerClass({
     }
 
     setFilter(filter) {
-        if (Utils.updateTerms(this._filterTerms, filter))
-            this._list.invalidate_filter();
-    }
+        if (!Utils.updateTerms(this._filterTerms, filter))
+            return;
+
+        this._list.invalidate_filter();
 
-    activateFirst() {
         let row = this._list.get_row_at_y(0);
         if (row)
+            this._list.select_row(row);
+    }
+
+    activateSelected() {
+        let row = this._list.get_selected_row();
+        if (row)
             row.activate();
     }
 
diff --git a/src/joinDialog.js b/src/joinDialog.js
index b468b6f..89abe94 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -144,7 +144,7 @@ var JoinDialog = GObject.registerClass({
         });
         this._filterEntry.connect('activate', () => {
             if (this._filterEntry.text.length > 0)
-                this._connectionsList.activateFirst();
+                this._connectionsList.activateSelected();
         });
     }
 


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