diff options
author | Not Zed <NotZed@Ximian.com> | 2004-04-28 14:39:25 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-04-28 14:39:25 +0800 |
commit | e23cf1ca36bcf886bcac15545166eff0e930a4bd (patch) | |
tree | 22462408dc2fe4da0306bb472cdd6239d739b650 | |
parent | 9e7d28c8bc1c14cbb627f0375a60c312c5569536 (diff) | |
download | gsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.tar.gz gsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.tar.zst gsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.zip |
** Changed error messages to use EError.
2004-04-28 Not Zed <NotZed@Ximian.com>
** Changed error messages to use EError.
svn path=/trunk/; revision=25653
-rw-r--r-- | mail/ChangeLog | 4 | ||||
-rw-r--r-- | mail/Makefile.am | 9 | ||||
-rw-r--r-- | mail/em-account-prefs.c | 21 | ||||
-rw-r--r-- | mail/em-composer-prefs.c | 11 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 45 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 108 | ||||
-rw-r--r-- | mail/em-utils.c | 65 | ||||
-rw-r--r-- | mail/em-utils.h | 2 | ||||
-rw-r--r-- | mail/mail-account-editor.c | 2 | ||||
-rw-r--r-- | mail/mail-account-gui.c | 7 | ||||
-rw-r--r-- | mail/mail-autofilter.c | 15 | ||||
-rw-r--r-- | mail/mail-component.c | 20 | ||||
-rw-r--r-- | mail/mail-errors.xml.in | 8 | ||||
-rw-r--r-- | mail/mail-mt.c | 30 | ||||
-rw-r--r-- | mail/mail-session.c | 32 | ||||
-rw-r--r-- | mail/mail-signature-editor.c | 25 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 22 |
17 files changed, 145 insertions, 281 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index edc5b11800..0f9f31fbbf 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,7 @@ +2004-04-28 Not Zed <NotZed@Ximian.com> + + ** Changed error messages to use EError. + 2004-04-27 Not Zed <NotZed@Ximian.com> ** See bug #57659. diff --git a/mail/Makefile.am b/mail/Makefile.am index e7ee31c340..c8b533bd26 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -184,6 +184,11 @@ server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server) # Misc data to install +error_in_files = mail-errors.xml.in +error_DATA = $(error_in_files:.xml.in=.xml) +errordir = $(privdatadir)/errors +@INTLTOOL_XML_RULE@ + glade_DATA = mail-config.glade subscribe-dialog.glade message-tags.glade mail-search.glade mail-security.glade MARSHAL_GENERATED = em-marshal.c em-marshal.h @EVO_MARSHAL_RULE@ @@ -194,6 +199,7 @@ EXTRA_DIST = \ ChangeLog.pre-1-4 \ em-marshal.list \ $(SPELL_IDL) \ + $(error_in_files) \ $(glade_DATA) \ $(schema_DATA) \ $(server_in_files) \ @@ -237,5 +243,6 @@ install-data-local: dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) -BUILT_SOURCES = $(SPELL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) +BUILT_SOURCES = $(SPELL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(error_DATA) + CLEANFILES = $(BUILT_SOURCES) diff --git a/mail/em-account-prefs.c b/mail/em-account-prefs.c index 91de5e5f87..e7530a0041 100644 --- a/mail/em-account-prefs.c +++ b/mail/em-account-prefs.c @@ -37,6 +37,7 @@ #include "mail-send-recv.h" #include "e-util/e-account-list.h" +#include "widgets/misc/e-error.h" #include "em-account-prefs.h" @@ -202,7 +203,6 @@ account_delete_clicked (GtkButton *button, gpointer user_data) EAccount *account = NULL; EAccountList *accounts; GtkTreeModel *model; - GtkWidget *confirm; GtkTreeIter iter; int ans; @@ -214,24 +214,7 @@ account_delete_clicked (GtkButton *button, gpointer user_data) if (account == NULL || prefs->editor != NULL) return; - confirm = gtk_message_dialog_new (PREFS_WINDOW (prefs), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, - _("Are you sure you want to delete this account?")); - - button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_YES); - gtk_button_set_label (button, _("Delete")); - gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_YES); - gtk_widget_show ((GtkWidget *) button); - - button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_NO); - gtk_button_set_label (button, _("Don't delete")); - gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_NO); - gtk_widget_show ((GtkWidget *) button); - - ans = gtk_dialog_run ((GtkDialog *) confirm); - gtk_widget_destroy (confirm); - + ans = e_error_run(PREFS_WINDOW(prefs), "mail:ask-account-delete", NULL); if (ans == GTK_RESPONSE_YES) { int len; diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index 858a3717fb..554e115e78 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -47,6 +47,8 @@ #include <gtk/gtktreeview.h> #include "widgets/misc/e-charset-picker.h" +#include "widgets/misc/e-error.h" + #include <e-util/e-icon-factory.h> #include "mail-config.h" @@ -355,7 +357,6 @@ sig_add_script_response (GtkWidget *widget, int button, EMComposerPrefs *prefs) { const char *name; char *script; - GtkWidget *dialog; GtkWidget *entry; if (button == GTK_RESPONSE_ACCEPT) { @@ -390,14 +391,8 @@ sig_add_script_response (GtkWidget *widget, int button, EMComposerPrefs *prefs) } } + e_error_run((GtkWindow *)prefs->sig_script_dialog, "mail:signature-notscript", script, NULL); g_free(script); - dialog = gtk_message_dialog_new (GTK_WINDOW (prefs->sig_script_dialog), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must specify a valid script name.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); return; } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index a3ece89b7a..a0f05692e0 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -20,13 +20,14 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <string.h> +#include <gtk/gtkdialog.h> + #include "mail-mt.h" #include "mail-ops.h" #include "mail-tools.h" @@ -35,7 +36,7 @@ #include "mail-send-recv.h" #include "mail-component.h" -#include <e-util/e-dialog-utils.h> /* e_notice */ +#include "widgets/misc/e-error.h" #include "em-utils.h" #include "em-composer-utils.h" @@ -119,48 +120,31 @@ ask_confirm_for_unwanted_html_mail (EMsgComposer *composer, EDestination **recip } } - /* FIXME: this wording sucks */ - res = em_utils_prompt_user((GtkWindow *) composer, GTK_RESPONSE_YES, "/apps/evolution/mail/prompts/unwanted_html", - _("You are sending an HTML-formatted message. Please make sure that\n" - "the following recipients are willing and able to receive HTML mail:\n" - "%s" - "Send anyway?"), - str->str); - g_string_free (str, TRUE); - + res = em_utils_prompt_user((GtkWindow *)composer,"/apps/evolution/mail/prompts/unwanted_html", + "mail:ask-send-html", str->str, NULL); + g_string_free(str, TRUE); + return res; } static gboolean ask_confirm_for_empty_subject (EMsgComposer *composer) { - return em_utils_prompt_user((GtkWindow *)composer, GTK_RESPONSE_YES, "/apps/evolution/mail/prompts/empty_subject", - _("This message has no subject.\nReally send?")); + return em_utils_prompt_user((GtkWindow *)composer, "/apps/evolution/mail/prompts/empty_subject", + "mail:ask-send-no-subject", NULL); } static gboolean ask_confirm_for_only_bcc (EMsgComposer *composer, gboolean hidden_list_case) { - const char *first_text; - /* If the user is mailing a hidden contact list, it is possible for them to create a message with only Bcc recipients without really realizing it. To try to avoid being totally confusing, I've changed this dialog to provide slightly different text in that case, to better explain what the hell is going on. */ - if (hidden_list_case) { - first_text = _("Since the contact list you are sending to " - "is configured to hide the list's addresses, " - "this message will contain only Bcc recipients."); - } else { - first_text = _("This message contains only Bcc recipients."); - } - - return em_utils_prompt_user ((GtkWindow *) composer, GTK_RESPONSE_YES, "/apps/evolution/mail/prompts/only_bcc", - "%s\n%s", first_text, - _("It is possible that the mail server may reveal the recipients " - "by adding an Apparently-To header.\nSend anyway?")); + return em_utils_prompt_user((GtkWindow *)composer, "/apps/evolution/mail/prompts/only_bcc", + hidden_list_case?"mail:ask-send-only-bcc-contact":"mail:ask-send-only-bcc", NULL); } struct _send_data { @@ -301,8 +285,7 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ if (no_recipients) *no_recipients = TRUE; } else { - e_notice ((GtkWindow *) composer, GTK_MESSAGE_WARNING, - _("You must specify recipients in order to send this message.")); + e_error_run((GtkWindow *)composer, "mail:send-no-recipients", NULL); goto finished; } } @@ -570,9 +553,7 @@ em_utils_composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user mail_msg_wait (id); if (!folder) { - if (!em_utils_prompt_user ((GtkWindow *) composer, GTK_RESPONSE_YES, NULL, - _("Unable to open the drafts folder for this account.\n" - "Would you like to use the default drafts folder?"))) + if (e_error_run((GtkWindow *)composer, "mail:ask-default-drafts", NULL) != GTK_RESPONSE_YES) return; folder = drafts_folder; diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 7365f6f920..56d457a725 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -49,8 +49,9 @@ #include "e-util/e-mktemp.h" #include "e-util/e-request.h" -#include "e-util/e-dialog-utils.h" -#include <e-util/e-icon-factory.h> +#include "e-util/e-icon-factory.h" + +#include "widgets/misc/e-error.h" #include "filter/vfolder-rule.h" @@ -1972,11 +1973,9 @@ emft_popup_copy_folder_selected (const char *uri, void *data) { struct _copy_folder_data *cfd = data; struct _EMFolderTreePrivate *priv; - CamelStore *fromstore, *tostore; + CamelStore *fromstore = NULL, *tostore = NULL; char *tobase = NULL, *frombase; - GtkWindow *parent; CamelException ex; - GtkWidget *dialog; CamelURL *url; if (uri == NULL) { @@ -1989,20 +1988,24 @@ emft_popup_copy_folder_selected (const char *uri, void *data) d(printf ("%sing folder '%s' to '%s'\n", cfd->delete ? "move" : "copy", priv->selected_path, uri)); camel_exception_init (&ex); - if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex))) - goto exception; - frombase = priv->selected_path + 1; - if (fromstore == mail_component_peek_local_store (NULL) && is_special_local_folder (frombase)) { - if (cfd->delete) - camel_exception_setv (&ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot move folder `%s': illegal operation"), frombase); - camel_object_unref (fromstore); - goto exception; + + if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex))) { + e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW), + cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", frombase, uri, ex.desc, NULL); + goto fail; + } + + if (cfd->delete && fromstore == mail_component_peek_local_store (NULL) && is_special_local_folder (frombase)) { + e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW), + "mail:no-rename-special-folder", frombase, NULL); + goto fail; } if (!(tostore = camel_session_get_store (session, uri, &ex))) { - camel_object_unref (fromstore); - goto exception; + e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW), + cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-move-folder-to-notexist", frombase, uri, ex.desc, NULL); + goto fail; } url = camel_url_new (uri, NULL); @@ -2016,18 +2019,12 @@ emft_popup_copy_folder_selected (const char *uri, void *data) emft_copy_folders (tostore, tobase, fromstore, frombase, cfd->delete); camel_url_free (url); - g_free (cfd); - - return; - - exception: - - parent = (GtkWindow *) gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW); - dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s"), ex.desc); - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); +fail: + if (fromstore) + camel_object_unref(fromstore); + if (tostore) + camel_object_unref(tostore); camel_exception_clear (&ex); - gtk_widget_show (dialog); g_free (cfd); } @@ -2174,40 +2171,31 @@ em_folder_tree_create_folder (EMFolderTree *emft, const char *path, const char * struct _EMFolderTreePrivate *priv = emft->priv; struct _EMFolderTreeModelStoreInfo *si; gboolean created = FALSE; - GtkWindow *window; - GtkWidget *dialog; CamelStore *store; CamelException ex; d(printf ("Creating folder: %s (%s)\n", path, uri)); camel_exception_init (&ex); - if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) - goto exception; + if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) { + e_error_run((GtkWindow *)gtk_widget_get_ancestor((GtkWidget *)emft, GTK_TYPE_WINDOW), + "mail:no-create-folder-nostore", path, ex.desc, NULL); + goto fail; + } if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) { abort(); camel_object_unref (store); - goto exception; + goto fail; } camel_object_unref (store); mail_msg_wait (emft_create_folder (si->store, path, created_cb, &created)); +fail: + camel_exception_clear(&ex); return created; - - exception: - - window = (GtkWindow *) gtk_widget_get_ancestor ((GtkWidget *) emft, GTK_TYPE_WINDOW); - dialog = gtk_message_dialog_new (window, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s"), ex.desc); - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); - camel_exception_clear (&ex); - - gtk_widget_show (dialog); - - return FALSE; } static void @@ -2394,7 +2382,7 @@ emft_popup_delete_response (GtkWidget *dialog, guint response, EMFolderTree *emf camel_exception_init (&ex); emft_popup_delete_folders (store, path, &ex); if (camel_exception_is_set (&ex)) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("Could not delete folder: %s"), ex.desc); + e_error_run(NULL, "mail:no-delete-folder", path, ex.desc, NULL); camel_exception_clear (&ex); } } @@ -2409,7 +2397,7 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft) GtkTreeIter iter; GtkWidget *dialog; const char *full_name; - char *title, *path; + char *path; selection = gtk_tree_view_get_selection (priv->treeview); if (!emft_selection_get_selected (selection, &model, &iter)) @@ -2421,26 +2409,11 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft) full_name = path[0] == '/' ? path + 1 : path; if (store == local && is_special_local_folder (full_name)) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot delete local %s folder."), full_name); + e_error_run(NULL, "mail:no-delete-spethal-folder", full_name, NULL); return; } - - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, - _("Really delete folder \"%s\" and all of its subfolders?"), - full_name); - - gtk_dialog_add_button ((GtkDialog *) dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - gtk_dialog_add_button ((GtkDialog *) dialog, GTK_STOCK_DELETE, GTK_RESPONSE_OK); - - gtk_dialog_set_default_response ((GtkDialog *) dialog, GTK_RESPONSE_OK); - gtk_container_set_border_width ((GtkContainer *) dialog, 6); - gtk_box_set_spacing ((GtkBox *) ((GtkDialog *) dialog)->vbox, 6); - - title = g_strdup_printf (_("Delete \"%s\""), full_name); - gtk_window_set_title ((GtkWindow *) dialog, title); - g_free (title); - + + dialog = e_error_new(NULL, "mail:ask-delete-folder", full_name, NULL); g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_delete_response), emft); gtk_widget_show (dialog); } @@ -2473,7 +2446,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) /* don't allow user to rename one of the special local folders */ if (store == local && is_special_local_folder (full_name)) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot rename local %s folder."), full_name); + e_error_run(NULL, "mail:no-rename-spethal-folder", full_name, NULL); return; } @@ -2506,10 +2479,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) camel_exception_init (&ex); if ((fi = camel_store_get_folder_info (store, path, CAMEL_STORE_FOLDER_INFO_FAST, &ex)) != NULL) { camel_store_free_folder_info (store, fi); - - e_notice (NULL, GTK_MESSAGE_ERROR, - _("A folder named \"%s\" already exists. Please use a different name."), - new_name); + e_error_run(NULL, "mail:no-rename-folder-exists", name, new_name, NULL); } else { const char *oldpath, *newpath; @@ -2521,7 +2491,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) camel_exception_clear (&ex); camel_store_rename_folder (store, oldpath, newpath, &ex); if (camel_exception_is_set (&ex)) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("Could not rename folder: %s"), ex.desc); + e_error_run(NULL, "mail:no-rename-folder", oldpath, newpath, ex.desc, NULL); camel_exception_clear (&ex); } diff --git a/mail/em-utils.c b/mail/em-utils.c index 5f6236f1cc..4b92555684 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -46,8 +46,9 @@ #include "message-tag-followup.h" #include <e-util/e-mktemp.h> -#include <e-util/e-dialog-utils.h> #include <e-util/e-account-list.h> +#include <e-util/e-dialog-utils.h> +#include "widgets/misc/e-error.h" #include <gal/util/e-util.h> @@ -63,10 +64,9 @@ static void emu_save_part_done (CamelMimePart *part, char *name, int done, void /** * em_utils_prompt_user: * @parent: parent window - * @def: default response * @promptkey: gconf key to check if we should prompt the user or not. - * @fmt: prompt format - * @Varargs: varargs + * @tag: e_error tag. + * @arg0: The first of a NULL terminated list of arguments for the error. * * Convenience function to query the user with a Yes/No dialog and a * "Don't show this dialog again" checkbox. If the user checks that @@ -76,29 +76,25 @@ static void emu_save_part_done (CamelMimePart *part, char *name, int done, void * Returns %TRUE if the user clicks Yes or %FALSE otherwise. **/ gboolean -em_utils_prompt_user(GtkWindow *parent, int def, const char *promptkey, const char *fmt, ...) +em_utils_prompt_user(GtkWindow *parent, const char *promptkey, const char *tag, const char *arg0, ...) { GtkWidget *mbox, *check = NULL; va_list ap; int button; - char *str; GConfClient *gconf = mail_config_get_gconf_client(); if (promptkey && !gconf_client_get_bool(gconf, promptkey, NULL)) return TRUE; - - va_start (ap, fmt); - str = g_strdup_vprintf (fmt, ap); - va_end (ap); - mbox = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - "%s", str); - g_free (str); - gtk_dialog_set_default_response ((GtkDialog *) mbox, def); + + va_start(ap, arg0); + mbox = e_error_newv(parent, tag, arg0, ap); + va_end(ap); + if (promptkey) { check = gtk_check_button_new_with_label (_("Don't show this message again.")); - gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 10); + gtk_container_set_border_width((GtkContainer *)check, 12); + gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0); gtk_widget_show (check); } @@ -278,9 +274,7 @@ em_utils_edit_filters (GtkWidget *parent) g_free (user); if (((RuleContext *) fc)->error) { - e_notice (parent, GTK_MESSAGE_ERROR, - _("Error loading filter information:\n%s"), - ((RuleContext *) fc)->error); + e_error_run((GtkWindow *)parent, "mail:filter-load-error", ((RuleContext *)fc)->error, NULL); return; } @@ -1432,13 +1426,11 @@ emu_can_save(GtkWindow *parent, const char *path) if (access (path, F_OK) == 0) { if (access (path, W_OK) != 0) { - e_notice (parent, GTK_MESSAGE_ERROR, - _("Cannot save to `%s'\n %s"), path, g_strerror (errno)); + e_error_run(parent, "mail:no-save-path", path, g_strerror(errno), NULL); return FALSE; } - return em_utils_prompt_user (parent, GTK_RESPONSE_NO, NULL, - _("`%s' already exists.\nOverwrite it?"), path); + return e_error_run(parent, "mail:ask-save-path-overwrite", path, NULL) == GTK_RESPONSE_OK; } return TRUE; @@ -1516,8 +1508,7 @@ em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePar dirname = g_path_get_dirname(filename); if (camel_mkdir(dirname, 0777) == -1) { - e_notice(parent, GTK_MESSAGE_ERROR, - _("Cannot save to `%s'\n %s"), filename, g_strerror(errno)); + e_error_run((GtkWindow *)parent, "mail:no-create-path", filename, g_strerror(errno), NULL); g_free(dirname); return FALSE; } @@ -1525,15 +1516,13 @@ em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePar if (access(filename, F_OK) == 0) { if (access(filename, W_OK) != 0) { - e_notice(parent, GTK_MESSAGE_ERROR, - _("Cannot save to `%s'\n %s"), filename, g_strerror(errno)); + e_error_run((GtkWindow *)parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, filename, NULL); return FALSE; } } if (stat(filename, &st) != -1 && !S_ISREG(st.st_mode)) { - e_notice(parent, GTK_MESSAGE_ERROR, - _("Error: '%s' exists and is not a regular file"), filename); + e_error_run((GtkWindow *)parent, "no-write-path-notfile", filename, NULL); return FALSE; } @@ -2121,10 +2110,7 @@ em_utils_temp_save_part(GtkWidget *parent, CamelMimePart *part) tmpdir = e_mkdtemp("evolution-tmp-XXXXXX"); if (tmpdir == NULL) { - e_notice(parent, GTK_MESSAGE_ERROR, - _("Could not create temporary directory: %s"), - g_strerror (errno)); - + e_error_run((GtkWindow *)parent, "mail:no-create-tmp-path", g_strerror(errno), NULL); return NULL; } @@ -2451,12 +2437,7 @@ em_utils_expunge_folder (GtkWidget *parent, CamelFolder *folder) camel_object_get(folder, NULL, CAMEL_OBJECT_DESCRIPTION, &name, 0); - if (!em_utils_prompt_user ((GtkWindow *) parent, GTK_RESPONSE_NO, - "/apps/evolution/mail/prompts/expunge", - _("This operation will permanently remove all deleted messages " - "in the folder `%s'. If you continue, you " - "will not be able to recover these messages.\n" - "\nReally erase these messages?"), name)) + if (!em_utils_prompt_user ((GtkWindow *) parent, "/apps/evolution/mail/prompts/expunge", "mail:ask-expunge", name, NULL)) return; mail_expunge_folder(folder, NULL, NULL); @@ -2477,11 +2458,7 @@ em_utils_empty_trash (GtkWidget *parent) EIterator *iter; CamelException ex; - if (!em_utils_prompt_user ((GtkWindow *) parent, GTK_RESPONSE_NO, "/apps/evolution/mail/prompts/empty_trash", - _("This operation will permanently remove all deleted messages " - "in all folders. If you continue, you will not be able to " - "recover these messages.\n" - "\nReally erase these messages?"))) + if (!em_utils_prompt_user((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) return; camel_exception_init (&ex); diff --git a/mail/em-utils.h b/mail/em-utils.h index 786e9583ec..4c24316b60 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -42,7 +42,7 @@ struct _GtkSelectionData; struct _GtkAdjustment; struct _EMsgComposer; -gboolean em_utils_prompt_user(struct _GtkWindow *parent, int def, const char *promptkey, const char *fmt, ...); +gboolean em_utils_prompt_user(struct _GtkWindow *parent, const char *promptkey, const char *tag, const char *arg0, ...); GPtrArray *em_utils_uids_copy (GPtrArray *uids); void em_utils_uids_free (GPtrArray *uids); diff --git a/mail/mail-account-editor.c b/mail/mail-account-editor.c index cfe619b22f..963ba36498 100644 --- a/mail/mail-account-editor.c +++ b/mail/mail-account-editor.c @@ -107,7 +107,7 @@ apply_changes (MailAccountEditor *editor) if (page != -1) { gtk_notebook_set_current_page (editor->notebook, page); gtk_widget_grab_focus (incomplete); - e_notice (editor, GTK_MESSAGE_ERROR, _("You have not filled in all of the required information.")); + e_error_run(editor, "mail:account-incomplete", NULL); return FALSE; } diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 33d61d1705..bc3eaba006 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -22,7 +22,6 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -36,9 +35,10 @@ #include <gconf/gconf-client.h> #include <e-util/e-account-list.h> -#include <e-util/e-dialog-utils.h> #include <e-util/e-signature-list.h> +#include <widgets/misc/e-error.h> + #include "em-account-prefs.h" #include "em-folder-selection-button.h" #include "mail-account-gui.h" @@ -2266,7 +2266,8 @@ mail_account_gui_save (MailAccountGui *gui) account = mail_config_get_account_by_name (new_name); if (account && account != new) { - e_notice (gui->account_name, GTK_MESSAGE_ERROR, _("You may not create two accounts with the same name.")); + e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)gui->account_name), + "mail:account-notunique", NULL); return FALSE; } diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index d6c5b8e462..3091abc032 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -427,22 +427,17 @@ mail_filter_delete_uri(CamelStore *store, const char *uri) GString *s; GList *l; - s = g_string_new (_("The following filter rule(s):\n")); + s = g_string_new(""); l = deleted; while (l) { g_string_append_printf (s, " %s\n", (char *)l->data); l = l->next; } - g_string_append_printf (s, _("Used the removed folder:\n '%s'\n" - "And have been updated."), euri); - - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, "%s", s->str); + + dialog = e_error_new(NULL, "mail:filter-updated", s->str, euri, NULL); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); - - g_string_free (s, TRUE); - - gtk_widget_show (dialog); + g_string_free(s, TRUE); + gtk_widget_show(dialog); printf("Folder deleterename '%s' changed filters, resaving\n", euri); if (rule_context_save ((RuleContext *) fc, user) == -1) diff --git a/mail/mail-component.c b/mail/mail-component.c index 05ca8cfb5a..6227f113e0 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -45,6 +45,7 @@ #include "em-migrate.h" #include "widgets/misc/e-info-label.h" +#include "widgets/misc/e-error.h" #include "filter/rule-context.h" #include "mail-config.h" @@ -57,6 +58,7 @@ #include "mail-send-recv.h" #include "mail-session.h" #include "mail-offline-handler.h" +#include "message-list.h" #include "e-activity-handler.h" #include "shell/e-user-creatable-items-handler.h" @@ -68,7 +70,6 @@ #include <gtk/gtklabel.h> #include <e-util/e-mktemp.h> -#include <e-util/e-dialog-utils.h> #include <gal/e-table/e-tree.h> #include <gal/e-table/e-tree-memory.h> @@ -616,20 +617,9 @@ impl_requestQuit(PortableServer_Servant servant, CORBA_Environment *ev) folder = mc_default_folders[MAIL_COMPONENT_FOLDER_OUTBOX].folder; if (folder != NULL && camel_folder_get_message_count(folder) != 0 - && camel_session_is_online(session)) { - GtkWidget *dialog; - guint resp; - - /* FIXME: HIG? */ - dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO, - _("You have unsent messages, do you wish to quit anyway?")); - gtk_dialog_set_default_response((GtkDialog *)dialog, GTK_RESPONSE_NO); - resp = gtk_dialog_run((GtkDialog *)dialog); - gtk_widget_destroy(dialog); - - if (resp != GTK_RESPONSE_YES) - return FALSE; - } + && camel_session_is_online(session) + && e_error_run(NULL, "mail:exit-unsaved", NULL) != GTK_RESPONSE_YES) + return FALSE; return TRUE; } diff --git a/mail/mail-errors.xml.in b/mail/mail-errors.xml.in index 81a7d09af0..7d5ec855bf 100644 --- a/mail/mail-errors.xml.in +++ b/mail/mail-errors.xml.in @@ -138,14 +138,6 @@ The message is stored in the Outbox folder. Check the message for errors and re <_secondary>{1}</_secondary> </error> - <error id="ask-save-path-overwrite" type="error" default="GTK_RESPONSE_CANCEL"> - <_title>Overwrite file?</_title> - <_primary>File exists "{0}".</_primary> - <_secondary>Do you wish to overwrite it?</_secondary> - <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/> - <button _label="_Overwrite" response="GTK_RESPONSE_OK"/> - </error> - <error id="no-create-path" type="error"> <_primary>Cannot save to file "{0}".</_primary> <_secondary>Cannot create the save directory, because "{1}"</_secondary> diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 3b7da83244..9fc3c113c8 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -19,13 +19,15 @@ #include <gal/widgets/e-gui-utils.h> #include "e-util/e-msgport.h" -#include "camel/camel-operation.h" +#include "widgets/misc/e-error.h" #include "e-activity-handler.h" #include <e-util/e-icon-factory.h> -#include "mail-config.h" #include "camel/camel-url.h" +#include "camel/camel-operation.h" + +#include "mail-config.h" #include "mail-component.h" #include "mail-session.h" #include "mail-mt.h" @@ -231,8 +233,7 @@ static void error_response(GtkObject *o, int button, void *data) void mail_msg_check_error(void *msg) { struct _mail_msg *m = msg; - char *what = NULL; - char *text; + char *what; GtkDialog *gd; #ifdef MALLOC_CHECK @@ -252,30 +253,25 @@ void mail_msg_check_error(void *msg) if (active_errors == NULL) active_errors = g_hash_table_new(NULL, NULL); - if (m->ops->describe_msg) - what = m->ops->describe_msg(m, FALSE); - - if (what) { - text = g_strdup_printf(_("Error while '%s':\n%s"), what, camel_exception_get_description(&m->ex)); - g_free (what); - } else - text = g_strdup_printf(_("Error while performing operation:\n%s"), camel_exception_get_description(&m->ex)); - /* check to see if we have dialogue already running for this operation */ /* we key on the operation pointer, which is at least accurate enough for the operation type, although it could be on a different object. */ if (g_hash_table_lookup(active_errors, m->ops)) { - g_warning("Error occured while existing dialogue active:\n%s", text); - g_free(text); + g_warning("Error occured while existing dialogue active:\n%s", camel_exception_get_description(&m->ex)); return; } - gd = (GtkDialog *)gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", text); + if (m->ops->describe_msg + && (what = m->ops->describe_msg(m, FALSE))) { + gd = (GtkDialog *)e_error_new(NULL, "mail:async-error", what, camel_exception_get_description(&m->ex), NULL); + g_free(what); + } else + gd = (GtkDialog *)e_error_new(NULL, "mail:async-error-nodescribe", camel_exception_get_description(&m->ex), NULL); + g_hash_table_insert(active_errors, m->ops, gd); g_signal_connect(gd, "response", G_CALLBACK(error_response), m->ops); g_signal_connect(gd, "destroy", G_CALLBACK(error_destroy), m->ops); gtk_widget_show((GtkWidget *)gd); - g_free (text); } void mail_msg_cancel(unsigned int msgid) diff --git a/mail/mail-session.c b/mail/mail-session.c index 38718eac9c..9b0761462f 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -52,6 +52,7 @@ #include "e-util/e-passwords.h" #include "e-util/e-msgport.h" #include "em-junk-filter.h" +#include "widgets/misc/e-error.h" #define d(x) @@ -270,14 +271,10 @@ request_password (struct _pass_msg *m) else title = g_strdup (_("Enter Password")); - password_dialog = (GtkDialog *) gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, - GTK_BUTTONS_OK_CANCEL, "%s", m->prompt); + password_dialog = (GtkDialog *)e_error_new(NULL, "mail:ask-session-password", m->prompt, NULL); gtk_window_set_title (GTK_WINDOW (password_dialog), title); - gtk_dialog_set_default_response (password_dialog, GTK_RESPONSE_OK); g_free (title); - gtk_container_set_border_width ((GtkContainer *) password_dialog, 6); - m->entry = gtk_entry_new (); gtk_entry_set_visibility ((GtkEntry *) m->entry, !(m->flags & CAMEL_SESSION_PASSWORD_SECRET)); g_signal_connect (m->entry, "activate", G_CALLBACK (pass_activate), password_dialog); @@ -456,11 +453,17 @@ user_message_destroy_notify (struct _user_message_msg *m, GObject *deadbeef) message_dialog = NULL; } +/* This is kinda ugly/inefficient, but oh well, it works */ +static const char *error_type[] = { + "session-message-info", "session-message-warning", "session-message-error", + "session-message-info-cancel", "session-message-warning-cancel", "session-message-error-cancel" +}; + static void do_user_message (struct _mail_msg *mm) { struct _user_message_msg *m = (struct _user_message_msg *)mm; - GtkMessageType msg_type; + int type; if (!m->ismain && message_dialog != NULL) { e_dlist_addtail (&message_list, (EDListNode *)m); @@ -469,23 +472,22 @@ do_user_message (struct _mail_msg *mm) switch (m->type) { case CAMEL_SESSION_ALERT_INFO: - msg_type = GTK_MESSAGE_INFO; + type = 0; break; case CAMEL_SESSION_ALERT_WARNING: - msg_type = GTK_MESSAGE_WARNING; + type = 1; break; case CAMEL_SESSION_ALERT_ERROR: - msg_type = GTK_MESSAGE_ERROR; + type = 2; break; default: - msg_type = GTK_MESSAGE_INFO; + type = 0; } + + if (m->allow_cancel) + type += 3; - message_dialog = (GtkDialog *) gtk_message_dialog_new ( - NULL, 0, msg_type, - m->allow_cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, - "%s", m->prompt); - gtk_dialog_set_default_response (message_dialog, m->allow_cancel ? GTK_RESPONSE_CANCEL : GTK_RESPONSE_OK); + message_dialog = (GtkDialog *)e_error_new(NULL, error_type[type], m->prompt, NULL); g_object_set ((GObject *) message_dialog, "allow_shrink", TRUE, "allow_grow", TRUE, NULL); /* We only need to wait for the result if we allow cancel otherwise show but send result back instantly */ diff --git a/mail/mail-signature-editor.c b/mail/mail-signature-editor.c index 864f69bf1f..4828a46aa0 100644 --- a/mail/mail-signature-editor.c +++ b/mail/mail-signature-editor.c @@ -21,7 +21,6 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -38,7 +37,7 @@ #include <bonobo/bonobo-stream-memory.h> #include <e-util/e-signature-list.h> -#include <e-util/e-dialog-utils.h> +#include "widgets/misc/e-error.h" #include "e-msg-composer.h" #include "mail-signature-editor.h" @@ -83,7 +82,7 @@ menu_file_save_error (BonoboUIComponent *uic, CORBA_Environment *ev) err = ev->_major != CORBA_NO_EXCEPTION ? bonobo_exception_get_text (ev) : g_strdup (g_strerror (errno)); - e_notice (NULL, GTK_MESSAGE_ERROR, _("Could not save signature file: %s"), err); + e_error_run(NULL, "mail:no-save-signature", err, NULL); g_warning ("Exception while saving signature: %s", err); g_free (err); @@ -224,25 +223,9 @@ do_exit (ESignatureEditor *editor) CORBA_exception_init (&ev); if (GNOME_GtkHTML_Editor_Engine_hasUndo (editor->engine, &ev)) { - GtkWidget *dialog; int button; - - dialog = gtk_message_dialog_new (GTK_WINDOW (editor->win), - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", - _("This signature has been changed, but hasn't been saved.\n" - "\nDo you wish to save your changes?")); - gtk_dialog_add_buttons ((GtkDialog *) dialog, - _("_Discard changes"), GTK_RESPONSE_NO, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_YES, - NULL); - gtk_window_set_title ((GtkWindow *) dialog, _("Save signature")); - gtk_dialog_set_default_response ((GtkDialog *) dialog, GTK_RESPONSE_YES); - - button = gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - + + button = e_error_run((GtkWindow *)editor->win, "mail:ask-signature-changed", NULL); exit_dialog_cb (button, editor); } else destroy_editor (editor); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 7e8fec52c4..45e542b936 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -39,7 +39,7 @@ #include "em-utils.h" #include "e-util/e-account-list.h" -#include "e-util/e-dialog-utils.h" +#include "widgets/misc/e-error.h" #include "camel/camel.h" #include "camel/camel-vee-folder.h" @@ -521,11 +521,7 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi) GtkWidget *dialog; char *user; - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, - _("The following vFolder(s):\n%s" - "Used the removed folder:\n '%s'\n" - "And have been updated."), - changed->str, uri); + dialog = e_error_new(NULL, "mail:vfolder-updated", changed->str, uri, NULL); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); gtk_widget_show (dialog); @@ -981,8 +977,8 @@ vfolder_edit_rule(const char *uri) g_signal_connect(gd, "response", G_CALLBACK(edit_rule_response), NULL); gtk_widget_show((GtkWidget *)gd); } else { - e_notice (NULL, GTK_MESSAGE_WARNING, - _("Trying to edit a vfolder '%s' which doesn't exist."), uri); + /* TODO: we should probably just create it ... */ + e_error_run(NULL, "mail:vfolder-notexist", uri, NULL); } if (url) @@ -1002,15 +998,7 @@ new_rule_clicked(GtkWidget *w, int button, void *data) } if (rule_context_find_rule ((RuleContext *)context, rule->name, rule->source)) { - GtkWidget *dialog = - gtk_message_dialog_new ((GtkWindow *) w, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Rule name '%s' is not unique, choose another."), - rule->name); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - + e_error_run((GtkWindow *)w, "mail:vfolder-notunique", rule->name, NULL); return; } |