From e244bd48b230087bc62364b5c7e7ffcc635a8b30 Mon Sep 17 00:00:00 2001 From: Philip Van Hoof Date: Mon, 3 Jan 2005 12:37:03 +0000 Subject: Warning when overwriting file 2004-12-27 Philip Van Hoof * save-attachments.c: Warning when overwriting file svn path=/trunk/; revision=28212 --- plugins/save-attachments/ChangeLog | 4 ++++ plugins/save-attachments/save-attachments.c | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/save-attachments/ChangeLog b/plugins/save-attachments/ChangeLog index df63f244e5..0ecc0d99cf 100644 --- a/plugins/save-attachments/ChangeLog +++ b/plugins/save-attachments/ChangeLog @@ -1,3 +1,7 @@ +2004-12-27 Philip Van Hoof + + * save-attachments.c: Warning when overwriting file + 2004-11-01 JP Rosevear * Makefile.am: dist xml menu file diff --git a/plugins/save-attachments/save-attachments.c b/plugins/save-attachments/save-attachments.c index bcf77df1d8..1a903037da 100644 --- a/plugins/save-attachments/save-attachments.c +++ b/plugins/save-attachments/save-attachments.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -212,7 +213,31 @@ save_part(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, void *d) /* FIXME: if part == data->msg then we need to save this * differently, not using the envelope MimePart */ - em_utils_save_part_to_file(NULL, save, part); + /* + * The underlying em_utils_save_part_to_file ain't using gnome-vfs. Therefor + * the POSIX access-call should suffice for checking the file existence. + */ + + if (access (save, F_OK)) { + GtkWidget *warning = + gtk_message_dialog_new_with_markup (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_NONE, + _("File exists \"%s\".\n" + "Do you wish to overwrite it?"), save); + + gtk_dialog_add_button (GTK_DIALOG (warning), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_dialog_add_button (GTK_DIALOG (warning), _("_Overwrite"), GTK_RESPONSE_YES); + + doit = FALSE; + if (gtk_dialog_run (GTK_DIALOG (warning)) == GTK_RESPONSE_YES) + doit = TRUE; + gtk_widget_destroy (warning); + } + + if (doit) + em_utils_save_part_to_file(NULL, save, part); g_free(ext); g_free(filename); -- cgit v1.2.3