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
This commit is contained in:

committed by
Jeffrey Stedfast

parent
1441c34f00
commit
dbe2c18c4c
@ -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>
|
2003-09-24 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
* e-msg-composer-attachment-bar.c (get_default_charset): Same as
|
* e-msg-composer-attachment-bar.c (get_default_charset): Same as
|
||||||
|
@ -99,7 +99,7 @@ e_msg_composer_select_file (EMsgComposer *composer, const char *title)
|
|||||||
GtkFileSelection *selection;
|
GtkFileSelection *selection;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
selection = run_selector(composer, _("Attach file(s)"), TRUE, NULL);
|
selection = run_selector (composer, title, TRUE, NULL);
|
||||||
if (selection) {
|
if (selection) {
|
||||||
name = g_strdup(gtk_file_selection_get_filename(selection));
|
name = g_strdup(gtk_file_selection_get_filename(selection));
|
||||||
gtk_widget_destroy((GtkWidget *)selection);
|
gtk_widget_destroy((GtkWidget *)selection);
|
||||||
|
@ -1179,33 +1179,45 @@ show_attachments (EMsgComposer *composer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save (EMsgComposer *composer, const char *file_name)
|
save (EMsgComposer *composer, const char *default_filename)
|
||||||
{
|
{
|
||||||
CORBA_Environment ev;
|
CORBA_Environment ev;
|
||||||
char *my_file_name;
|
char *filename;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (file_name != NULL)
|
if (default_filename != NULL)
|
||||||
my_file_name = g_strdup (file_name);
|
filename = g_strdup (default_filename);
|
||||||
else
|
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;
|
return;
|
||||||
|
|
||||||
/* check to see if we already have the file */
|
/* check to see if we already have the file and that we can create it */
|
||||||
if ((fd = open (my_file_name, O_RDONLY | O_CREAT | O_EXCL, 0777)) == -1) {
|
if ((fd = open (filename, O_RDONLY | O_CREAT | O_EXCL, 0777)) == -1) {
|
||||||
|
int resp, errnosav = errno;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
int resp;
|
struct stat st;
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
|
if (stat (filename, &st) == 0 && S_ISREG (st.st_mode)) {
|
||||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
dialog = gtk_message_dialog_new (GTK_WINDOW (composer),
|
||||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
_("File exists, overwrite?"));
|
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
|
||||||
resp = gtk_dialog_run(GTK_DIALOG(dialog));
|
_("File exists, overwrite?"));
|
||||||
gtk_widget_destroy(dialog);
|
resp = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
if (resp != GTK_RESPONSE_YES) {
|
gtk_widget_destroy (dialog);
|
||||||
g_free(my_file_name);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1213,20 +1225,19 @@ save (EMsgComposer *composer, const char *file_name)
|
|||||||
|
|
||||||
CORBA_exception_init (&ev);
|
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) {
|
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||||
char *tmp = g_path_get_basename(my_file_name);
|
char *tmp = g_path_get_basename (filename);
|
||||||
|
|
||||||
e_notice (composer, GTK_MESSAGE_ERROR,
|
e_notice (composer, GTK_MESSAGE_ERROR, _("Error saving file: %s"), tmp);
|
||||||
_("Error saving file: %s"), tmp);
|
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
} else
|
} else
|
||||||
GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev);
|
GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev);
|
||||||
|
|
||||||
CORBA_exception_free (&ev);
|
CORBA_exception_free (&ev);
|
||||||
|
|
||||||
g_free (my_file_name);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user