summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Pöschel <[email protected]>2024-02-03 22:43:45 +0100
committerraveit65 <[email protected]>2024-02-21 12:52:41 +0100
commitd90c625350c52b2ca10b6edda50c977075ad5fc6 (patch)
treeeda758ebde4deb070c8b1ff209d2205cc6d64430
parent27fdb849de02f551eab46eb78f48065da9d1d1ec (diff)
downloadcaja-d90c625350c52b2ca10b6edda50c977075ad5fc6.tar.bz2
caja-d90c625350c52b2ca10b6edda50c977075ad5fc6.tar.xz
caja-file-operations: fix caption/button in destination error dialogue
For certain operations, the destination is checked. If an error occurs, the user is asked how to proceed using a dialogue. So far this dialogue was hard-coded to only consider the copy operation. This fix also considers the other affected operations and generalizes the continue button text.
-rw-r--r--libcaja-private/caja-file-operations.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c
index 8676800e..edc595b1 100644
--- a/libcaja-private/caja-file-operations.c
+++ b/libcaja-private/caja-file-operations.c
@@ -152,6 +152,8 @@ typedef struct {
} SetPermissionsJob;
typedef enum {
+ OP_KIND_CREATE,
+ OP_KIND_LINK,
OP_KIND_COPY,
OP_KIND_MOVE,
OP_KIND_DELETE,
@@ -188,7 +190,7 @@ typedef struct {
#define DELETE_ALL _("Delete _All")
#define REPLACE_ALL _("Replace _All")
#define MERGE_ALL _("Merge _All")
-#define COPY_FORCE _("Copy _Anyway")
+#define CONTINUE_FORCE _("Continue _Anyway")
NotifyNotification *unmount_notify;
@@ -2522,6 +2524,10 @@ report_count_progress (CommonJob *job,
switch (source_info->op) {
default:
+ // OP_KIND_CREATE and OP_KIND_LINK don't have a source
+ g_assert_not_reached ();
+ s = f ("");
+ break;
case OP_KIND_COPY:
s = f (ngettext("Preparing to copy %'d file (%S)",
"Preparing to copy %'d files (%S)",
@@ -2571,6 +2577,9 @@ get_scan_primary (OpKind kind)
{
switch (kind) {
default:
+ // OP_KIND_CREATE and OP_KIND_LINK don't have a source
+ g_assert_not_reached ();
+ return f ("");
case OP_KIND_COPY:
return f (_("Error while copying."));
case OP_KIND_MOVE:
@@ -2820,8 +2829,29 @@ scan_sources (GList *files,
report_count_progress (job, source_info);
}
+static char *
+get_verify_primary (OpKind kind,
+ GFile *dest)
+{
+ switch (kind) {
+ default:
+ // OP_KIND_DELETE and OP_KIND_TRASH don't have a destination
+ g_assert_not_reached ();
+ return f ("");
+ case OP_KIND_CREATE:
+ return f (_("Error while creating file/directory in \"%B\"."), dest);
+ case OP_KIND_LINK:
+ return f (_("Error while creating link in \"%B\"."), dest);
+ case OP_KIND_COPY:
+ return f (_("Error while copying to \"%B\"."), dest);
+ case OP_KIND_MOVE:
+ return f (_("Error while moving to \"%B\"."), dest);
+ }
+}
+
static void
verify_destination (CommonJob *job,
+ OpKind kind,
GFile *dest,
char **dest_fs_id,
goffset required_size)
@@ -2853,7 +2883,7 @@ verify_destination (CommonJob *job,
return;
}
- primary = f (_("Error while copying to \"%B\"."), dest);
+ primary = get_verify_primary (kind, dest);
details = NULL;
if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
@@ -2895,7 +2925,7 @@ verify_destination (CommonJob *job,
g_object_unref (info);
if (file_type != G_FILE_TYPE_DIRECTORY) {
- primary = f (_("Error while copying to \"%B\"."), dest);
+ primary = get_verify_primary (kind, dest);
secondary = f (_("The destination is not a folder."));
response = run_error (job,
@@ -2928,7 +2958,7 @@ verify_destination (CommonJob *job,
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
if (free_size < (guint64) required_size) {
- primary = f (_("Error while copying to \"%B\"."), dest);
+ primary = get_verify_primary (kind, dest);
secondary = f(_("There is not enough space on the destination. Try to remove files to make space."));
details = f (_("There is %" G_GUINT64_FORMAT " available, but %" G_GOFFSET_FORMAT " is required."), free_size, required_size);
@@ -2939,7 +2969,7 @@ verify_destination (CommonJob *job,
details,
FALSE,
CANCEL,
- COPY_FORCE,
+ CONTINUE_FORCE,
RETRY,
NULL);
@@ -2948,7 +2978,7 @@ verify_destination (CommonJob *job,
} else if (response == 2) {
goto retry;
} else if (response == 1) {
- /* We are forced to copy - just fall through ... */
+ /* We are forced to continue - just fall through ... */
} else {
g_assert_not_reached ();
}
@@ -2958,7 +2988,7 @@ verify_destination (CommonJob *job,
if (!job_aborted (job) &&
g_file_info_get_attribute_boolean (fsinfo,
G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)) {
- primary = f (_("Error while copying to \"%B\"."), dest);
+ primary = get_verify_primary (kind, dest);
secondary = f (_("The destination is read-only."));
response = run_error (job,
@@ -4668,6 +4698,7 @@ copy_job (GIOSchedulerJob *io_job,
}
verify_destination (&job->common,
+ OP_KIND_COPY,
dest,
&dest_fs_id,
source_info.num_bytes);
@@ -5196,6 +5227,7 @@ move_job (GIOSchedulerJob *io_job,
caja_progress_info_start (job->common.progress);
verify_destination (&job->common,
+ OP_KIND_MOVE,
job->destination,
&dest_fs_id,
-1);
@@ -5225,6 +5257,7 @@ move_job (GIOSchedulerJob *io_job,
}
verify_destination (&job->common,
+ OP_KIND_MOVE,
job->destination,
NULL,
source_info.num_bytes);
@@ -5526,6 +5559,7 @@ link_job (GIOSchedulerJob *io_job,
caja_progress_info_start (job->common.progress);
verify_destination (&job->common,
+ OP_KIND_LINK,
job->destination,
NULL,
-1);
@@ -6009,6 +6043,7 @@ create_job (GIOSchedulerJob *io_job,
max_length = get_max_name_length (job->dest_dir);
verify_destination (common,
+ OP_KIND_CREATE,
job->dest_dir,
NULL, -1);
if (job_aborted (common)) {