[gnome-maps] SearchPopup: Enable keyboard navigation



commit 4360567722fae234e95818cc26d524fd83681158
Author: Damián Nohales <damiannohaes gmail com>
Date:   Thu Mar 6 22:06:50 2014 -0700

    SearchPopup: Enable keyboard navigation
    
    Have the treeview of the SearchPopup grab focus when shown.
    Also switch signals from button-press-event to row-activated
    for item selection.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725715

 src/search-popup.ui |    3 ++-
 src/searchPopup.js  |   32 +++++++++++++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/search-popup.ui b/src/search-popup.ui
index 1d67507..0b4b1e5 100644
--- a/src/search-popup.ui
+++ b/src/search-popup.ui
@@ -14,10 +14,11 @@
         <child>
           <object class="GtkTreeView" id="treeview">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can_focus">True</property>
             <property name="expand">True</property>
             <property name="headers-visible">False</property>
             <property name="hover-selection">True</property>
+            <property name="activate-on-single-click">True</property>
             <child internal-child="selection">
               <object class="GtkTreeSelection" id="treeview-selection"/>
             </child>
diff --git a/src/searchPopup.js b/src/searchPopup.js
index 201d510..6874e95 100644
--- a/src/searchPopup.js
+++ b/src/searchPopup.js
@@ -57,8 +57,8 @@ const SearchPopup = new Lang.Class({
                                 GObject.TYPE_OBJECT]);
         this._treeView.model = model;
 
-        this._treeView.connect('button-press-event',
-                               this._onListButtonPress.bind(this));
+        this._treeView.connect('row-activated',
+                               this._onRowActivated.bind(this));
         this._initList();
         this.height_request = this._cellHeight * numVisible;
         this._scrolledWindow.set_min_content_height(this.height_request);
@@ -91,26 +91,18 @@ const SearchPopup = new Lang.Class({
         this._cellHeight += cell.get_preferred_height(this._treeView)[0];
     },
 
-    _onListButtonPress: function(widget, event) {
-        let path_valid, path;
-        let bool, coordX, coordY;
+    _onRowActivated: function(widget, path, column) {
+        let model = this._treeView.model;
+        let iter_valid, iter;
 
-        [bool, coordX, coordY] = event.get_coords();
-        [path_valid, path] = this._treeView.get_path_at_pos(coordX, coordY,
-                                                            null, null, null);
-        if (path_valid) {
-            let model = this._treeView.model;
-            let iter_valid, iter;
+        if (model === null)
+            return;
 
-            if (model === null)
-                return;
-
-            [iter_valid, iter] = model.get_iter(path);
-            if (!iter_valid)
-                return;
+        [iter_valid, iter] = model.get_iter(path);
+        if (!iter_valid)
+            return;
 
-            this.emit('selected', model.get_value(iter, Columns.PLACE));
-        }
+        this.emit('selected', model.get_value(iter, Columns.PLACE));
     },
 
     showSpinner: function() {
@@ -129,6 +121,8 @@ const SearchPopup = new Lang.Class({
 
         if (!this.get_visible())
             this.show();
+
+        this._treeView.grab_focus();
     },
 
     vfunc_show: function() {


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