Merge lp:~jeremywootten/pantheon-files/refix-interactive-search into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Danielle Foré
Approved revision: 1663
Merged at revision: 1661
Proposed branch: lp:~jeremywootten/pantheon-files/refix-interactive-search
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 246 lines (+89/-11)
5 files modified
src/View/AbstractDirectoryView.vala (+11/-1)
src/View/LocationBar.vala (+6/-1)
src/View/SearchResults.vala (+56/-2)
src/View/ViewContainer.vala (+11/-6)
src/View/Window.vala (+5/-1)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/refix-interactive-search
Reviewer Review Type Date Requested Status
Danielle Foré ux Approve
PerfectCarl (community) (code) Approve
Artem Anufrij (community) behavior Needs Information
Review via email: mp+243207@code.launchpad.net

Commit message

Fix interactive search using the pathbar.

Description of the change

This branch corrects a conflict resolution error made when merging the branch that was supposed to fix it which rendered that fix ineffective.

To post a comment you must log in.
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Hey Jeremy,

what do you think about following behavior:

1. open a folder
2. typing a search text
 --- new feature
3. Press CTRL+F for switch to global search instead "CURRENT_DIRECTORY_ONLY".

??

In the currently version its not possible.

review: Needs Information (behavior)
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I don't see why that cannot be implemented quite easily. Give me a day or so.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

1. Enter a search text
2. Select a result item
3. Press enter

expected:
"files" selects the file and scrolls it into view.

currently:
"files" selects the file, but they will be not scrolled into view.

following behavior would be perfect, in my opinion:

1. Type search text

2. Navigate with the arrow keys in the result popup.
 -> selected file will be selected and scrolled into view.

3. On press enter
 -> run selected file.

what do you think about?

review: Needs Information (behavior)
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

It think it will be useful, if the filenames will be checked like "contains (searchtext)" instead "starts_with (searchtext)".

1658. By Jeremy Wootten

Convert from local to global search with Ctrl-F

1659. By Jeremy Wootten

Fix scroll to selected file

1660. By Jeremy Wootten

Selection follows cursor

1661. By Jeremy Wootten

Fix bugs in selection follows cursor

1662. By Jeremy Wootten

Merge trunk rev 1659

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Scroll to selected file fixed.
Selection in current directory follows search view cursor implemented.

1663. By Jeremy Wootten

Ensure location pathbar loses focus after accepting search result

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The global search performs a "contains (text)" search but the local search in the current directory performs a "begins with (text)" search in order to match the existing behaviour of the trunk and the native interactive search of Gtk.TreeView.

It would be easy to use a "contains (text)" search for both but I think this should be be cleared by the UI team.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I don't think its a good idea to "run" the selected search result (i.e. load it into the appropriate default application) - the user may not want this. However, you can suggest it to the UI team.

Revision history for this message
PerfectCarl (name-is-carl) wrote :

The local search (ie what happens what I type text in the view) works.
But the display flickers quite a lot each time I type another key.

Let's say I have a unique subfolder 'good' in my folder and that I'm starting to type 'g'.
The focus goes in the pathbar (as expected) and then I continue to type 'o', 'o' and so on.

Each time the dropbox is re-created with exactly the same item.
It feels very slow and it flickers a lot as we can see the dropbox being cleared and
repopulated with the same item.

Global search (Ctrl+F) works nicely.

I feel like the UX team should really do a pass on this to be sure that
everything feels the way it should.

Code is approved

review: Approve ((code))
Revision history for this message
Danielle Foré (danrabbit) wrote :

The flickering problem is something we face in Midori and is already present in trunk, so I wouldn't block this branch based on that. But it is indeed pretty annoying :/

I think we should maintain the "begins with" behavior. I think there's a lot of people (like me) that rely on this behavior to navigate quickly. I know there was a quite an uproar when Nautilus changed its behavior regarding "type ahead".

I'm going to approve, because I think this feature is super important. But I do think there's room for discussion and improvement regarding type ahead and search in general and it would be desirable to have a single consistent search results UI :)

