diff options
-rw-r--r-- | composer/ChangeLog | 7 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 39 |
2 files changed, 38 insertions, 8 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 25a11d6f62..364a4cd093 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,10 @@ +2001-07-05 Jeffrey Stedfast <fejj@ximian.com> + + * e-msg-composer.c (save): Play the "File exists, overwrite?" + game. + (autosave_run_foreach_cb): Change the return val from a gboolean + to void. + 2001-07-04 Larry Ewing <lewing@ximian.com> * e-msg-composer.c (autosave_load_draft): attach send and postpone diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 3fb82db821..df955c383e 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -858,26 +858,49 @@ save (EMsgComposer *composer, { CORBA_Environment ev; char *my_file_name; - + int fd; + if (file_name != NULL) my_file_name = g_strdup (file_name); else my_file_name = e_msg_composer_select_file (composer, _("Save as...")); - + if (my_file_name == NULL) return; - + + /* check to see if we already have the file */ + if ((fd = open (my_file_name, O_RDONLY | O_CREAT | O_EXCL)) == -1) { + GtkWidget *dialog, *label; + + dialog = gnome_dialog_new (_("Warning!"), GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, NULL); + label = gtk_label_new (_("File exists, overwrite?")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); + + switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) { + case -1: + gtk_widget_destroy (dialog); + return; + case 1: + return; + default: + /* ie, the user hit "Yes" so just continue as normal */ + } + } else + close (fd); + CORBA_exception_init (&ev); - + Bonobo_PersistFile_save (composer->persist_file_interface, my_file_name, &ev); - + if (ev._major != CORBA_NO_EXCEPTION) { e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR, _("Error saving file: %s"), g_basename (file_name)); } - + CORBA_exception_free (&ev); - + g_free (my_file_name); } @@ -1134,7 +1157,7 @@ autosave_query_load_orphans (AutosaveManager *am, EMsgComposer *composer) return matches; } -static gboolean +static void autosave_run_foreach_cb (gpointer key, gpointer value, gpointer data) { EMsgComposer *composer = E_MSG_COMPOSER (value); |