diff options
Diffstat (limited to 'plugins/save-calendar')
-rw-r--r-- | plugins/save-calendar/ChangeLog | 4 | ||||
-rw-r--r-- | plugins/save-calendar/csv-format.c | 31 | ||||
-rw-r--r-- | plugins/save-calendar/rdf-format.c | 32 | ||||
-rw-r--r-- | plugins/save-calendar/save-calendar.c | 3 |
4 files changed, 60 insertions, 10 deletions
diff --git a/plugins/save-calendar/ChangeLog b/plugins/save-calendar/ChangeLog index 38d3a99df6..a8ee1d64a4 100644 --- a/plugins/save-calendar/ChangeLog +++ b/plugins/save-calendar/ChangeLog @@ -1,3 +1,7 @@ +2004-12-27 Philip Van Hoof <pvanhoof@gnome.org> + + * csv-format.c, rdf-format.c: Warning when overwriting file + 2004-12-22 JP Rosevear <jpr@novell.com> * Makefile.am: list format-handler.h as a source so it dists 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 (""); diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c index efa038a1f2..bcacd1f373 100644 --- a/plugins/save-calendar/rdf-format.c +++ b/plugins/save-calendar/rdf-format.c @@ -195,6 +195,7 @@ do_save_calendar_rdf (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource GnomeVFSHandle *handle; GnomeVFSURI *uri; gchar *temp = NULL; + gboolean doit = TRUE; if (!dest_uri) return; @@ -211,13 +212,36 @@ do_save_calendar_rdf (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource } 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, + _("<b>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)) { xmlBufferPtr buffer=xmlBufferCreate(); xmlDocPtr doc = xmlNewDoc((xmlChar *) "1.0"); xmlNodePtr fnode = doc->children; diff --git a/plugins/save-calendar/save-calendar.c b/plugins/save-calendar/save-calendar.c index d55a7d876f..23dc40065c 100644 --- a/plugins/save-calendar/save-calendar.c +++ b/plugins/save-calendar/save-calendar.c @@ -225,8 +225,7 @@ ask_destination_and_save (EPlugin *ep, ECalPopupTargetSource *target, ECalSource } - if (proceed) - { + if (proceed) { handler->save (handler, ep, target, type, dest_uri); /* Free the handlers */ g_list_foreach (format_handlers, format_handlers_foreach_free, NULL); |