Merge lp:~jeremywootten/pantheon-files/fix-1643526-block-focus-out-during-rename into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 2474
Merged at revision: 2510
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1643526-block-focus-out-during-rename
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 127 lines (+26/-18)
4 files modified
src/TextRenderer.vala (+12/-11)
src/View/AbstractDirectoryView.vala (+5/-1)
src/View/IconView.vala (+2/-2)
src/View/Widgets/AbstractEditableLabel.vala (+7/-4)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1643526-block-focus-out-during-rename
Reviewer Review Type Date Requested Status
Leonardo Lemos (community) i18n Approve
David Hewitt code, function Approve
Review via email: mp+317374@code.launchpad.net

This proposal supersedes a proposal from 2017-02-08.

Commit message

Do not end name editing when focus is lost

Description of the change

This branch fixes the issue where file or bookmark renaming ends prematurely of the Ctrl key is pressed. This only occurs if the accessibility option "Reveal pointer" is active, because the entry loses focus while the animation is shown. It also fixes premature ending of rename if the keyboard layout is switched (Alt +Shift)

A side effect of this branch is that rename does not end if you switch to another app. This allows pasting a name in from elsewhere.

To confirm rename press Enter. To cancel rename press Esc or click on the view widget or navigate away from the folder.

To post a comment you must log in.
Revision history for this message
Jeremy Wootten (jeremywootten) wrote : Posted in a previous version of this proposal

This is a better solution than the first attempt - the name of the branch is not quite accurate now.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote : Posted in a previous version of this proposal

Regression found in autorename new folder.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote : Posted in a previous version of this proposal

Regression now fixed.

Revision history for this message
David Hewitt (davidmhewitt) wrote : Posted in a previous version of this proposal

I'm not so sure about this one. It definitely fixes the very annoying bug of renaming being cancelled when you press any of the hotkeys. But I don't like not being able to click in the window to cancel renaming. I feel like this is something that quite a few users would do.

It's especially bad that once you've clicked in the window, it then doesn't cancel when pressing escape or enter until you click back in the text field. How hard would it be to make any window click event cancel editing?

review: Disapprove
Revision history for this message
Jeremy Wootten (jeremywootten) wrote : Posted in a previous version of this proposal

OK, I'll see whether that can be arranged.

Revision history for this message
David Hewitt (davidmhewitt) wrote :

I'm happy with this now, but I won't set the status to approved so that Cody can decide whether to merge before or after his release.

review: Approve (code, function)
Revision history for this message
Maxim Taranov (png2378) wrote :

