[tracker] tracker-needle: Go to search results from entry box by pressing Down



commit 2babd17d9463d770075edeeb6c7bd2502e0198c2
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Feb 11 12:29:40 2014 +0000

    tracker-needle: Go to search results from entry box by pressing Down
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723097

 src/tracker-needle/tracker-needle.vala |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 4350769..35cf954 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -58,6 +58,7 @@ public class Tracker.Needle {
        private uint limit = 500;
        static bool current_find_in_filelist = true;
        static bool current_find_in_icons = true;
+       private Widget current_view;
 
        private ResultStore categories_model;
        private ResultStore files_model;
@@ -304,6 +305,7 @@ public class Tracker.Needle {
                search = search_list.get_child () as Entry;
                search.changed.connect (search_changed);
                search.activate.connect (search_activated);
+               search.key_press_event.connect (search_key_press_event);
                search_history_insert (history.get ());
 
                spinner = new Spinner ();
@@ -366,6 +368,19 @@ public class Tracker.Needle {
                return false;
        }
 
+       private bool search_key_press_event (Gtk.Widget widget, Gdk.EventKey event) {
+               if (Gdk.keyval_name (event.keyval) == "Down" ||
+                   Gdk.keyval_name (event.keyval) == "KP_Down") {
+                       var child = ((ScrolledWindow) current_view).get_child ();
+
+                       if (child != null) {
+                               child.grab_focus();
+                       }
+               }
+
+               return false;
+       }
+
        private void search_changed (Editable editable) {
                if (last_search_id != 0) {
                        Source.remove (last_search_id);
@@ -459,9 +474,11 @@ public class Tracker.Needle {
 
                // Show correct window
                sw_noresults.hide ();
+               current_view = sw_noresults;
 
                if (view_icons.active) {
                        sw_icons.show ();
+                       current_view = sw_icons;
 
                        if (find_in_all.active) {
                                store = images_model;
@@ -476,6 +493,7 @@ public class Tracker.Needle {
 
                if (view_categories.active) {
                        sw_categories.show ();
+                       current_view = sw_categories;
                        store = categories_model;
                } else {
                        sw_categories.hide ();
@@ -483,6 +501,7 @@ public class Tracker.Needle {
 
                if (view_filelist.active) {
                        sw_filelist.show ();
+                       current_view = sw_filelist;
 
                        if (find_in_contents.active) {
                                store = files_model;


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