diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c index 2f07b4627b7e11dbf2aaa3a39b27c48b135bc507..a907ef9b6bcf160c8d3c924ef02d5089bae1594f 100644 --- a/thunar/thunar-application.c +++ b/thunar/thunar-application.c @@ -2351,8 +2351,10 @@ unlink_stub (GList *source_path_list, * If the user pressed the shift key while triggering the delete action, * the files will be deleted permanently (after confirming the action), * otherwise the files will be moved to the trash. + * + * Return value: TRUE if the trash/delete operation was canceled, FALSE otehrwise **/ -void +gboolean thunar_application_unlink_files (ThunarApplication *application, gpointer parent, GList *file_list, @@ -2367,9 +2369,10 @@ thunar_application_unlink_files (ThunarApplication *application, gchar *message; guint n_path_list = 0; gint response; + gboolean operation_canceled = FALSE; - _thunar_return_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent)); - _thunar_return_if_fail (THUNAR_IS_APPLICATION (application)); + _thunar_return_val_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent), TRUE); + _thunar_return_val_if_fail (THUNAR_IS_APPLICATION (application), TRUE); /* determine the paths for the files */ for (lp = g_list_last (file_list); lp != NULL; lp = lp->prev, ++n_path_list) @@ -2385,7 +2388,7 @@ thunar_application_unlink_files (ThunarApplication *application, /* nothing to do if we don't have any paths */ if (G_UNLIKELY (n_path_list == 0)) - return; + return FALSE; /* ask the user to confirm if deleting permanently */ if (G_UNLIKELY (permanently) && warn) @@ -2435,6 +2438,8 @@ thunar_application_unlink_files (ThunarApplication *application, _("Deleting files..."), unlink_stub, path_list, path_list, TRUE, FALSE, THUNAR_OPERATION_LOG_OPERATIONS, NULL); } + else + operation_canceled = TRUE; } else if (G_UNLIKELY (permanently)) { @@ -2450,6 +2455,8 @@ thunar_application_unlink_files (ThunarApplication *application, /* release the path list */ thunar_g_list_free_full (path_list); + + return operation_canceled; } diff --git a/thunar/thunar-application.h b/thunar/thunar-application.h index a339af2e15bbeeb7ef5912fb021ee230bf3b48d8..febdce8a44c995b4e5bf94132ae7d84405d880e7 100644 --- a/thunar/thunar-application.h +++ b/thunar/thunar-application.h @@ -139,12 +139,13 @@ void thunar_application_move_files (ThunarApplic ThunarOperationLogMode log_mode, GClosure *new_files_closure); -void thunar_application_unlink_files (ThunarApplication *application, +gboolean thunar_application_unlink_files (ThunarApplication *application, gpointer parent, GList *file_list, gboolean permanently, gboolean warn); + void thunar_application_trash (ThunarApplication *application, gpointer parent, GList *file_list, diff --git a/thunar/thunar-job-operation.c b/thunar/thunar-job-operation.c index 4185e2c84f2e51c6fa765e204cc515e49652284e..6d83dc17e3c5a8d98735ff601af7530e92297262 100644 --- a/thunar/thunar-job-operation.c +++ b/thunar/thunar-job-operation.c @@ -391,6 +391,7 @@ thunar_job_operation_execute (ThunarJobOperation *job_operation, GFile *parent_dir; gchar *display_name; GFile *template_file; + gboolean execute_failed = FALSE; _thunar_return_if_fail (THUNAR_IS_JOB_OPERATION (job_operation)); @@ -425,9 +426,22 @@ thunar_job_operation_execute (ThunarJobOperation *job_operation, thunar_file_list = g_list_append (thunar_file_list, thunar_file); } - thunar_application_unlink_files (application, NULL, thunar_file_list, TRUE, TRUE); + if (thunar_file_list == NULL) + { + execute_failed = TRUE; + } + else + { + execute_failed = thunar_application_unlink_files (application, NULL, thunar_file_list, TRUE, TRUE); + g_list_free_full (thunar_file_list, g_object_unref); + } - thunar_g_list_free_full (thunar_file_list); + if (execute_failed) + { + *error = g_error_new (G_FILE_ERROR, + G_FILE_ERROR_AGAIN, + "Failed to execute operation"); + } break; case THUNAR_JOB_OPERATION_KIND_MOVE: