Re: [evolution-patches] patch for bug 48759
- From: Charles Zhang <Charles Zhang Sun Com>
- To: Jeffrey Stedfast <fejj ximian com>
- Cc: evolution-patches <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] patch for bug 48759
- Date: Sat, 27 Sep 2003 21:45:39 +0800
Jeffrey Stedfast wrote:
attached is the correct fix.
appologies for including part of another patch, but I didn't feel like
separating them.
changing the bahaviour of the filesel dialog to not allow the user to
hit OK until a valid filename has been selected is:
1. inconsistant with the rest of gnome/evolution
2. confusing to the user (unless maybe you popped up a dialog to tell
them WHY OK wasn't working... either that or maybe gray out the OK
button until something valid has been input? but you'd also need to
handle the case where the user hits Enter in the entry box which has the
same effect as hitting OK)
Thank you, Jeffrey.
It should be my duty to complete it, but wasted you much time.
I prefer popping up some dialog to explain some reason, with the filesel
dialog open, because it is convenient and the user can save much time
for it.
or you think this way of solving isn't inconsistant with the rest of
evolution either?
the proper fix, attached below, fixes the error dialog shown to the user
so that it doesn't always show "file exists, overwrite?" even if that is
not the problem.
Jeff
On Fri, 2003-09-26 at 14:21, Jeffrey Stedfast wrote:
- /* 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
And if it should be done this way,
Do you think it is necessary to merge these two parts as below?
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?"));
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));
resp = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
if (resp != GTK_RESPONSE_YES) {
g_free (filename);
return;
}
@@ -1193,20 +1211,19 @@
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]