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
1=== modified file 'src/View/AbstractDirectoryView.vala'
2--- src/View/AbstractDirectoryView.vala 2015-04-18 12:10:52 +0000
3+++ src/View/AbstractDirectoryView.vala 2015-05-10 10:19:11 +0000
4@@ -181,6 +181,8 @@
5 public bool single_click_mode {get; set;}
6 protected bool should_activate = false;
7 protected bool should_scroll = true;
8+ protected bool should_deselect = false;
9+ protected Gtk.TreePath? click_path = null;
10 protected uint click_zone = ClickZone.ICON;
11 protected uint previous_click_zone = ClickZone.ICON;
12
13@@ -1404,9 +1406,9 @@
14
15 /** Handle Drop target signals*/
16 private bool on_drag_motion (Gdk.DragContext context,
17- int x,
18- int y,
19- uint timestamp) {
20+ int x,
21+ int y,
22+ uint timestamp) {
23 /* if we don't have drop data already ... */
24 if (!drop_data_ready && !get_drop_data (context, x, y, timestamp))
25 return false;
26@@ -2449,7 +2451,7 @@
27 new_empty_folder ();
28
29 return true;
30-
31+
32 case Gdk.Key.A:
33 if (shift_pressed && only_control_pressed)
34 invert_selection ();
35@@ -2694,7 +2696,6 @@
36
37 protected virtual bool handle_primary_button_click (Gdk.EventButton event, Gtk.TreePath? path) {
38 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);
39- should_activate = single_click_mode || double_click_event;
40
41 if (!double_click_event)
42 start_drag_timer ((Gdk.Event)event);
43@@ -2733,6 +2734,7 @@
44 unselect_path (path);
45 path = null;
46 }
47+ click_path = path;
48
49 /* Unless single click renaming is enabled, treat name same as blank zone */
50 if (!single_click_rename && click_zone == ClickZone.NAME)
51@@ -2752,10 +2754,10 @@
52 * dragging on blank areas
53 */
54 block_drag_and_drop ();
55+
56 /* Handle un-modified clicks or control-clicks here else pass on.
57 */
58 if (!no_mods && !only_control_pressed) {
59- block_drag_and_drop ();
60 return window.button_press_event (event);
61 }
62
63@@ -2763,7 +2765,8 @@
64 if (no_mods)
65 unselect_all ();
66
67- if (!on_blank)
68+ /* If modifier pressed then default handler determines selection */
69+ if (no_mods && !on_blank)
70 select_path (path);
71 }
72
73@@ -2773,20 +2776,32 @@
74
75 switch (event.button) {
76 case Gdk.BUTTON_PRIMARY:
77+ /* Control-click should deselect previously selected path on key release (unless
78+ * pointer moves)
79+ */
80+ should_deselect = only_control_pressed && path_selected;
81+
82 switch (click_zone) {
83 case ClickZone.BLANK_NO_PATH:
84 result = false;
85 break;
86
87 case ClickZone.BLANK_PATH:
88+ case ClickZone.ICON:
89 bool double_click_event = (event.type == Gdk.EventType.@2BUTTON_PRESS);
90+ /* determine whether should activate on key release (unless pointer moved)*/
91 should_activate = no_mods &&
92- activate_on_blank &&
93+ (!on_blank || activate_on_blank) &&
94 (single_click_mode || double_click_event);
95
96- if (!activate_on_blank || !path_selected) {
97- result = false;
98- } else
99+ /* We need to decide whether to rubberband or drag&drop.
100+ * Rubberband if modifer pressed or if not on the icon and either
101+ * the item is unselected or activate_on_blank is not enabled.
102+ */
103+
104+ if (!no_mods || (on_blank && (!activate_on_blank || !path_selected)))
105+ result = false; /* Rubberband */
106+ else
107 result = handle_primary_button_click (event, path);
108
109 break;
110@@ -2803,14 +2818,6 @@
111 rename_file (selected_files.data);
112 break;
113
114- case ClickZone.ICON:
115- /* Allow dragging of icons */
116- unblock_drag_and_drop ();
117- if (no_mods)
118- result = handle_primary_button_click (event, path);
119-
120- break;
121-
122 case ClickZone.EXPANDER:
123 /* on expanders (if any) or xpad. Handle ourselves so that clicking
124 * on xpad also expands/collapses row (accessibility)*/
125@@ -2858,17 +2865,19 @@
126
127 slot.active (should_scroll);
128
129- if (should_activate) {
130- Gtk.Widget widget = get_real_view ();
131- int x = (int)event.x;
132- int y = (int)event.y;
133-
134- /* Only activate if pointer has not moved */
135- if (!Gtk.drag_check_threshold (widget, drag_x, drag_y, x, y))
136+ Gtk.Widget widget = get_real_view ();
137+ int x = (int)event.x;
138+ int y = (int)event.y;
139+ /* Only take action if pointer has not moved */
140+ if (!Gtk.drag_check_threshold (widget, drag_x, drag_y, x, y)) {
141+ if (should_activate)
142 activate_selected_items (Marlin.OpenFlag.DEFAULT);
143+ else if (should_deselect && click_path != null)
144+ unselect_path (click_path);
145 }
146-
147 should_activate = false;
148+ should_deselect = false;
149+ click_path = null;
150 return false;
151 }
152
153
154=== modified file 'src/View/ListView.vala'
155--- src/View/ListView.vala 2015-03-26 02:19:38 +0000
156+++ src/View/ListView.vala 2015-05-10 10:19:11 +0000
157@@ -53,7 +53,7 @@
158 var renderer = new Gtk.CellRendererText ();
159 var col = new Gtk.TreeViewColumn.with_attributes (column_titles [k - fnc],
160 renderer,
161- "text", k);
162+ "text", k);
163 col.set_sort_column_id (k);
164 col.set_resizable (false);
165 col.set_expand (false);
166@@ -207,10 +207,10 @@
167 protected override bool get_next_visible_iter (ref Gtk.TreeIter iter, bool recurse = true) {
168 Gtk.TreePath? path = model.get_path (iter);
169 Gtk.TreeIter start = iter;
170-
171+
172 if (path == null)
173 return false;
174-
175+
176 if (recurse && tree.is_row_expanded (path)) {
177 Gtk.TreeIter? child_iter = null;
178 if (model.iter_children (out child_iter, iter)) {
179@@ -218,7 +218,7 @@
180 return true;
181 }
182 }
183-
184+
185 if (model.iter_next (ref iter))
186 return true;
187 else {

Subscribers

People subscribed via source and target branches

to all changes: