summaryrefslogtreecommitdiff
path: root/src/nautilus-file-conflict-dialog.c
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-02-08 19:53:51 +0000
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2021-02-12 16:29:57 +0000
commit9108b4028b7f476b598bc664079fd6d115801b66 (patch)
treebe3e8b8677cc594e836598028f5da53a0c622892 /src/nautilus-file-conflict-dialog.c
parent867e60521b039589bb1c017763f27c0497e09776 (diff)
downloadnautilus-9108b4028b7f476b598bc664079fd6d115801b66.tar.gz
file-conflict-dialog: Make manual rename more convenient
The suggested name is in the form "original (1).txt", if the the conflicting name was "original.txt". The user may want to replace the "(1)" bits with something more meaningful, so select this region for convenience.
Diffstat (limited to 'src/nautilus-file-conflict-dialog.c')
-rw-r--r--src/nautilus-file-conflict-dialog.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/nautilus-file-conflict-dialog.c b/src/nautilus-file-conflict-dialog.c
index f51a5edbb..2bbe37fef 100644
--- a/src/nautilus-file-conflict-dialog.c
+++ b/src/nautilus-file-conflict-dialog.c
@@ -196,8 +196,6 @@ on_expanded_notify (GtkExpander *w,
GParamSpec *pspec,
NautilusFileConflictDialog *dialog)
{
- int start_pos, end_pos;
-
if (gtk_expander_get_expanded (w))
{
gtk_widget_hide (dialog->replace_button);
@@ -206,11 +204,24 @@ on_expanded_notify (GtkExpander *w,
gtk_widget_set_sensitive (dialog->checkbox, FALSE);
- if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), dialog->conflict_name) == 0)
+ gtk_widget_grab_focus (dialog->entry);
+ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), dialog->suggested_name) == 0)
{
- gtk_widget_grab_focus (dialog->entry);
+ /* The suggested name is in the form "original (1).txt", if the
+ * the conflicting name was "original.txt". The user may want to
+ * replace the "(1)" bits with with something more meaningful, so
+ * select this region for convenience. */
+
+ const gchar *offset;
+ int start_pos;
+ int end_pos;
+
+ offset = eel_filename_get_extension_offset (dialog->conflict_name);
+ start_pos = g_utf8_pointer_to_offset (dialog->conflict_name, offset);
+
+ offset = eel_filename_get_extension_offset (dialog->suggested_name);
+ end_pos = g_utf8_pointer_to_offset (dialog->suggested_name, offset);
- eel_filename_get_rename_region (dialog->conflict_name, &start_pos, &end_pos);
gtk_editable_select_region (GTK_EDITABLE (dialog->entry), start_pos, end_pos);
}
}