diff options
-rw-r--r-- | plugins/save-attachments/ChangeLog | 4 | ||||
-rw-r--r-- | plugins/save-attachments/save-attachments.c | 27 |
2 files changed, 30 insertions, 1 deletions
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 <pvanhoof@gnome.org> + + * save-attachments.c: Warning when overwriting file + 2004-11-01 JP Rosevear <jpr@novell.com> * 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 <gtk/gtkcheckbutton.h> #include <gtk/gtkdialog.h> +#include <gtk/gtkmessagedialog.h> #include <gtk/gtktreestore.h> #include <gtk/gtkcellrenderertext.h> #include <gtk/gtkcellrenderertoggle.h> @@ -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); |