aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPhilip Van Hoof <pvanhoof@gnome.org>2005-01-03 20:39:33 +0800
committerPhilip Van Hoof <pvanhoof@src.gnome.org>2005-01-03 20:39:33 +0800
commit8cfe52bd9e50155e045442a4ae80bd2e1fe060f0 (patch)
tree7c87349c5213b746d86f22852a830981df81ea5e /plugins
parente244bd48b230087bc62364b5c7e7ffcc635a8b30 (diff)
downloadgsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar
gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.gz
gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.bz2
gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.lz
gsoc2013-evolution-8cfe52bd9e50155e045442a4ae80bd2e1fe060f0.tar.xz
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')
-rw-r--r--plugins/save-calendar/ChangeLog4
-rw-r--r--plugins/save-calendar/csv-format.c31
-rw-r--r--plugins/save-calendar/rdf-format.c32
-rw-r--r--plugins/save-calendar/save-calendar.c3
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);