review: Approve (ux)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/View/AbstractDirectoryView.vala'
2--- src/View/AbstractDirectoryView.vala 2014-11-25 13:01:07 +0000
3+++ src/View/AbstractDirectoryView.vala 2014-12-01 12:20:59 +0000
4@@ -372,7 +372,7 @@
5 if (model.get_first_iter_for_file (file, out iter)) {
6 Gtk.TreePath path = model.get_path (iter);
7 if (path != null) {
8- if (focus_location == file.location)
9+ if (focus_location.equal (file.location))
10 set_cursor (path, false, true, false); /* set cursor and select */
11 else
12 select_path (path);
13@@ -2244,6 +2244,16 @@
14 break;
15 }
16
17+ /* Use find function instead of view interactive search */
18+ if (no_mods || only_shift_pressed) {
19+ /* Use printable characters to initiate search */
20+ if (((unichar)(Gdk.keyval_to_unicode (event.keyval))).isprint ()) {
21+ window.win_actions.activate_action ("find", "CURRENT_DIRECTORY_ONLY");
22+ window.key_press_event (event);
23+ return true;
24+ }
25+ }
26+
27 return false;
28 }
29
30
31=== modified file 'src/View/LocationBar.vala'
32--- src/View/LocationBar.vala 2014-11-25 22:49:10 +0000
33+++ src/View/LocationBar.vala 2014-12-01 12:20:59 +0000
34@@ -252,10 +252,15 @@
35 win.current_tab.focus_location (file);
36
37 search_mode = false;
38+ escape ();
39+ });
40+
41+ search_results.cursor_changed.connect ((file) => {
42+ win.current_tab.focus_location_if_in_current_directory (file, true);
43 });
44
45 search_results.first_match_found.connect ((file) => {
46- win.current_tab.focus_location_if_in_current_directory (file);
47+ win.current_tab.focus_location_if_in_current_directory (file, true);
48 });
49
50 search_results.hide.connect (() => {
51
52=== modified file 'src/View/SearchResults.vala'
53--- src/View/SearchResults.vala 2014-11-14 11:47:50 +0000
54+++ src/View/SearchResults.vala 2014-12-01 12:20:59 +0000
55@@ -44,6 +44,7 @@
56 const int DELAY_ADDING_RESULTS = 150;
57
58 public signal void file_selected (File file);
59+ public signal void cursor_changed (File? file);
60 public signal void first_match_found (File? file);
61
62 public Gtk.Entry entry { get; construct; }
63@@ -83,6 +84,8 @@
64 Gtk.TreeModelFilter filter;
65 Gtk.ScrolledWindow scroll;
66
67+ ulong cursor_changed_handler_id;
68+
69 public SearchResults (Gtk.Entry entry)
70 {
71 Object (entry: entry,
72@@ -111,6 +114,7 @@
73 scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
74
75 view = new Gtk.TreeView ();
76+ view.get_selection ().set_mode (Gtk.SelectionMode.BROWSE);
77 view.headers_visible = false;
78 view.show_expanders = false;
79 view.level_indentation = 12;
80@@ -189,6 +193,7 @@
81 Gtk.TreePath path;
82 Gtk.TreeIter iter;
83
84+ SignalHandler.block (view, cursor_changed_handler_id);
85 view.get_path_at_pos ((int) e.x, (int) e.y, out path, null, null, null);
86
87 if (path != null) {
88@@ -196,23 +201,55 @@
89 filter.convert_iter_to_child_iter (out iter, iter);
90 accept (iter);
91 }
92-
93+ SignalHandler.unblock (view, cursor_changed_handler_id);
94 return true;
95 });
96
97+ cursor_changed_handler_id = view.cursor_changed.connect (on_cursor_changed);
98+
99 key_release_event.connect (key_event);
100 key_press_event.connect (key_event);
101
102 entry.key_press_event.connect (entry_key_press);
103 }
104
105+ void on_cursor_changed () {
106+ Gtk.TreeIter iter;
107+ Gtk.TreePath? path = null;
108+ var selected_paths = view.get_selection ().get_selected_rows (null);
109+
110+ if (selected_paths != null)
111+ path = selected_paths.data;
112+
113+ if (path != null) {
114+ filter.get_iter (out iter, path);
115+ filter.convert_iter_to_child_iter (out iter, iter);
116+ cursor_changed (get_file_at_iter (iter));
117+ }
118+
119+ }
120+
121 bool entry_key_press (Gdk.EventKey event)
122 {
123 if (!get_mapped ())
124 return false;
125
126+ var mods = event.state & Gtk.accelerator_get_default_mod_mask ();
127+ bool only_control_pressed = (mods == Gdk.ModifierType.CONTROL_MASK);
128+
129+ if (mods != 0) {
130+ if (only_control_pressed && event.keyval == Gdk.Key.f) {
131+ search_current_directory_only = false;
132+ begins_with_only = false;
133+ entry.changed ();
134+ return true;
135+ } else
136+ return false;
137+ }
138+
139 switch (event.keyval) {
140 case Gdk.Key.Escape:
141+ cursor_changed (null); /* Clears selection in view */
142 popdown ();
143 return true;
144 case Gdk.Key.Return:
145@@ -400,7 +437,7 @@
146
147 y += entry_alloc.height;
148
149- if (y + height > workarea.x + workarea.height)
150+ if (y + height > workarea.y + workarea.height)
151 height = workarea.y + workarea.height - y - 12;
152
153 scroll.set_min_content_height (height);
154@@ -415,6 +452,10 @@
155 Gtk.TreeIter filter_iter;
156
157 view.get_cursor (out path, null);
158+
159+ if (path == null)
160+ return;
161+
162 filter.get_iter (out filter_iter, path);
163
164 filter.convert_iter_to_child_iter (out iter, filter_iter);
165@@ -569,6 +610,19 @@
166 popdown ();
167 }
168
169+ File? get_file_at_iter (Gtk.TreeIter? iter)
170+ {
171+ if (iter == null) {
172+ get_iter_at_cursor (out iter);
173+ }
174+
175+ File? file = null;
176+ if (iter != null)
177+ list.@get (iter, 3, out file);
178+
179+ return file;
180+ }
181+
182 public void clear ()
183 {
184 Gtk.TreeIter parent, iter;
185
186=== modified file 'src/View/ViewContainer.vala'
187--- src/View/ViewContainer.vala 2014-11-24 21:24:29 +0000
188+++ src/View/ViewContainer.vala 2014-12-01 12:20:59 +0000
189@@ -298,13 +298,16 @@
190 get_current_slot ().set_active_state (is_active);
191 }
192
193- public void focus_location (GLib.File? file, bool select_in_current_only = false) {
194- if (file == null) {
195+ public void focus_location (GLib.File? file,
196+ bool select_in_current_only = false,
197+ bool unselect_others = false) {
198+
199+ if (unselect_others || file == null) {
200 get_current_slot ().set_all_selected (false);
201- return;
202+ selected_locations = null;
203 }
204
205- if (location.equal (file))
206+ if (file == null || location.equal (file))
207 return;
208
209 GLib.File? loc = null;
210@@ -332,8 +335,10 @@
211 }
212 }
213
214- public void focus_location_if_in_current_directory (GLib.File? file) {
215- focus_location (file, true);
216+ public void focus_location_if_in_current_directory (GLib.File? file,
217+ bool unselect_others = false) {
218+
219+ focus_location (file, true, unselect_others);
220 }
221
222 public string get_root_uri () {
223
224=== modified file 'src/View/Window.vala'
225--- src/View/Window.vala 2014-11-25 13:01:07 +0000
226+++ src/View/Window.vala 2014-12-01 12:20:59 +0000
227@@ -425,7 +425,7 @@
228 top_menu.location_bar.enter_search_mode (true, true);
229 else
230 top_menu.location_bar.enter_search_mode ();
231-
232+
233 }
234
235 private void action_new_window (GLib.SimpleAction action, GLib.Variant? param) {
236@@ -466,6 +466,10 @@
237 default:
238 break;
239 }
240+
241+ /* cancel any unfinished location bar activity */
242+ top_menu.location_bar.escape ();
243+
244 current_tab.change_view_mode (mode);
245 update_view_mode (mode);
246 }

Subscribers

People subscribed via source and target branches

to all changes: