Merge lp:~evfool/pantheon-files/lp883553-properties-rename into lp:~elementary-apps/pantheon-files/trunk

Proposed by Robert Roth
Status: Merged
Approved by: Danielle Foré
Approved revision: 1665
Merged at revision: 1669
Proposed branch: lp:~evfool/pantheon-files/lp883553-properties-rename
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 76 lines (+40/-6)
1 file modified
src/View/PropertiesWindow.vala (+40/-6)
To merge this branch: bzr merge lp:~evfool/pantheon-files/lp883553-properties-rename
Reviewer Review Type Date Requested Status
PerfectCarl (community) Approve
Cody Garver (community) Approve
Danielle Foré ux Approve
elementary Apps team code Pending
Review via email: mp+243730@code.launchpad.net

Commit message

Rename file/folder from properties dialog (lp:883553)

Description of the change

Rename file/folder from properties dialog (lp:883553)

Renaming currently happens on entry focus out (properties window close) and on entry activate (enter pressed).

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

This looks good! Focus on save out is probably appropriate. That mimics the way it's done in the view.

My only small request would be if we could try to exclude extensions when it's selected, so you can start typing without worrying about that.

review: Approve (ux)
1664. By Robert Roth

Only preselect filename without extension on properties dialog

Revision history for this message
Cody Garver (codygarver) wrote :

This is the coolest!!!!

I could not find any way to break it

My only concern is perhaps a little cancel icon or something could appear so you could revert

review: Approve
Revision history for this message
Robert Roth (evfool) wrote :

Maybe the UX team could suggest a way to cancel the rename. I feel that might be unnecessary if we had undo for renaming, but as we don't have that yet, maybe a way to cancel would be ok.

Revision history for this message
PerfectCarl (name-is-carl) wrote :

Very minor remarks on the code (use var) and about improving a warning message

1665. By Robert Roth

Fixed based on code review

Revision history for this message
Robert Roth (evfool) wrote :

Minor fixes based on code review added.

Revision history for this message
PerfectCarl (name-is-carl) wrote :

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/View/PropertiesWindow.vala'
2--- src/View/PropertiesWindow.vala 2014-11-24 21:55:13 +0000
3+++ src/View/PropertiesWindow.vala 2014-12-08 22:02:18 +0000
4@@ -45,7 +45,7 @@
5
6 private Gee.Set<string>? mimes;
7
8- private Granite.Widgets.WrapLabel header_title;
9+ private Gtk.Widget header_title;
10 private Granite.Widgets.WrapLabel type_label;
11 private Gtk.Label size_label;
12 private Gtk.Widget type_key_label;
13@@ -201,6 +201,14 @@
14 content_area.show_all ();
15 show_all ();
16
17+ if (count == 1) {
18+ int start_offset= 0, end_offset = -1;
19+
20+ Marlin.get_rename_region (goffile.info.get_name (), out start_offset, out end_offset, goffile.is_folder ());
21+ (header_title as Gtk.Entry).select_region (start_offset, end_offset);
22+ }
23+
24+
25 /* Action area */
26 add_button (_("Close"), Gtk.ResponseType.CLOSE);
27 response.connect ((source, type) => {
28@@ -319,6 +327,18 @@
29 deep_count_directories = null;
30 }
31 */
32+
33+ private void rename_file (GOF.File file, string new_name) {
34+ /* Only rename if name actually changed */
35+ var original_name = file.info.get_name ();
36+ if (new_name != original_name) {
37+ file.rename (new_name, (file, result_location, error) => {
38+ if (error != null)
39+ warning ("Rename Error while renaming %s to %s: %s", original_name, new_name, error.message);
40+ });
41+ }
42+ }
43+
44 private void add_header_box (Gtk.Box vbox, Gtk.Box content) {
45 type_label = new Granite.Widgets.WrapLabel ("");
46 size_label = new Gtk.Label ("");
47@@ -377,11 +397,25 @@
48 file_img.set_valign (Gtk.Align.CENTER);
49 content.pack_start (file_img, false, false);
50
51- header_title = new Granite.Widgets.WrapLabel ();
52- if (count > 1)
53- header_title.set_markup ("<span>" + _("%u selected items").printf(count) + "</span>");
54- else
55- header_title.set_markup ("<span>" + goffile.info.get_name () + "</span>");
56+ if (count > 1 || (count == 1 && !goffile.is_writable ())) {
57+ var label = new Granite.Widgets.WrapLabel ();
58+ label.set_markup ("<span>" + _("%u selected items").printf(count) + "</span>");
59+ header_title = label;
60+ } else if (count == 1 && goffile.is_writable ()) {
61+ var entry = new Gtk.Entry ();
62+
63+ entry.set_text (goffile.info.get_name ());
64+
65+ entry.activate.connect (() => {
66+ rename_file (goffile, entry.get_text ());
67+ });
68+
69+ entry.focus_out_event.connect (() => {
70+ rename_file (goffile, entry.get_text ());
71+ return false;
72+ });
73+ header_title = entry;
74+ }
75 header_title.get_style_context ().add_class ("h2");
76 header_title.margin_top = 5;
77

Subscribers

People subscribed via source and target branches

to all changes: