diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c index 210aaa5b153251b5de0450fa580748ed6c745c54..d484094b133b6277c0c4db94c0cfbe10b412092b 100644 --- a/thunar/thunar-application.c +++ b/thunar/thunar-application.c @@ -2352,8 +2352,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, @@ -2369,9 +2371,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) @@ -2387,7 +2390,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) @@ -2437,6 +2440,8 @@ thunar_application_unlink_files (ThunarApplication *application, _("Deleting files..."), unlink_stub, path_list, path_list, TRUE, FALSE, log_mode, NULL); } + else + operation_canceled = TRUE; } else if (G_UNLIKELY (permanently)) { @@ -2482,6 +2487,8 @@ thunar_application_unlink_files (ThunarApplication *application, if (G_LIKELY (response == GTK_RESPONSE_YES)) thunar_application_trash (application, parent, path_list, log_mode); + else + operation_canceled = TRUE; } else { @@ -2491,6 +2498,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 3247c82fd9b4c1af36eec106a20ec4c351051372..019389eb444943eedbadfcd81198d4825a7ebf47 100644 --- a/thunar/thunar-application.h +++ b/thunar/thunar-application.h @@ -139,7 +139,7 @@ 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, diff --git a/thunar/thunar-job-operation.c b/thunar/thunar-job-operation.c index 6861bd16963e55f62ac05e73ac1ed2560d2a573e..978e476a74da09616f2bd5ea7c004c36f9c3f2a6 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, THUNAR_OPERATION_LOG_OPERATIONS); + if (thunar_file_list == NULL) + { + execute_failed = TRUE; + } + else + { + execute_failed = thunar_application_unlink_files (application, NULL, thunar_file_list, TRUE, TRUE, THUNAR_OPERATION_LOG_OPERATIONS); + 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: