diff options
author | Not Zed <NotZed@Ximian.com> | 2004-04-28 14:38:55 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-04-28 14:38:55 +0800 |
commit | 9e7d28c8bc1c14cbb627f0375a60c312c5569536 (patch) | |
tree | 1608bdedc6d7e8583767c660629e4c4a0c50e03c /composer | |
parent | 6674bdd55b8b29b1bde4b032f6933dfcfb967107 (diff) | |
download | gsoc2013-evolution-9e7d28c8bc1c14cbb627f0375a60c312c5569536.tar.gz gsoc2013-evolution-9e7d28c8bc1c14cbb627f0375a60c312c5569536.tar.zst gsoc2013-evolution-9e7d28c8bc1c14cbb627f0375a60c312c5569536.zip |
** Changed error messages to EError.
2004-04-28 Not Zed <NotZed@Ximian.com>
** Changed error messages to EError.
svn path=/trunk/; revision=25652
Diffstat (limited to 'composer')
-rw-r--r-- | composer/ChangeLog | 4 | ||||
-rw-r--r-- | composer/Makefile.am | 8 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment-bar.c | 13 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.c | 10 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 135 | ||||
-rw-r--r-- | composer/mail-composer-errors.xml.in | 24 |
6 files changed, 75 insertions, 119 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 3cb82e6d39..3dfa45febc 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,7 @@ +2004-04-28 Not Zed <NotZed@Ximian.com> + + ** Changed error messages to EError. + 2004-04-27 Not Zed <NotZed@Ximian.com> * e-msg-composer-attachment-bar.c (update): duh, pass the string diff --git a/composer/Makefile.am b/composer/Makefile.am index 7ffdc41eca..17d918f3ac 100644 --- a/composer/Makefile.am +++ b/composer/Makefile.am @@ -29,6 +29,11 @@ $(HTML_EDITOR_GENERATED): $(GTKHTML_DATADIR)/Editor.idl ## +error_in_files = mail-composer-errors.xml.in +error_DATA = $(error_in_files:.xml.in=.xml) +errordir = $(privdatadir)/errors +@INTLTOOL_XML_RULE@ + idl_DATA = $(IDLS) glade_DATA = \ @@ -77,11 +82,12 @@ libcomposer_la_SOURCES = \ listener.h EXTRA_DIST = \ + $(error_in_files) \ $(glade_DATA) \ $(IDLS) \ ChangeLog.pre-1-4 -BUILT_SOURCES = $(IDL_GENERATED) $(HTML_EDITOR_GENERATED) +BUILT_SOURCES = $(IDL_GENERATED) $(HTML_EDITOR_GENERATED) $(error_DATA) CLEANFILES = $(BUILT_SOURCES) dist-hook: diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index 3cd58a9955..c8cf9b5e7b 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -21,7 +21,6 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -55,6 +54,7 @@ #include "e-util/e-gui-utils.h" #include "e-util/e-icon-factory.h" +#include "widgets/misc/e-error.h" #define ICON_WIDTH 64 #define ICON_SEPARATORS " /-_" @@ -171,22 +171,15 @@ add_from_file (EMsgComposerAttachmentBar *bar, const char *disposition) { EMsgComposerAttachment *attachment; - EMsgComposer *composer; CamelException ex; - GtkWidget *dialog; camel_exception_init (&ex); attachment = e_msg_composer_attachment_new (file_name, disposition, &ex); if (attachment) { add_common (bar, attachment); } else { - composer = E_MSG_COMPOSER (gtk_widget_get_toplevel (GTK_WIDGET (bar))); - dialog = gtk_message_dialog_new(GTK_WINDOW(composer), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s", camel_exception_get_description (&ex)); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); + e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)bar), "mail-composer:no-attach", + file_name, camel_exception_get_description(&ex), NULL); camel_exception_clear (&ex); } } diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index d9c444dc3b..5d23e385e0 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -51,6 +51,8 @@ #include <gal/e-text/e-entry.h> +#include "widgets/misc/e-error.h" + #include <camel/camel.h> #include "e-msg-composer-hdrs.h" #include "mail/mail-config.h" @@ -266,7 +268,7 @@ static void account_removed_cb (EAccountList *accounts, EAccount *account, EMsgComposerHdrs *hdrs) { struct _EMsgComposerHdrsPrivate *priv = hdrs->priv; - GtkWidget *item, *omenu, *toplevel, *dialog; + GtkWidget *item, *omenu, *toplevel; EAccount *acnt; GSList *node; @@ -302,10 +304,8 @@ account_removed_cb (EAccountList *accounts, EAccount *account, EMsgComposerHdrs toplevel = gtk_widget_get_toplevel ((GtkWidget *) hdrs); gtk_widget_set_sensitive (toplevel, FALSE); - dialog = gtk_message_dialog_new ((GtkWindow *) toplevel, GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", - _("You need to configure an account before you can compose mail.")); + /* FIXME: this should offer a 'configure account' button, can we do that? */ + e_error_run((GtkWindow *)toplevel, "mail-composer:all-accounts-deleted", NULL); } } } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index b355e85db3..6330686394 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -91,6 +91,7 @@ #include "e-util/e-signature-list.h" #include "widgets/misc/e-charset-picker.h" #include "widgets/misc/e-expander.h" +#include "widgets/misc/e-error.h" #include <camel/camel-session.h> #include <camel/camel-charset-map.h> @@ -786,14 +787,8 @@ skip_content: camel_object_unref (new); if (ex.id != CAMEL_EXCEPTION_USER_CANCEL) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new(GTK_WINDOW(composer), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s", camel_exception_get_description (&ex)); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); + e_error_run((GtkWindow *)composer, "mail-composer:no-build-message", + camel_exception_get_description(&ex), NULL); } camel_exception_clear (&ex); @@ -822,17 +817,9 @@ get_file_content (EMsgComposer *composer, const char *file_name, gboolean want_h fd = open (file_name, O_RDONLY); if (fd == -1) { - if (warn) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new(GTK_WINDOW(composer), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error while reading file %s:\n%s"), - file_name, g_strerror (errno)); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - } + if (warn) + e_error_run((GtkWindow *)composer, "mail-composer:no-sig-file", + file_name, g_strerror(errno), NULL); return g_strdup (""); } @@ -1201,27 +1188,18 @@ save (EMsgComposer *composer, const char *default_filename) /* 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; 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) { + resp = e_error_run((GtkWindow *)composer, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, + filename, NULL); + if (resp != GTK_RESPONSE_OK) { 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); + e_error_run((GtkWindow *)composer, E_ERROR_NO_SAVE_FILE, + filename, g_strerror(errnosav)); g_free (filename); return; } @@ -1233,10 +1211,8 @@ save (EMsgComposer *composer, const char *default_filename) Bonobo_PersistFile_save (composer->persist_file_interface, filename, &ev); if (ev._major != CORBA_NO_EXCEPTION) { - char *tmp = g_path_get_basename (filename); - - e_notice (composer, GTK_MESSAGE_ERROR, _("Error saving file: %s"), tmp); - g_free(tmp); + e_error_run((GtkWindow *)composer, E_ERROR_NO_SAVE_FILE, + filename, _("Unknown reason")); } else { GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev); e_msg_composer_unset_autosaved (composer); @@ -1255,13 +1231,9 @@ load (EMsgComposer *composer, const char *file_name) Bonobo_PersistFile_load (composer->persist_file_interface, file_name, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - char *tmp = g_path_get_basename(file_name); - - e_notice (composer, GTK_MESSAGE_ERROR, - _("Error loading file: %s"), tmp); - g_free(tmp); - } + if (ev._major != CORBA_NO_EXCEPTION) + e_error_run((GtkWindow *)composer, E_ERROR_NO_LOAD_FILE, + file_name, _("Unknown reason"), NULL); CORBA_exception_free (&ev); } @@ -1296,39 +1268,26 @@ autosave_save_draft (EMsgComposer *composer) file = composer->autosave_file; if (fd == -1) { - e_notice (composer, GTK_MESSAGE_ERROR, - _("Error accessing file: %s"), file); + /* This code is odd, the fd is opened elsewhere but a failure is ignored */ + e_error_run((GtkWindow *)composer, "mail-composer:no-autosave", + file, _("Could not open file"), NULL); return FALSE; } message = e_msg_composer_get_message_draft (composer); if (message == NULL) { - e_notice (composer, GTK_MESSAGE_ERROR, - _("Unable to retrieve message from editor")); + e_error_run((GtkWindow *)composer, "mail-composer:no-autosave", + file, _("Unable to retrieve message from editor"), NULL); return FALSE; } - if (lseek (fd, (off_t)0, SEEK_SET) == -1) { + if (lseek (fd, (off_t)0, SEEK_SET) == -1 + || ftruncate (fd, (off_t)0) == -1 + || (camelfd = dup(fd)) == -1) { camel_object_unref (message); - e_notice (composer, GTK_MESSAGE_ERROR, - _("Unable to seek on file: %s\n%s"), file, g_strerror (errno)); - return FALSE; - } - - if (ftruncate (fd, (off_t)0) == -1) { - camel_object_unref (message); - e_notice (composer, GTK_MESSAGE_ERROR, - _("Unable to truncate file: %s\n%s"), file, g_strerror (errno)); - return FALSE; - } - - /* dup the fd because we dont want camel to close it when done */ - camelfd = dup(fd); - if (fd == -1) { - camel_object_unref (message); - e_notice (composer, GTK_MESSAGE_ERROR, - _("Unable to copy file descriptor: %s\n%s"), file, g_strerror (errno)); + e_error_run((GtkWindow *)composer, "mail-composer:no-autosave", + file, g_strerror(errno), NULL); return FALSE; } @@ -1336,9 +1295,8 @@ autosave_save_draft (EMsgComposer *composer) stream = camel_stream_fs_new_with_fd (camelfd); if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream) == -1 || camel_stream_close (CAMEL_STREAM (stream)) == -1) { - e_notice (composer, GTK_MESSAGE_ERROR, - _("Error autosaving message: %s\n %s"), file, strerror(errno)); - + e_error_run((GtkWindow *)composer, "mail-composer:no-autosave", + file, g_strerror(errno), NULL); success = FALSE; } else { CORBA_Environment ev; @@ -1433,18 +1391,8 @@ autosave_manager_query_load_orphans (AutosaveManager *am, GtkWindow *parent) closedir (dir); - if (match != NULL) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (parent, - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - _("Ximian Evolution has found unsaved messages from a previous session.\n" - "Would you like to try to recover them?")); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); - load = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES; - gtk_widget_destroy (dialog); - } + if (match != NULL) + load = e_error_run(parent, "mail-composer:recover-autosave", NULL) == GTK_RESPONSE_YES; while (match != NULL) { GSList *next = match->next; @@ -1588,7 +1536,6 @@ static void do_exit (EMsgComposer *composer) { const char *subject; - GtkWidget *dialog; int button; if (!e_msg_composer_is_dirty (composer) && !e_msg_composer_is_autosaved (composer)) { @@ -1599,24 +1546,10 @@ do_exit (EMsgComposer *composer) gdk_window_raise (GTK_WIDGET (composer)->window); subject = e_msg_composer_hdrs_get_subject (E_MSG_COMPOSER_HDRS (composer->hdrs)); - - dialog = gtk_message_dialog_new (GTK_WINDOW (composer), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, - _("The message \"%s\" has not been sent.\n\n" - "Do you wish to save your changes?"), - subject && *subject ? subject : _("Untitled Message")); - - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - _("_Discard Changes"), GTK_RESPONSE_NO, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_YES, - NULL); - gtk_window_set_title (GTK_WINDOW (dialog), _("Warning: Modified Message")); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); - button = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - + + button = e_error_run((GtkWindow *)composer, "mail-composer:exit-unsaved", + subject && subject[0] ? subject : _("Untitled Message"), NULL); + switch (button) { case GTK_RESPONSE_YES: /* Save */ diff --git a/composer/mail-composer-errors.xml.in b/composer/mail-composer-errors.xml.in index 442891d09f..3314a6dc5c 100644 --- a/composer/mail-composer-errors.xml.in +++ b/composer/mail-composer-errors.xml.in @@ -1,9 +1,9 @@ <?xml version="1.0"?> <error-list domain="mail-composer"> - <error id="attach" type="warning"> + <error id="no-attach" type="error" modal="true"> <_primary>You cannot attach the file `${0}' to this message.</_primary> - <_secondary>${0}</_secondary> + <_secondary>${1}</_secondary> </error> <error id="attach-notfile" type="warning"> @@ -23,6 +23,11 @@ <button _label="Recover" response="GTK_RESPONSE_YES"/> </error> + <error id="no-autosave" type="error"> + <_primary>Could not save to autosave file "{0}".</_primary> + <_secondary>Error saving to autosave because "{1}".</_secondary> + </error> + <error id="exit-unsaved" modal="true" type="warning"> <_title>Warning: Modified Message</_title> <_primary>Are you sure you want to discard the message, titled '{0}', you are composing?</_primary> @@ -32,4 +37,19 @@ <button _label="Save Message" response="GTK_RESPONSE_YES"/> </error> + <error id="no-build-message" type="error" modal="true"> + <_primary>Could not create message.</_primary> + <_secondary>Because "${0}", you may need to select different mail options.</_secondary> + </error> + + <error id="no-sig-file" type="warning" modal="true"> + <_primary>Could not read signature file "{0}".</_primary> + <_secondary>Because "${1}".</_secondary> + </error> + + <error id="all-accounts-deleted" type="warning" modal="true"> + <_primary>All accounts have been removed.</_primary> + <_secondary>You need to configure an account before you can compose mail.</_secondary> + </error> + </error-list> |