Merge lp:~jeremywootten/pantheon-files/fix-regression-rename-in-listview-does-not-grab-keyboard-focus into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: David Hewitt
Approved revision: 2524
Merged at revision: 2524
Proposed branch: lp:~jeremywootten/pantheon-files/fix-regression-rename-in-listview-does-not-grab-keyboard-focus
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 35 lines (+10/-1)
1 file modified
src/View/Widgets/SingleLineEditableLabel.vala (+10/-1)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-regression-rename-in-listview-does-not-grab-keyboard-focus
Reviewer Review Type Date Requested Status
David Hewitt Approve
Review via email: mp+319853@code.launchpad.net

Commit message

Fix regression caused by r2522

Description of the change

This branch fixes a regression in renaming using list and column view using only keyboard caused by fix recently merged at r2522.

While that fix worked if the name was clicked on to edit, immediately typing in a new name did not work. While the appropriate part of the name appeared selected, the editable widget did not have keyboard focus.

A slightly less simple fix is needed, delaying the selection of the required region until the editable widget (Gtk.Entry) is realized and the start_editing method has been called.

To post a comment you must log in.
Revision history for this message
David Hewitt (davidmhewitt) wrote :

Can confirm this fixes the regression and still works fine for renaming by right clicking and selecting rename.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/View/Widgets/SingleLineEditableLabel.vala'
2--- src/View/Widgets/SingleLineEditableLabel.vala 2017-03-10 18:19:39 +0000
3+++ src/View/Widgets/SingleLineEditableLabel.vala 2017-03-14 17:42:20 +0000
4@@ -20,6 +20,8 @@
5 public class SingleLineEditableLabel : AbstractEditableLabel {
6
7 protected Gtk.Entry textview;
8+ private int select_start = 0;
9+ private int select_end = 0;
10
11 public SingleLineEditableLabel () {}
12
13@@ -65,7 +67,11 @@
14 /** Gtk.Editable interface */
15
16 public override void select_region (int start_pos, int end_pos) {
17- textview.select_region (start_pos, end_pos);
18+ /* Cannot select textview region here because it is not realised yet and the selected region
19+ * will be overridden when keyboard focus is grabbed after realising. So just remember start and end.
20+ */
21+ select_start = start_pos;
22+ select_end = end_pos;
23 }
24
25 public override void do_delete_text (int start_pos, int end_pos) {
26@@ -101,6 +107,9 @@
27 }
28
29 public override void start_editing (Gdk.Event? event) {
30+ /* Now realised. Grab keyboard focus first and then select region */
31+ textview.grab_focus ();
32+ textview.select_region (select_start, select_end);
33 }
34 }
35 }

Subscribers

People subscribed via source and target branches

to all changes: