[nautilus/1344-be-a-little-more-helpful-with-renaming-duplicate-files: 3/4] file-conflict-dialog: Automatically suggest new name
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/1344-be-a-little-more-helpful-with-renaming-duplicate-files: 3/4] file-conflict-dialog: Automatically suggest new name
- Date: Wed, 10 Feb 2021 12:04:47 +0000 (UTC)
commit a509909412841af251000fcf793e9001988d558e
Author: António Fernandes <antoniof gnome org>
Date: Thu Jan 30 01:00:26 2020 +0000
file-conflict-dialog: Automatically suggest new name
When "Select new name for the destination" expander is selected, the
users must type a new name in order to proceed.
This makes them go and look at the destination to see what would even
make a unique name.
Let's be more helpful and suggest a unique name based on the original.
Closes https://gitlab.gnome.org/GNOME/nautilus/issues/1344
src/nautilus-file-conflict-dialog.c | 10 +++++++++-
src/nautilus-file-conflict-dialog.h | 4 +++-
src/nautilus-file-operations.c | 10 +++++++++-
src/nautilus-operations-ui-manager.c | 19 +++++++++++++------
src/nautilus-operations-ui-manager.h | 5 +++--
5 files changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-file-conflict-dialog.c b/src/nautilus-file-conflict-dialog.c
index 8adb4bb14..c48bd7bfb 100644
--- a/src/nautilus-file-conflict-dialog.c
+++ b/src/nautilus-file-conflict-dialog.c
@@ -38,6 +38,7 @@ struct _NautilusFileConflictDialog
GtkDialog parent_instance;
gchar *conflict_name;
+ gchar *suggested_name;
/* UI objects */
GtkWidget *titles_vbox;
@@ -135,8 +136,14 @@ nautilus_file_conflict_dialog_set_conflict_name (NautilusFileConflictDialog *fcd
gchar *conflict_name)
{
fcd->conflict_name = g_strdup (conflict_name);
+}
- gtk_entry_set_text (GTK_ENTRY (fcd->entry), fcd->conflict_name);
+void
+nautilus_file_conflict_dialog_set_suggested_name (NautilusFileConflictDialog *fcd,
+ gchar *suggested_name)
+{
+ fcd->suggested_name = g_strdup (suggested_name);
+ gtk_entry_set_text (GTK_ENTRY (fcd->entry), suggested_name);
}
void
@@ -352,6 +359,7 @@ do_finalize (GObject *self)
NautilusFileConflictDialog *dialog = NAUTILUS_FILE_CONFLICT_DIALOG (self);
g_free (dialog->conflict_name);
+ g_free (dialog->suggested_name);
G_OBJECT_CLASS (nautilus_file_conflict_dialog_parent_class)->finalize (self);
}
diff --git a/src/nautilus-file-conflict-dialog.h b/src/nautilus-file-conflict-dialog.h
index e54071b02..e7d34f6fd 100644
--- a/src/nautilus-file-conflict-dialog.h
+++ b/src/nautilus-file-conflict-dialog.h
@@ -45,6 +45,8 @@ void nautilus_file_conflict_dialog_set_file_labels (NautilusFileConflictDialog *
gchar *source_label);
void nautilus_file_conflict_dialog_set_conflict_name (NautilusFileConflictDialog *fcd,
gchar *conflict_name);
+void nautilus_file_conflict_dialog_set_suggested_name (NautilusFileConflictDialog *fcd,
+ gchar *suggested_name);
void nautilus_file_conflict_dialog_set_replace_button_label (NautilusFileConflictDialog *fcd,
gchar *label);
@@ -55,4 +57,4 @@ void nautilus_file_conflict_dialog_disable_apply_to_all (NautilusFileConflictDia
char* nautilus_file_conflict_dialog_get_new_name (NautilusFileConflictDialog *dialog);
gboolean nautilus_file_conflict_dialog_get_apply_to_all (NautilusFileConflictDialog *dialog);
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 3adf3b54c..5558786c1 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -5136,14 +5136,22 @@ handle_copy_move_conflict (CommonJob *job,
GFile *dest_dir)
{
FileConflictResponse *response;
+ g_autofree gchar *basename = NULL;
+ g_autoptr (GFile) suggested_file = NULL;
+ g_autofree gchar *suggestion = NULL;
g_timer_stop (job->time);
nautilus_progress_info_pause (job->progress);
+ basename = g_file_get_basename (dest);
+ suggested_file = nautilus_generate_unique_file_in_directory (dest_dir, basename);
+ suggestion = g_file_get_basename (suggested_file);
+
response = copy_move_conflict_ask_user_action (job->parent_window,
src,
dest,
- dest_dir);
+ dest_dir,
+ suggestion);
nautilus_progress_info_resume (job->progress);
g_timer_continue (job->time);
diff --git a/src/nautilus-operations-ui-manager.c b/src/nautilus-operations-ui-manager.c
index 790592f5a..170ee7f5a 100644
--- a/src/nautilus-operations-ui-manager.c
+++ b/src/nautilus-operations-ui-manager.c
@@ -88,6 +88,8 @@ typedef struct
GFile *destination_name;
GFile *destination_directory_name;
+ gchar *suggestion;
+
GtkWindow *parent;
FileConflictResponse *response;
@@ -328,14 +330,17 @@ set_file_labels (FileConflictDialogData *data)
}
static void
-set_conflict_name (FileConflictDialogData *data)
+set_conflict_and_suggested_names (FileConflictDialogData *data)
{
- g_autofree gchar *edit_name = NULL;
+ g_autofree gchar *conflict_name = NULL;
- edit_name = nautilus_file_get_edit_name (data->destination);
+ conflict_name = nautilus_file_get_edit_name (data->destination);
nautilus_file_conflict_dialog_set_conflict_name (data->dialog,
- edit_name);
+ conflict_name);
+
+ nautilus_file_conflict_dialog_set_suggested_name (data->dialog,
+ data->suggestion);
}
static void
@@ -399,7 +404,7 @@ copy_move_conflict_on_file_list_ready (GList *files,
set_file_labels (data);
- set_conflict_name (data);
+ set_conflict_and_suggested_names (data);
set_replace_button_label (data);
@@ -482,7 +487,8 @@ FileConflictResponse *
copy_move_conflict_ask_user_action (GtkWindow *parent_window,
GFile *source_name,
GFile *destination_name,
- GFile *destination_directory_name)
+ GFile *destination_directory_name,
+ gchar *suggestion)
{
FileConflictDialogData *data;
FileConflictResponse *response;
@@ -492,6 +498,7 @@ copy_move_conflict_ask_user_action (GtkWindow *parent_window,
data->source_name = source_name;
data->destination_name = destination_name;
data->destination_directory_name = destination_directory_name;
+ data->suggestion = suggestion;
data->response = g_slice_new0 (FileConflictResponse);
data->response->new_name = NULL;
diff --git a/src/nautilus-operations-ui-manager.h b/src/nautilus-operations-ui-manager.h
index 032ffb5bd..4321c824f 100644
--- a/src/nautilus-operations-ui-manager.h
+++ b/src/nautilus-operations-ui-manager.h
@@ -14,7 +14,8 @@ void file_conflict_response_free (FileConflictResponse *data);
FileConflictResponse * copy_move_conflict_ask_user_action (GtkWindow *parent_window,
GFile *src,
GFile *dest,
- GFile *dest_dir);
+ GFile *dest_dir,
+ gchar *suggestion);
enum
{
@@ -24,4 +25,4 @@ enum
};
void handle_unsupported_compressed_file (GtkWindow *parent_window,
- GFile *compressed_file);
\ No newline at end of file
+ GFile *compressed_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]