diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c index 458760d..2ec5517 100644 --- a/thunar/thunar-application.c +++ b/thunar/thunar-application.c @@ -1718,7 +1718,7 @@ thunar_application_unlink_files (ThunarApplication *application, GdkScreen *screen; GList *path_list = NULL; GList *lp; - gchar *message; + gchar *message = NULL; guint n_path_list = 0; gint response; @@ -1741,12 +1741,12 @@ thunar_application_unlink_files (ThunarApplication *application, if (G_UNLIKELY (n_path_list == 0)) return; + /* parse the parent pointer */ + screen = thunar_util_parse_parent (parent, &window); + /* ask the user to confirm if deleting permanently */ if (G_UNLIKELY (permanently)) { - /* parse the parent pointer */ - screen = thunar_util_parse_parent (parent, &window); - /* generate the question to confirm the delete operation */ if (G_LIKELY (n_path_list == 1)) { @@ -1776,9 +1776,9 @@ thunar_application_unlink_files (ThunarApplication *application, gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("If you delete a file, it is permanently lost.")); + gtk_window_set_title (GTK_WINDOW (dialog), _("Confirm File Delete")); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - g_free (message); /* perform the delete operation */ if (G_LIKELY (response == GTK_RESPONSE_YES)) @@ -1791,12 +1791,52 @@ thunar_application_unlink_files (ThunarApplication *application, } else { - /* launch the "Move to Trash" operation */ - thunar_application_trash (application, parent, path_list); + /* generate the question to confirm the trash move operation */ + if (G_LIKELY (n_path_list == 1)) + { + message = g_strdup_printf (_("Are you sure that you want to\n \"%s\" to Trash?"), + thunar_file_get_display_name (THUNAR_FILE (file_list->data))); + } + else + { + message = g_strdup_printf (ngettext ("Are you sure that you want to move\nthis file to Trash?", + "Are you sure that you want to move\nthese %u selected files to Trash?", + n_path_list), + n_path_list); + } + + /* ask the user to confirm the trash move operation */ + dialog = gtk_message_dialog_new (window, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "%s", message); + if (G_UNLIKELY (window == NULL && screen != NULL)) + gtk_window_set_screen (GTK_WINDOW (dialog), screen); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + "No", GTK_RESPONSE_NO, + "Yes", GTK_RESPONSE_YES, + NULL); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("This operation may be undone by restoring the file in the Trash Bin.")); + gtk_window_set_title (GTK_WINDOW (dialog), _("Confirm File Delete")); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + + /* perform the delete operation */ + if (G_LIKELY (response == GTK_RESPONSE_YES)) + { + /* launch the "Move to Trash" operation */ + thunar_application_trash (application, parent, path_list); + } } /* release the path list */ thunar_g_file_list_free (path_list); + + /* free any allocated messages. if not, we should safely return without any problems */ + g_free (message); }