Merge lp:~jeremywootten/pantheon-files/fix-1452574-ctrl-click-unselect into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1812
Merged at revision: 1823
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1452574-ctrl-click-unselect
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 187 lines (+40/-31)
2 files modified
src/View/AbstractDirectoryView.vala (+36/-27)
src/View/ListView.vala (+4/-4)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1452574-ctrl-click-unselect
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+258718@code.launchpad.net

Commit message

Control-click on selected item now deselects it (lp:1452574)

Description of the change

This branch fixes a regression caused by rev 1811 whereby Ctrl-Click on a selected item no longer de-selected it.

To test:
1)
  a) Select one or more items using Ctrl-Click or otherwise
  b) Ctrl-Click on a selected item (icon or name) - that item deselects.

2) Check other button press linked behaviours unaffected (selection, activation, rubberbanding, DND, etc).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2015-04-18 12:10:52 +0000
+++ src/View/AbstractDirectoryView.vala 2015-05-10 10:19:11 +0000
@@ -181,6 +181,8 @@
181 public bool single_click_mode {get; set;}181 public bool single_click_mode {get; set;}
182 protected bool should_activate = false;182 protected bool should_activate = false;
183 protected bool should_scroll = true;183 protected bool should_scroll = true;
184 protected bool should_deselect = false;
185 protected Gtk.TreePath? click_path = null;
184 protected uint click_zone = ClickZone.ICON;186 protected uint click_zone = ClickZone.ICON;
185 protected uint previous_click_zone = ClickZone.ICON;187 protected uint previous_click_zone = ClickZone.ICON;
186188
@@ -1404,9 +1406,9 @@
14041406
1405/** Handle Drop target signals*/1407/** Handle Drop target signals*/
1406 private bool on_drag_motion (Gdk.DragContext context,1408 private bool on_drag_motion (Gdk.DragContext context,
1407 int x,1409 int x,
1408 int y,1410 int y,
1409 uint timestamp) {1411 uint timestamp) {
1410 /* if we don't have drop data already ... */1412 /* if we don't have drop data already ... */
1411 if (!drop_data_ready && !get_drop_data (context, x, y, timestamp))1413 if (!drop_data_ready && !get_drop_data (context, x, y, timestamp))
1412 return false;1414 return false;
@@ -2449,7 +2451,7 @@
2449 new_empty_folder ();2451 new_empty_folder ();
24502452
2451 return true;2453 return true;
2452 2454
2453 case Gdk.Key.A:2455 case Gdk.Key.A:
2454 if (shift_pressed && only_control_pressed)2456 if (shift_pressed && only_control_pressed)
2455 invert_selection ();2457 invert_selection ();
@@ -2694,7 +2696,6 @@
26942696
2695 protected virtual bool handle_primary_button_click (Gdk.EventButton event, Gtk.TreePath? path) {2697 protected virtual bool handle_primary_button_click (Gdk.EventButton event, Gtk.TreePath? path) {
2696 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);2698 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);
2697 should_activate = single_click_mode || double_click_event;
26982699
2699 if (!double_click_event)2700 if (!double_click_event)
2700 start_drag_timer ((Gdk.Event)event);2701 start_drag_timer ((Gdk.Event)event);
@@ -2733,6 +2734,7 @@
2733 unselect_path (path);2734 unselect_path (path);
2734 path = null;2735 path = null;
2735 }2736 }
2737 click_path = path;
27362738
2737 /* Unless single click renaming is enabled, treat name same as blank zone */2739 /* Unless single click renaming is enabled, treat name same as blank zone */
2738 if (!single_click_rename && click_zone == ClickZone.NAME)2740 if (!single_click_rename && click_zone == ClickZone.NAME)
@@ -2752,10 +2754,10 @@
2752 * dragging on blank areas2754 * dragging on blank areas
2753 */2755 */
2754 block_drag_and_drop ();2756 block_drag_and_drop ();
2757
2755 /* Handle un-modified clicks or control-clicks here else pass on.2758 /* Handle un-modified clicks or control-clicks here else pass on.
2756 */2759 */
2757 if (!no_mods && !only_control_pressed) {2760 if (!no_mods && !only_control_pressed) {
2758 block_drag_and_drop ();
2759 return window.button_press_event (event);2761 return window.button_press_event (event);
2760 }2762 }
27612763
@@ -2763,7 +2765,8 @@
2763 if (no_mods)2765 if (no_mods)
2764 unselect_all ();2766 unselect_all ();
27652767
2766 if (!on_blank)2768 /* If modifier pressed then default handler determines selection */
2769 if (no_mods && !on_blank)
2767 select_path (path);2770 select_path (path);
2768 }2771 }
27692772
@@ -2773,20 +2776,32 @@
27732776
2774 switch (event.button) {2777 switch (event.button) {
2775 case Gdk.BUTTON_PRIMARY:2778 case Gdk.BUTTON_PRIMARY:
2779 /* Control-click should deselect previously selected path on key release (unless
2780 * pointer moves)
2781 */
2782 should_deselect = only_control_pressed && path_selected;
2783
2776 switch (click_zone) {2784 switch (click_zone) {
2777 case ClickZone.BLANK_NO_PATH:2785 case ClickZone.BLANK_NO_PATH:
2778 result = false;2786 result = false;
2779 break;2787 break;
27802788
2781 case ClickZone.BLANK_PATH:2789 case ClickZone.BLANK_PATH:
2790 case ClickZone.ICON:
2782 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);2791 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);
2792 /* determine whether should activate on key release (unless pointer moved)*/
2783 should_activate = no_mods &&2793 should_activate = no_mods &&
2784 activate_on_blank &&2794 (!on_blank || activate_on_blank) &&
2785 (single_click_mode || double_click_event);2795 (single_click_mode || double_click_event);
27862796
2787 if (!activate_on_blank || !path_selected) {2797 /* We need to decide whether to rubberband or drag&drop.
2788 result = false;2798 * Rubberband if modifer pressed or if not on the icon and either
2789 } else2799 * the item is unselected or activate_on_blank is not enabled.
2800 */
2801
2802 if (!no_mods || (on_blank && (!activate_on_blank || !path_selected)))
2803 result = false; /* Rubberband */
2804 else
2790 result = handle_primary_button_click (event, path);2805 result = handle_primary_button_click (event, path);
27912806
2792 break;2807 break;
@@ -2803,14 +2818,6 @@
2803 rename_file (selected_files.data);2818 rename_file (selected_files.data);
2804 break;2819 break;
28052820
2806 case ClickZone.ICON:
2807 /* Allow dragging of icons */
2808 unblock_drag_and_drop ();
2809 if (no_mods)
2810 result = handle_primary_button_click (event, path);
2811
2812 break;
2813
2814 case ClickZone.EXPANDER:2821 case ClickZone.EXPANDER:
2815 /* on expanders (if any) or xpad. Handle ourselves so that clicking2822 /* on expanders (if any) or xpad. Handle ourselves so that clicking
2816 * on xpad also expands/collapses row (accessibility)*/2823 * on xpad also expands/collapses row (accessibility)*/
@@ -2858,17 +2865,19 @@
28582865
2859 slot.active (should_scroll);2866 slot.active (should_scroll);
28602867
2861 if (should_activate) {2868 Gtk.Widget widget = get_real_view ();
2862 Gtk.Widget widget = get_real_view ();2869 int x = (int)event.x;
2863 int x = (int)event.x;2870 int y = (int)event.y;
2864 int y = (int)event.y;2871 /* Only take action if pointer has not moved */
28652872 if (!Gtk.drag_check_threshold (widget, drag_x, drag_y, x, y)) {
2866 /* Only activate if pointer has not moved */2873 if (should_activate)
2867 if (!Gtk.drag_check_threshold (widget, drag_x, drag_y, x, y))
2868 activate_selected_items (Marlin.OpenFlag.DEFAULT);2874 activate_selected_items (Marlin.OpenFlag.DEFAULT);
2875 else if (should_deselect && click_path != null)
2876 unselect_path (click_path);
2869 }2877 }
2870
2871 should_activate = false;2878 should_activate = false;
2879 should_deselect = false;
2880 click_path = null;
2872 return false;2881 return false;
2873 }2882 }
28742883
28752884
=== modified file 'src/View/ListView.vala'
--- src/View/ListView.vala 2015-03-26 02:19:38 +0000
+++ src/View/ListView.vala 2015-05-10 10:19:11 +0000
@@ -53,7 +53,7 @@
53 var renderer = new Gtk.CellRendererText ();53 var renderer = new Gtk.CellRendererText ();
54 var col = new Gtk.TreeViewColumn.with_attributes (column_titles [k - fnc],54 var col = new Gtk.TreeViewColumn.with_attributes (column_titles [k - fnc],
55 renderer,55 renderer,
56 "text", k); 56 "text", k);
57 col.set_sort_column_id (k);57 col.set_sort_column_id (k);
58 col.set_resizable (false);58 col.set_resizable (false);
59 col.set_expand (false);59 col.set_expand (false);
@@ -207,10 +207,10 @@
207 protected override bool get_next_visible_iter (ref Gtk.TreeIter iter, bool recurse = true) {207 protected override bool get_next_visible_iter (ref Gtk.TreeIter iter, bool recurse = true) {
208 Gtk.TreePath? path = model.get_path (iter);208 Gtk.TreePath? path = model.get_path (iter);
209 Gtk.TreeIter start = iter;209 Gtk.TreeIter start = iter;
210 210
211 if (path == null)211 if (path == null)
212 return false;212 return false;
213 213
214 if (recurse && tree.is_row_expanded (path)) {214 if (recurse && tree.is_row_expanded (path)) {
215 Gtk.TreeIter? child_iter = null;215 Gtk.TreeIter? child_iter = null;
216 if (model.iter_children (out child_iter, iter)) {216 if (model.iter_children (out child_iter, iter)) {
@@ -218,7 +218,7 @@
218 return true;218 return true;
219 }219 }
220 }220 }
221 221
222 if (model.iter_next (ref iter))222 if (model.iter_next (ref iter))
223 return true;223 return true;
224 else {224 else {

Subscribers

People subscribed via source and target branches

to all changes: