[nautilus/wip/antoniof/try-admin-backend-for-file-ops: 2/11] file-undo-operations: Set NULL dest for duplication
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/try-admin-backend-for-file-ops: 2/11] file-undo-operations: Set NULL dest for duplication
- Date: Sat, 16 Oct 2021 14:02:29 +0000 (UTC)
commit dc6b9783ef898640499147a68ddec90297aacac0
Author: António Fernandes <antoniof gnome org>
Date: Fri Oct 15 23:38:39 2021 +0100
file-undo-operations: Set NULL dest for duplication
In src/nautilus-file-operations.c, the duplication operation is
identified within the 'copy' code paths by having a NULL destination
imply it's the same as the source parent dir.
For consistency, adopt the same paradigm in the undo stack.
Also, while we are at it, adopt autocleanup for some related strings.
src/nautilus-file-operations.c | 2 +-
src/nautilus-file-undo-operations.c | 30 +++++++++++++++++++++---------
2 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index d37938be4..18c51504b 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -7133,7 +7133,7 @@ nautilus_file_operations_duplicate (GList *files,
job->common.undo_info =
nautilus_file_undo_info_ext_new (NAUTILUS_FILE_UNDO_OP_DUPLICATE,
g_list_length (files),
- src_dir, src_dir);
+ src_dir, NULL);
}
task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);
diff --git a/src/nautilus-file-undo-operations.c b/src/nautilus-file-undo-operations.c
index 64f9ce76c..70123dace 100644
--- a/src/nautilus-file-undo-operations.c
+++ b/src/nautilus-file-undo-operations.c
@@ -435,10 +435,20 @@ ext_strings_func (NautilusFileUndoInfo *info,
NautilusFileUndoInfoExt *self = NAUTILUS_FILE_UNDO_INFO_EXT (info);
NautilusFileUndoOp op_type = nautilus_file_undo_info_get_op_type (info);
gint count = nautilus_file_undo_info_get_item_count (info);
- gchar *name = NULL, *source, *destination;
+ g_autofree gchar *name = NULL;
+ g_autofree gchar *source = NULL;
+ g_autofree gchar *destination = NULL;
source = g_file_get_path (self->src_dir);
- destination = g_file_get_path (self->dest_dir);
+
+ if (self->dest_dir == NULL)
+ {
+ g_assert (op_type == NAUTILUS_FILE_UNDO_OP_DUPLICATE);
+ }
+ else
+ {
+ destination = g_file_get_path (self->dest_dir);
+ }
if (count <= 1)
{
@@ -528,7 +538,7 @@ ext_strings_func (NautilusFileUndoInfo *info,
count);
*redo_description = g_strdup_printf (ngettext ("Duplicate %d item in “%s”",
"Duplicate %d items in “%s”", count),
- count, destination);
+ count, source);
*undo_label = g_strdup_printf (ngettext ("_Undo Duplicate %d item",
"_Undo Duplicate %d items", count),
@@ -541,7 +551,7 @@ ext_strings_func (NautilusFileUndoInfo *info,
{
*undo_description = g_strdup_printf (_("Delete “%s”"), name);
*redo_description = g_strdup_printf (_("Duplicate “%s” in “%s”"),
- name, destination);
+ name, source);
*undo_label = g_strdup (_("_Undo Duplicate"));
*redo_label = g_strdup (_("_Redo Duplicate"));
@@ -571,10 +581,6 @@ ext_strings_func (NautilusFileUndoInfo *info,
{
g_assert_not_reached ();
}
-
- g_free (name);
- g_free (source);
- g_free (destination);
}
static void
@@ -777,13 +783,19 @@ nautilus_file_undo_info_ext_new (NautilusFileUndoOp op_type,
{
NautilusFileUndoInfoExt *self;
+ g_assert (src_dir != NULL);
+ g_assert (target_dir != NULL || op_type == NAUTILUS_FILE_UNDO_OP_DUPLICATE);
+
self = g_object_new (NAUTILUS_TYPE_FILE_UNDO_INFO_EXT,
"op-type", op_type,
"item-count", item_count,
NULL);
self->src_dir = g_object_ref (src_dir);
- self->dest_dir = g_object_ref (target_dir);
+ if (target_dir != NULL)
+ {
+ self->dest_dir = g_object_ref (target_dir);
+ }
self->sources = g_queue_new ();
self->destinations = g_queue_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]