diff options
author | Philip Van Hoof <pvanhoof@gnome.org> | 2005-01-03 20:39:33 +0800 |
---|---|---|
committer | Philip Van Hoof <pvanhoof@src.gnome.org> | 2005-01-03 20:39:33 +0800 |
commit | 8cfe52bd9e50155e045442a4ae80bd2e1fe060f0 (patch) | |
tree | 7c87349c5213b746d86f22852a830981df81ea5e /plugins/save-calendar/csv-format.c | |
parent | e244bd48b230087bc62364b5c7e7ffcc635a8b30 (diff) | |
download | gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.gz gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.zst gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.zip |
Warning when overwriting file
2004-12-27 Philip Van Hoof <pvanhoof@gnome.org>
* csv-format.c, rdf-format.c: Warning when overwriting file
svn path=/trunk/; revision=28213
Diffstat (limited to 'plugins/save-calendar/csv-format.c')
-rw-r--r-- | plugins/save-calendar/csv-format.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c index 661f75a216..06124f1bd9 100644 --- a/plugins/save-calendar/csv-format.c +++ b/plugins/save-calendar/csv-format.c @@ -320,6 +320,7 @@ do_save_calendar_csv (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource CsvConfig *config = NULL; CsvPluginData *d = handler->data; const gchar *tmp = NULL; + gboolean doit = TRUE; if (!dest_uri) return; @@ -346,13 +347,35 @@ do_save_calendar_csv (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource config->header = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (d->header_check)); uri = gnome_vfs_uri_new (dest_uri); - result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE); - if (result != GNOME_VFS_OK) { - gnome_vfs_create (&handle, dest_uri, GNOME_VFS_OPEN_WRITE, TRUE, GNOME_VFS_PERM_USER_ALL); + + result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_READ); + if (result == GNOME_VFS_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?"), dest_uri); + + 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) { result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE); + if (result != GNOME_VFS_OK) { + gnome_vfs_create (&handle, dest_uri, GNOME_VFS_OPEN_WRITE, TRUE, GNOME_VFS_PERM_USER_ALL); + result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE); + } } - if (result == GNOME_VFS_OK && e_cal_get_object_list_as_comp (source_client, "#t", &objects, NULL)) { + if (result == GNOME_VFS_OK && doit && e_cal_get_object_list_as_comp (source_client, "#t", &objects, NULL)) { if (config->header) { line = g_string_new (""); |