Merge lp:~jeremywootten/pantheon-files/fix-trash-read-only-error-messages into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1590
Merged at revision: 1611
Proposed branch: lp:~jeremywootten/pantheon-files/fix-trash-read-only-error-messages
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 118 lines (+82/-12)
1 file modified
libcore/marlin-file-operations.c (+82/-12)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-trash-read-only-error-messages
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+233611@code.launchpad.net

Commit message

Change the messages displayed when the trash operation fails to better reflect the real cause (lp:1080924)

Description of the change

Change the messages displayed when the trash operation fails to better reflect the real cause.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libcore/marlin-file-operations.c'
2--- libcore/marlin-file-operations.c 2014-08-05 22:40:12 +0000
3+++ libcore/marlin-file-operations.c 2014-09-06 06:39:13 +0000
4@@ -1852,10 +1852,21 @@
5 GFile *file;
6 GList *to_delete;
7 GError *error;
8+ GFileInfo *info;
9+ GFileInfo *parent_info;
10+ GFileInfo *fsinfo;
11 int total_files, files_trashed;
12 char *primary, *secondary, *details;
13 int response;
14 guint64 mtime;
15+ gboolean can_delete;
16+ gboolean can_write;
17+ gboolean is_folder;
18+ gboolean parent_can_write;
19+ gboolean readonly_fs;
20+ gboolean have_info;
21+ gboolean have_parent_info;
22+ gboolean have_filesystem_info;
23
24 if (job_aborted (job)) {
25 return;
26@@ -1887,21 +1898,80 @@
27 goto skip;
28 }
29
30- primary = f (_("Cannot move file to trash. Delete Immediately?"));
31- secondary = f (_("This file is located on an external media and cannot be moved to the trash. Once deleted, it cannot be restored."));
32+ info = g_file_query_info (file, "access::can-write,standard::type", 0, NULL, NULL);
33+ parent_info = g_file_query_info (g_file_get_parent (file), "access::can-write", 0, NULL, NULL);
34+ fsinfo = g_file_query_filesystem_info (file, "filesystem::readonly", NULL, NULL);
35+
36+ if (info != NULL) {
37+ can_write = g_file_info_get_attribute_boolean (info, "access::can-write");
38+ is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
39+ have_info = TRUE;
40+ g_object_unref (info);
41+ } else
42+ have_info = FALSE;
43+
44+ if (parent_info != NULL) {
45+ parent_can_write = g_file_info_get_attribute_boolean (parent_info, "access::can-write");
46+ have_parent_info = TRUE;
47+ g_object_unref (parent_info);
48+ } else
49+ have_parent_info = FALSE;
50+
51+ if (fsinfo != NULL) {
52+ readonly_fs = g_file_info_get_attribute_boolean (fsinfo, "filesystem::readonly");
53+ have_filesystem_info = TRUE;
54+ g_object_unref (fsinfo);
55+ } else
56+ have_filesystem_info = FALSE;
57+
58+ if (have_info) {
59+ can_delete = FALSE;
60+ if (have_filesystem_info && readonly_fs) {
61+ primary = f (_("Cannot move file to trash or delete it"));
62+ secondary = f (_("It is not permitted to trash or delete files on a read only filesystem."));
63+ } else if (have_parent_info && !parent_can_write) {
64+ primary = f (_("Cannot move file to trash or delete it"));
65+ secondary = f (_("It is not permitted to trash or delete files inside folders for which you do not have write privileges."));
66+ } else if (is_folder && !can_write ) {
67+ primary = f (_("Cannot move file to trash or delete it"));
68+ secondary = f (_("It is not permitted to trash or delete folders for which you do not have write privileges."));
69+ } else {
70+ primary = f (_("Cannot move file to trash. Try to delete it immediately?"));
71+ secondary = f (_("This file could not be moved to trash. See details below for further information."));
72+ can_delete = TRUE;
73+ }
74+ } else {
75+ primary = f (_("Cannot move file to trash. Try to delete it?"));
76+ secondary = f (_("This file could not be moved to trash. You may not be able to delete it either."));
77+ can_delete = TRUE;
78+ }
79+
80+ if (can_delete)
81+ secondary = g_strconcat (secondary, f (_("\n Deleting a file removes it permanently")), NULL);
82+
83 details = NULL;
84- if (!IS_IO_ERROR (error, NOT_SUPPORTED)) {
85- details = error->message;
86+ details = error->message;
87+
88+ /* Note primary and secondary text is freed by run_simple_dialog_va */
89+ if (can_delete) {
90+ response = run_question (job,
91+ primary,
92+ secondary,
93+ details,
94+ (total_files - files_trashed) > 1,
95+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP, DELETE_ALL, GTK_STOCK_DELETE,
96+ NULL);
97+ } else {
98+ response = run_question (job,
99+ primary,
100+ secondary,
101+ details,
102+ (total_files - files_trashed) > 1,
103+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
104+ NULL);
105+
106 }
107
108- response = run_question (job,
109- primary,
110- secondary,
111- details,
112- (total_files - files_trashed) > 1,
113- GTK_STOCK_CANCEL, SKIP_ALL, SKIP, DELETE_ALL, GTK_STOCK_DELETE,
114- NULL);
115-
116 if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
117 ((DeleteJob *) job)->user_cancel = TRUE;
118 abort_job (job);

Subscribers

People subscribed via source and target branches

to all changes: