Merge lp:~jeremywootten/pantheon-files/fix-1537536-search-selection-in-icon-view into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Danielle Foré
Approved revision: 2103
Merged at revision: 2106
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1537536-search-selection-in-icon-view
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 151 lines (+38/-15)
3 files modified
libwidgets/View/LocationBar.vala (+5/-7)
libwidgets/View/SearchResults.vala (+19/-6)
src/View/ViewContainer.vala (+14/-2)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1537536-search-selection-in-icon-view
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / tests Approve
Review via email: mp+291222@code.launchpad.net

Commit message

Stop emission of cursor-changed signals when clearing search list

Description of the change

This branch stops "cursor-changed" signals being emitted when clearing the search list, which was causing unexpected selections when no matches were found.

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Looks good, I am no longer getting strange selections.

review: Approve (code / tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libwidgets/View/LocationBar.vala'
--- libwidgets/View/LocationBar.vala 2016-02-11 11:12:03 +0000
+++ libwidgets/View/LocationBar.vala 2016-04-07 10:13:59 +0000
@@ -28,7 +28,7 @@
28 public bool search_mode {get; private set;}28 public bool search_mode {get; private set;}
2929
30 public signal void reload_request ();30 public signal void reload_request ();
31 public signal void focus_file_request (File file);31 public signal void focus_file_request (File? file);
32 public signal void escape ();32 public signal void escape ();
3333
34 public LocationBar () {34 public LocationBar () {
@@ -65,15 +65,13 @@
65 }65 }
6666
67 private void on_search_results_first_match_found (GLib.File? file) {67 private void on_search_results_first_match_found (GLib.File? file) {
68 if (file != null) {68 focus_file_request (file);
69 focus_file_request (file);
70 }
71 }69 }
70
72 private void on_search_results_cursor_changed (GLib.File? file) {71 private void on_search_results_cursor_changed (GLib.File? file) {
73 if (file != null) {72 focus_file_request (file);
74 focus_file_request (file);
75 }
76 }73 }
74
77 private void on_search_results_realize () {75 private void on_search_results_realize () {
78 (get_toplevel () as Gtk.Window).get_group ().add_window (search_results); /*Is this necessary every popup? */76 (get_toplevel () as Gtk.Window).get_group ().add_window (search_results); /*Is this necessary every popup? */
79 }77 }
8078
=== modified file 'libwidgets/View/SearchResults.vala'
--- libwidgets/View/SearchResults.vala 2016-02-11 11:12:03 +0000
+++ libwidgets/View/SearchResults.vala 2016-04-07 10:13:59 +0000
@@ -327,7 +327,6 @@
327 }327 }
328 }328 }
329329
330
331 bool on_button_press_event (Gdk.EventButton e) {330 bool on_button_press_event (Gdk.EventButton e) {
332 if (e.x >= 0 && e.y >= 0 && e.x < get_allocated_width () && e.y < get_allocated_height ()) {331 if (e.x >= 0 && e.y >= 0 && e.x < get_allocated_width () && e.y < get_allocated_height ()) {
333 view.event (e);332 view.event (e);
@@ -616,12 +615,14 @@
616615
617 is_grabbing = true;616 is_grabbing = true;
618 }617 }
619 /* Also pair signal connect and disconnect */618 /* Paired with disconnect function in popdown () */
620 view.cursor_changed.connect (on_cursor_changed);619 connect_view_cursor_changed_signal ();
621 }620 }
622621
623 void popdown ()622 void popdown ()
624 {623 {
624 /* Paired with connect function in popup () */
625 disconnect_view_cursor_changed_signal ();
625 if (is_grabbing) {626 if (is_grabbing) {
626 if (device == null) {627 if (device == null) {
627 /* 'device' can become null during searching for reasons as yet unidentified. This ensures628 /* 'device' can become null during searching for reasons as yet unidentified. This ensures
@@ -635,8 +636,7 @@
635 Gtk.device_grab_remove (this, device);636 Gtk.device_grab_remove (this, device);
636 is_grabbing = false;637 is_grabbing = false;
637 }638 }
638 /* Also pair signal connect and disconnect */639
639 view.cursor_changed.disconnect (on_cursor_changed);
640 hide ();640 hide ();
641 }641 }
642642
@@ -770,6 +770,9 @@
770770
771 protected void clear ()771 protected void clear ()
772 {772 {
773 /* Disconnect the cursor-changed signal so that it does not get emitted when entries removed
774 * causing incorrect files to get selected in icon view */
775 disconnect_view_cursor_changed_signal ();
773 Gtk.TreeIter parent, iter;776 Gtk.TreeIter parent, iter;
774 for (var valid = list.get_iter_first (out parent); valid; valid = list.iter_next (ref parent)) {777 for (var valid = list.get_iter_first (out parent); valid; valid = list.iter_next (ref parent)) {
775 if (!list.iter_nth_child (out iter, parent, 0))778 if (!list.iter_nth_child (out iter, parent, 0))
@@ -779,6 +782,8 @@
779 }782 }
780783
781 resize_popup ();784 resize_popup ();
785 /* Reconnect signal */
786 connect_view_cursor_changed_signal ();
782 }787 }
783788
784789
@@ -797,10 +802,11 @@
797802
798 filter.refilter ();803 filter.refilter ();
799804
800 select_first ();
801 if (local_search_finished && global_search_finished && list_empty ()) {805 if (local_search_finished && global_search_finished && list_empty ()) {
802 view.get_selection ().unselect_all ();806 view.get_selection ().unselect_all ();
803 first_match_found (null);807 first_match_found (null);
808 } else {
809 select_first ();
804 }810 }
805811
806 if (local_search_finished && global_search_finished) {812 if (local_search_finished && global_search_finished) {
@@ -999,6 +1005,13 @@
999 public bool has_popped_up () {1005 public bool has_popped_up () {
1000 return is_grabbing;1006 return is_grabbing;
1001 }1007 }
1008
1009 private void connect_view_cursor_changed_signal () {
1010 view.cursor_changed.connect (on_cursor_changed);
1011 }
1012 private void disconnect_view_cursor_changed_signal () {
1013 view.cursor_changed.disconnect (on_cursor_changed);
1014 }
1002 }1015 }
1003}1016}
10041017
10051018
=== modified file 'src/View/ViewContainer.vala'
--- src/View/ViewContainer.vala 2016-03-06 10:18:25 +0000
+++ src/View/ViewContainer.vala 2016-04-07 10:13:59 +0000
@@ -404,15 +404,27 @@
404 if (aslot != null)404 if (aslot != null)
405 aslot.set_frozen_state (is_frozen);405 aslot.set_frozen_state (is_frozen);
406 }406 }
407
408 private void set_all_selected (bool select_all) {
409 var aslot = get_current_slot ();
410 if (aslot != null) {
411 aslot.set_all_selected (select_all);
412 }
413 }
407 414
408 public void focus_location (GLib.File loc,415 public void focus_location (GLib.File? loc,
409 bool no_path_change = false,416 bool no_path_change = false,
410 bool unselect_others = false) {417 bool unselect_others = false) {
411418
412 /* This function navigates to another folder if necessary if 419 /* This function navigates to another folder if necessary if
413 * select_in_current_only is not set to true.420 * select_in_current_only is not set to true.
414 */421 */
415 assert (loc != null);422
423 /* Search can generate null focus requests if no match - deselect previous search selection */
424 if (loc == null) {
425 set_all_selected (false);
426 return;
427 }
416428
417 if (location.equal (loc)) {429 if (location.equal (loc)) {
418 return;430 return;

Subscribers

People subscribed via source and target branches

to all changes: