aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-10-07 00:56:52 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-10-07 00:56:52 +0800
commitdbe2c18c4c4ed35437d7e779e02448778537585a (patch)
tree4ce174f08dabfd95e007d436936192dbc72e085c
parent1441c34f007cc19dc5d33c0f16eca59535c2aa77 (diff)
downloadgsoc2013-evolution-dbe2c18c4c4ed35437d7e779e02448778537585a.tar.gz
gsoc2013-evolution-dbe2c18c4c4ed35437d7e779e02448778537585a.tar.zst
gsoc2013-evolution-dbe2c18c4c4ed35437d7e779e02448778537585a.zip
Don't blindly claim that the file exists and then ask the user if he/she
2003-09-26 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer.c (save): Don't blindly claim that the file exists and then ask the user if he/she would like to overwrite it. First check that the file even exists, if not - then we've got a different error. Fixes bug #48759. * e-msg-composer-select-file.c (e_msg_composer_select_file): Use the proper selector title, otherwise it says "Attach files" when we are trying to save a message. svn path=/trunk/; revision=22798
-rw-r--r--composer/ChangeLog11
-rw-r--r--composer/e-msg-composer-select-file.c2
-rw-r--r--composer/e-msg-composer.c59
3 files changed, 47 insertions, 25 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 890149a843..b698c2cf57 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,14 @@
+2003-09-26 Jeffrey Stedfast <fejj@ximian.com>
+
+ * e-msg-composer.c (save): Don't blindly claim that the file
+ exists and then ask the user if he/she would like to overwrite
+ it. First check that the file even exists, if not - then we've got
+ a different error. Fixes bug #48759.
+
+ * e-msg-composer-select-file.c (e_msg_composer_select_file): Use
+ the proper selector title, otherwise it says "Attach files" when
+ we are trying to save a message.
+
2003-09-24 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment-bar.c (get_default_charset): Same as
diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c
index 0ad89c220b..3726124837 100644
--- a/composer/e-msg-composer-select-file.c
+++ b/composer/e-msg-composer-select-file.c
@@ -99,7 +99,7 @@ e_msg_composer_select_file (EMsgComposer *composer, const char *title)
GtkFileSelection *selection;
char *name = NULL;
- selection = run_selector(composer, _("Attach file(s)"), TRUE, NULL);
+ selection = run_selector (composer, title, TRUE, NULL);
if (selection) {
name = g_strdup(gtk_file_selection_get_filename(selection));
gtk_widget_destroy((GtkWidget *)selection);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index cf4a130d52..f446229889 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1179,33 +1179,45 @@ show_attachments (EMsgComposer *composer,
}
static void
-save (EMsgComposer *composer, const char *file_name)
+save (EMsgComposer *composer, const char *default_filename)
{
CORBA_Environment ev;
- char *my_file_name;
+ char *filename;
int fd;
- if (file_name != NULL)
- my_file_name = g_strdup (file_name);
+ if (default_filename != NULL)
+ filename = g_strdup (default_filename);
else
- my_file_name = e_msg_composer_select_file (composer, _("Save as..."));
+ filename = e_msg_composer_select_file (composer, _("Save as..."));
- if (my_file_name == NULL)
+ if (filename == NULL)
return;
- /* check to see if we already have the file */
- if ((fd = open (my_file_name, O_RDONLY | O_CREAT | O_EXCL, 0777)) == -1) {
+ /* check to see if we already have the file and that we can create it */
+ if ((fd = open (filename, O_RDONLY | O_CREAT | O_EXCL, 0777)) == -1) {
+ int resp, errnosav = errno;
GtkWidget *dialog;
- int resp;
-
- dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
- GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
- _("File exists, overwrite?"));
- resp = gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- if (resp != GTK_RESPONSE_YES) {
- g_free(my_file_name);
+ struct stat st;
+
+ if (stat (filename, &st) == 0 && S_ISREG (st.st_mode)) {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (composer),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+ _("File exists, overwrite?"));
+ resp = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ if (resp != GTK_RESPONSE_YES) {
+ g_free (filename);
+ return;
+ }
+ } else {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (composer),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ _("Error saving file: %s"), g_strerror (errnosav));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (filename);
return;
}
} else
@@ -1213,20 +1225,19 @@ save (EMsgComposer *composer, const char *file_name)
CORBA_exception_init (&ev);
- Bonobo_PersistFile_save (composer->persist_file_interface, my_file_name, &ev);
+ Bonobo_PersistFile_save (composer->persist_file_interface, filename, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- char *tmp = g_path_get_basename(my_file_name);
-
- e_notice (composer, GTK_MESSAGE_ERROR,
- _("Error saving file: %s"), tmp);
+ char *tmp = g_path_get_basename (filename);
+
+ e_notice (composer, GTK_MESSAGE_ERROR, _("Error saving file: %s"), tmp);
g_free(tmp);
} else
GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev);
CORBA_exception_free (&ev);
- g_free (my_file_name);
+ g_free (filename);
}
static void