Of course, It would be better to fix the cause (bug #1593358), not the consequence. But I think this MR is good and helpful temporary workaround, because problem with objects renaming in Files is most frequent case of bug with lost focus.

This branch didn't cause me any problems and works well, but I still can't change keyboard layout during the search in Files.

I also want to note that for some reasons Nautilus (I tried 3.18.4 and latest 3.23.90) behaves similarly - rename does not end if you switch to another window.

Revision history for this message
Leonardo Lemos (leonardolemos) :
review: Approve (i18n)
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

> Of course, It would be better to fix the cause (bug #1593358), not the
> consequence. But I think this MR is good and helpful temporary workaround,
> because problem with objects renaming in Files is most frequent case of bug
> with lost focus.
>
> This branch didn't cause me any problems and works well, but I still can't
> change keyboard layout during the search in Files.
>
> I also want to note that for some reasons Nautilus (I tried 3.18.4 and latest
> 3.23.90) behaves similarly - rename does not end if you switch to another
> window.

Yes, this branch was only intended to fix renaming. The keyboard layout issue with the pathbar will be dealt with separately.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/TextRenderer.vala'
2--- src/TextRenderer.vala 2017-01-27 12:16:50 +0000
3+++ src/TextRenderer.vala 2017-02-15 19:03:51 +0000
4@@ -34,18 +34,20 @@
5 int focus_border_width;
6 Pango.Layout layout;
7 Gtk.Widget widget;
8- public Marlin.AbstractEditableLabel entry;
9+ Marlin.AbstractEditableLabel entry;
10+
11+ construct {
12+ this.mode = Gtk.CellRendererMode.EDITABLE;
13+ }
14
15 public TextRenderer (Marlin.ViewMode viewmode) {
16- this.mode = Gtk.CellRendererMode.EDITABLE;
17-
18- if (viewmode == Marlin.ViewMode.ICON)
19+ if (viewmode == Marlin.ViewMode.ICON) {
20 entry = new Marlin.MultiLineEditableLabel ();
21- else
22+ } else {
23 entry = new Marlin.SingleLineEditableLabel ();
24+ }
25
26 entry.editing_done.connect (on_entry_editing_done);
27- entry.get_real_editable ().focus_out_event.connect_after (on_entry_focus_out_event);
28 }
29
30 public override void get_preferred_height_for_width (Gtk.Widget widget, int width, out int minimum_size, out int natural_size) {
31@@ -180,6 +182,10 @@
32 return entry as Gtk.CellEditable;
33 }
34
35+ public void end_editing (bool cancel) {
36+ entry.end_editing (cancel);
37+ }
38+
39 private void set_widget (Gtk.Widget? _widget) {
40 Pango.FontMetrics metrics;
41 Pango.Context context;
42@@ -246,11 +252,6 @@
43 file = null;
44 }
45
46- private bool on_entry_focus_out_event (Gdk.Event event) {
47- on_entry_editing_done ();
48- return false;
49- }
50-
51 private void draw_focus (Cairo.Context cr,
52 Gdk.Rectangle cell_area,
53 Gtk.CellRendererState flags,
54
55=== modified file 'src/View/AbstractDirectoryView.vala'
56--- src/View/AbstractDirectoryView.vala 2017-02-07 19:38:46 +0000
57+++ src/View/AbstractDirectoryView.vala 2017-02-15 19:03:51 +0000
58@@ -3110,7 +3110,11 @@
59 }
60
61 protected virtual bool on_view_button_press_event (Gdk.EventButton event) {
62- grab_focus (); /* cancels any renaming */
63+ if (renaming) {
64+ /* Cancel renaming */
65+ name_renderer.end_editing (true);
66+ }
67+
68 cancel_hover (); /* cancel overlay statusbar cancellables */
69
70 /* Ignore if second button pressed before first released - not permitted during rubberbanding.
71
72=== modified file 'src/View/IconView.vala'
73--- src/View/IconView.vala 2017-02-04 13:48:29 +0000
74+++ src/View/IconView.vala 2017-02-15 19:03:51 +0000
75@@ -38,6 +38,8 @@
76 name_renderer = new Marlin.TextRenderer (Marlin.ViewMode.ICON);
77 set_up_name_renderer ();
78
79+ set_up_icon_renderer ();
80+
81 (tree as Gtk.CellLayout).pack_start (icon_renderer, false);
82 (tree as Gtk.CellLayout).pack_end (name_renderer, false);
83
84@@ -72,8 +74,6 @@
85 protected override Gtk.Widget? create_view () {
86 tree = new Gtk.IconView ();
87 set_up_view ();
88- set_up_name_renderer ();
89- set_up_icon_renderer ();
90
91 return tree as Gtk.Widget;
92 }
93
94=== modified file 'src/View/Widgets/AbstractEditableLabel.vala'
95--- src/View/Widgets/AbstractEditableLabel.vala 2017-01-26 16:53:06 +0000
96+++ src/View/Widgets/AbstractEditableLabel.vala 2017-02-15 19:03:51 +0000
97@@ -46,16 +46,14 @@
98 * to commit Chinese/Japanese characters when using some input methods, without ending rename.
99 */
100 if (mods == 0) {
101- editing_canceled = false;
102- remove_widget (); /* also causes edited signal to be emitted by CellRenderer */
103+ end_editing (false);
104 return true;
105 }
106
107 break;
108
109 case Gdk.Key.Escape:
110- editing_canceled = true;
111- remove_widget (); /* also causes edited signal to be emitted by CellRenderer */
112+ end_editing (true);
113 return true;
114
115 case Gdk.Key.z:
116@@ -72,6 +70,11 @@
117 return false;
118 }
119
120+ public void end_editing (bool cancelled) {
121+ editing_canceled = cancelled;
122+ remove_widget ();
123+ editing_done ();
124+ }
125
126 public virtual void set_text (string text) {
127 original_name = text;

Subscribers

People subscribed via source and target branches

to all changes: