diff options
author | Jeffrey Stedfast <fejj@novell.com> | 2004-05-25 22:57:04 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-05-25 22:57:04 +0800 |
commit | 479e75883911fc03b2b7d09d69f48faf0f3812eb (patch) | |
tree | e0fd0f15f7abaf56031e6be4262a2cc3aea74ba7 /addressbook/gui | |
parent | f87fe83e1df3a2370b9b2dcef90eb8869f4b0eff (diff) | |
download | gsoc2013-evolution-479e75883911fc03b2b7d09d69f48faf0f3812eb.tar.gz gsoc2013-evolution-479e75883911fc03b2b7d09d69f48faf0f3812eb.tar.zst gsoc2013-evolution-479e75883911fc03b2b7d09d69f48faf0f3812eb.zip |
Generate the addressbook-errors.xml.h file and install the xml file and
2004-05-25 Jeffrey Stedfast <fejj@novell.com>
* Makefile.am: Generate the addressbook-errors.xml.h file and
install the xml file and all that jazz.
* addressbook-errors.xml: New error xml file.
* gui/widgets/e-addressbook-view.c (backend_died): Use
e_error_run().
* gui/widgets/eab-gui-util.c (eab_error_dialog): Use
e_error_run().
(eab_load_error_dialog): Same.
(eab_search_result_dialog): Same.
(eab_prompt_save_dialog): Same.
(save_it): Same.
* gui/contact-editor/e-contact-editor.c (categories_clicked): Use
e_error_run().
(e_contact_editor_is_valid): Same.
(save_contact): Same.
* gui/component/addressbook-view.c (delete_addressbook_cb): Use
e_error_run().
* gui/component/addressbook-config.c (addressbook_ldap_init): Use
e_error_run().
(addressbook_ldap_auth): Same.
(addressbook_root_dse_query): Same.
(do_ldap_root_dse_query): Same.
(do_schema_query): Same.
svn path=/trunk/; revision=26077
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook-config.c | 71 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-view.c | 15 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 48 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 10 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 160 |
5 files changed, 77 insertions, 227 deletions
diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index e9e3c123f4..47ca15ebc5 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -29,6 +29,8 @@ #include "addressbook-component.h" #include "addressbook-config.h" +#include "widgets/misc/e-error.h" + #include "evolution-config-control.h" #include <gal/e-table/e-table-memory-store.h> @@ -473,17 +475,8 @@ addressbook_ldap_init (GtkWidget *window, ESource *source) if (!source_to_uri_parts (source, &host, NULL, NULL, &port)) return NULL; - ldap = ldap_init (host, port); - if (!ldap) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new (GTK_WINDOW(window), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Failed to connect to LDAP server")); - g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - } + if (!(ldap = ldap_init (host, port))) + e_error_run ((GtkWindow *) window, "addressbook:ldap-init", NULL); /* XXX do TLS if it's configured in */ @@ -498,23 +491,15 @@ addressbook_ldap_auth (GtkWidget *window, LDAP *ldap) /* XXX use auth info from source */ ldap_error = ldap_simple_bind_s (ldap, NULL, NULL); - if (LDAP_SUCCESS != ldap_error) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new (GTK_WINDOW (window), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Failed to authenticate with LDAP server")); - g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - } - + if (LDAP_SUCCESS != ldap_error) + e_error_run ((GtkWindow *) window, "addressbook:ldap-auth", NULL); + return ldap_error; } static int addressbook_root_dse_query (AddressbookSourceDialog *dialog, GtkWindow *window, LDAP *ldap, -char **attrs, LDAPMessage **resp) + char **attrs, LDAPMessage **resp) { int ldap_error; struct timeval timeout; @@ -526,17 +511,9 @@ char **attrs, LDAPMessage **resp) LDAP_ROOT_DSE, LDAP_SCOPE_BASE, "(objectclass=*)", attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, resp); - if (LDAP_SUCCESS != ldap_error) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new (window, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Could not perform query on Root DSE")); - g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - } - + if (LDAP_SUCCESS != ldap_error) + e_error_run ((GtkWindow *) window, "addressbook:ldap-search-base", NULL); + return ldap_error; } @@ -832,14 +809,7 @@ do_ldap_root_dse_query (AddressbookSourceDialog *sdialog, GtkWidget *dialog, ETa values = ldap_get_values (ldap, resp, "namingContexts"); if (!values || values[0] == NULL) { - GtkWidget *error_dialog; - error_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("The server responded with no supported search bases")); - g_signal_connect (error_dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (error_dialog); + e_error_run ((GtkWindow *) dialog, "addressbook:ldap-search-base", NULL); goto fail; } @@ -1241,9 +1211,7 @@ do_schema_query (AddressbookSourceDialog *sdialog) values = ldap_get_values (ldap, resp, "subschemaSubentry"); if (!values || values[0] == NULL) { - GtkWidget *dialog; - dialog = gnome_ok_dialog_parented (_("This server does not support LDAPv3 schema information"), GTK_WINDOW (sdialog->window)); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + e_error_run ((GtkWindow *) sdialog->window, "addressbook:ldap-v3-schema", NULL); goto fail; } @@ -1262,21 +1230,16 @@ do_schema_query (AddressbookSourceDialog *sdialog) "(objectClass=subschema)", attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, &resp); if (LDAP_SUCCESS != ldap_error) { - GtkWidget *dialog; - dialog = gnome_error_dialog_parented (_("Error retrieving schema information"), GTK_WINDOW (sdialog->window)); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + e_error_run ((GtkWindow *) sdialog->window, "addressbook:ldap-get-schema", NULL); goto fail; } - values = ldap_get_values (ldap, resp, "objectClasses"); - if (!values) { - GtkWidget *dialog; - dialog = gnome_error_dialog_parented (_("Server did not respond with valid schema information"), GTK_WINDOW (sdialog->window)); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (!(values = ldap_get_values (ldap, resp, "objectClasses"))) { + e_error_run ((GtkWindow *) sdialog->window, "addressbook:ldap-invalid-schema", NULL); goto fail; } - for (i = 0; values[i]; i ++) { + for (i = 0; values[i]; i ++) { int j; int code; const char *err; diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index 3b8c86cfef..ce0003cc03 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -38,6 +38,7 @@ #include <bonobo/bonobo-exception.h> #include <gal/util/e-util.h> +#include "widgets/misc/e-error.h" #include "widgets/misc/e-task-bar.h" #include "widgets/misc/e-info-label.h" #include "widgets/misc/e-source-selector.h" @@ -696,17 +697,9 @@ delete_addressbook_cb (GtkWidget *widget, AddressbookView *view) e_source_list_sync (priv->source_list, NULL); } else { - GtkWidget *error_dialog; - - error_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (widget)), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "Error removing address book: %s", - error->message); - gtk_dialog_run (GTK_DIALOG (error_dialog)); - gtk_widget_destroy (error_dialog); - + e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + "addressbook:remove-addressbook", + error->message, NULL); g_error_free (error); } diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 85b2f2f5dc..2d058eca04 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -56,6 +56,7 @@ #include "addressbook/printing/e-contact-print-envelope.h" #include "addressbook/gui/widgets/eab-gui-util.h" #include "e-util/e-gui-utils.h" +#include "widgets/misc/e-error.h" #include "widgets/misc/e-dateedit.h" #include "widgets/misc/e-image-chooser.h" #include "widgets/misc/e-url-entry.h" @@ -2285,18 +2286,12 @@ categories_clicked (GtkWidget *button, EContactEditor *editor) else if (editor->contact) categories = e_contact_get (editor->contact, E_CONTACT_CATEGORIES); - dialog = GTK_DIALOG(e_categories_new(categories)); - - if (dialog == NULL) { - GtkWidget *uh_oh = gtk_message_dialog_new (NULL, - 0, GTK_MESSAGE_ERROR, - GTK_RESPONSE_OK, - _("Category editor not available.")); + if (!(dialog = GTK_DIALOG (e_categories_new (categories)))) { + e_error_run (NULL, "addressbook:edit-categories", NULL); g_free (categories); - gtk_widget_show (uh_oh); return; } - + ecml = e_categories_master_list_wombat_new (); g_object_set (dialog, "header", _("This contact belongs to these categories:"), @@ -2550,27 +2545,7 @@ save_contact (EContactEditor *ce, gboolean should_close) return; if (ce->target_editable && !ce->source_editable) { - GtkWidget *dialog; - gint response; - - dialog = gtk_message_dialog_new (GTK_WINDOW (ce->app), - (GtkDialogFlags) 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("You are moving the contact from one " - "address book to another, but it cannot " - "be removed from the source. Do you want " - "to save a copy instead?")); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_YES, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - if (response == GTK_RESPONSE_CANCEL) + if (e_error_run (GTK_WINDOW (ce->app), "addressbook:prompt-move", NULL) == GTK_RESPONSE_NO) return; } @@ -2601,9 +2576,8 @@ static gboolean e_contact_editor_is_valid (EABEditor *editor) { EContactEditor *ce = E_CONTACT_EDITOR (editor); - GtkWidget *dialog,*widget; + GtkWidget *widget; gboolean validation_error = FALSE; - gint result; GString *errmsg = g_string_new (_("The contact data is invalid:\n\n")); widget = glade_xml_get_widget (ce->gui, "dateedit-birthday"); @@ -2631,14 +2605,8 @@ e_contact_editor_is_valid (EABEditor *editor) if (validation_error) { g_string_append (errmsg, "."); - - dialog = gtk_message_dialog_new (GTK_WINDOW (ce->app), - 0, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - errmsg->str); - result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + e_error_run (GTK_WINDOW (ce->app), "addressbook:generic-error", + _("Invalid contact."), errmsg->str, NULL); g_string_free (errmsg, TRUE); return FALSE; } diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 9c123432ae..b5a98c5a49 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -67,6 +67,8 @@ #endif #include "eab-contact-merging.h" +#include "widgets/misc/e-error.h" + #include "e-contact-editor.h" #include <gdk/gdkkeysyms.h> #include <ctype.h> @@ -1306,12 +1308,8 @@ command_state_change (EABView *eav) static void backend_died (GtkObject *object, EABView *eav) { - char *message = g_strdup_printf (_("The addressbook backend for\n%s\nhas crashed. " - "You will have to restart Evolution in order " - "to use it again"), - e_book_get_uri (eav->book)); - gnome_error_dialog_parented (message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eav)))); - g_free (message); + e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eav))), + "addressbook:backend-died", e_book_get_uri (eav->book), NULL); } static void diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 60640f62f7..6dc7dfb5d1 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -30,6 +30,7 @@ #include "eab-gui-util.h" #include "util/eab-book-util.h" #include "util/e-destination.h" +#include "widgets/misc/e-error.h" #include "widgets/misc/e-image-chooser.h" #include "widgets/misc/e-source-selector.h" #include <e-util/e-icon-factory.h> @@ -41,59 +42,45 @@ #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" #include "addressbook/gui/component/addressbook-component.h" +/* the NULL's in this table correspond to the status codes + that should *never* be generated by a backend */ +static const char *status_to_string[] = { + /* E_BOOK_ERROR_OK */ N_("Success"), + /* E_BOOK_ERROR_INVALID_ARG */ NULL, + /* E_BOOK_ERROR_BUSY */ N_("Backend busy"), + /* E_BOOK_ERROR_REPOSITORY_OFFLINE */ N_("Repository offline"), + /* E_BOOK_ERROR_NO_SUCH_BOOK */ N_("Address Book does not exist"), + /* E_BOOK_ERROR_NO_SELF_CONTACT */ N_("No Self Contact defined"), + /* E_BOOK_ERROR_URI_NOT_LOADED */ NULL, + /* E_BOOK_ERROR_URI_ALREADY_LOADED */ NULL, + /* E_BOOK_ERROR_PERMISSION_DENIED */ N_("Permission denied"), + /* E_BOOK_ERROR_CONTACT_NOT_FOUND */ N_("Contact not found"), + /* E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS */ N_("Contact ID already exists"), + /* E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED */ N_("Protocol not supported"), + /* E_BOOK_ERROR_CANCELLED */ N_("Cancelled"), + /* E_BOOK_ERROR_COULD_NOT_CANCEL */ N_("Could not cancel"), + /* E_BOOK_ERROR_AUTHENTICATION_FAILED */ N_("Authentication Failed"), + /* E_BOOK_ERROR_AUTHENTICATION_REQUIRED */ N_("Authentication Required"), + /* E_BOOK_ERROR_TLS_NOT_AVAILABLE */ N_("TLS not Available"), + /* E_BOOK_ERROR_CORBA_EXCEPTION */ NULL, + /* E_BOOK_ERROR_NO_SUCH_SOURCE */ N_("No such source"), + /* E_BOOK_ERROR_OTHER_ERROR */ N_("Other error") +}; + void -eab_error_dialog (const gchar *msg, EBookStatus status) +eab_error_dialog (const char *msg, EBookStatus status) { - /* the NULL's in this table correspond to the status codes - that should *never* be generated by a backend */ - static char *status_to_string[] = { - /* E_BOOK_ERROR_OK */ N_("Success"), - /* E_BOOK_ERROR_INVALID_ARG */ NULL, - /* E_BOOK_ERROR_BUSY */ N_("Backend busy"), - /* E_BOOK_ERROR_REPOSITORY_OFFLINE */ N_("Repository offline"), - /* E_BOOK_ERROR_NO_SUCH_BOOK */ N_("Address Book does not exist"), - /* E_BOOK_ERROR_NO_SELF_CONTACT */ N_("No Self Contact defined"), - /* E_BOOK_ERROR_URI_NOT_LOADED */ NULL, - /* E_BOOK_ERROR_URI_ALREADY_LOADED */ NULL, - /* E_BOOK_ERROR_PERMISSION_DENIED */ N_("Permission denied"), - /* E_BOOK_ERROR_CONTACT_NOT_FOUND */ N_("Contact not found"), - /* E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS */ N_("Contact ID already exists"), - /* E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED */ N_("Protocol not supported"), - /* E_BOOK_ERROR_CANCELLED */ N_("Cancelled"), - /* E_BOOK_ERROR_COULD_NOT_CANCEL */ N_("Could not cancel"), - /* E_BOOK_ERROR_AUTHENTICATION_FAILED */ N_("Authentication Failed"), - /* E_BOOK_ERROR_AUTHENTICATION_REQUIRED */ N_("Authentication Required"), - /* E_BOOK_ERROR_TLS_NOT_AVAILABLE */ N_("TLS not Available"), - /* E_BOOK_ERROR_CORBA_EXCEPTION */ NULL, - /* E_BOOK_ERROR_NO_SUCH_SOURCE */ N_("No such source"), - /* E_BOOK_ERROR_OTHER_ERROR */ N_("Other error") - }; - char *error_msg; - char *status_str = status_to_string [status]; - GtkWidget *dialog; - - if (status_str) { - error_msg = g_strdup_printf ("%s: %s", msg, _(status_str)); - - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - error_msg); - - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); - - gtk_widget_show (dialog); - - g_free (error_msg); - } + const char *status_str = status_to_string [status]; + + if (status_str) + e_error_run (NULL, "addressbook:generic-error", msg, status_str, NULL); } void eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status) { - char *label_string; - GtkWidget *warning_dialog; - GtkWidget *href = NULL; - gchar *uri; - + char *label_string, *uri; + g_return_if_fail (source != NULL); uri = e_source_get_uri (source); @@ -113,10 +100,8 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status) #else label_string = _("This version of Evolution does not have LDAP support " - "compiled in to it. If you want to use LDAP in Evolution " - "you must compile the program from the CVS sources after " - "retrieving OpenLDAP from the link below."); - href = gnome_href_new ("http://www.openldap.org/", "OpenLDAP at http://www.openldap.org/"); + "compiled in to it. If you want to use LDAP in Evolution, " + "you must install an LDAP-enabled Evolution package."); #endif } else { /* other network folders */ @@ -125,27 +110,9 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status) "means you have entered an incorrect URI, or the server " "is unreachable."); } - - warning_dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL, - 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CLOSE, - label_string, - NULL); - - g_signal_connect (warning_dialog, - "response", - G_CALLBACK (gtk_widget_destroy), - warning_dialog); - - gtk_window_set_title (GTK_WINDOW (warning_dialog), _("Unable to open addressbook")); - - if (href) - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (warning_dialog)->vbox), - href, FALSE, FALSE, 0); - - gtk_widget_show_all (warning_dialog); - + + e_error_run ((GtkWindow *) parent, "addressbook:load-error", label_string, NULL); + g_free (uri); } @@ -179,44 +146,17 @@ eab_search_result_dialog (GtkWidget *parent, case E_BOOK_VIEW_ERROR_OTHER_ERROR: str = _("This query did not complete successfully."); break; + default: + g_assert_not_reached (); } - - if (str) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL, - 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - str); - g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - } + + e_error_run ((GtkWindow *) parent, "addressbook:search-error", str, NULL); } gint eab_prompt_save_dialog (GtkWindow *parent) { - GtkWidget *dialog; - gint response; - - dialog = gtk_message_dialog_new (parent, - (GtkDialogFlags)0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("Do you want to save changes?")); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - _("_Discard"), GTK_RESPONSE_NO, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_YES, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); - - return response; + return e_error_run (parent, "addressbook:prompt-save", NULL); } static void @@ -394,19 +334,7 @@ save_it(GtkWidget *widget, SaveAsInfo *info) return; } } else if (error != 0) { - GtkWidget *dialog; - char *str; - - str = g_strdup_printf (_("Error saving %s: %s"), filename, strerror(errno)); - dialog = gtk_message_dialog_new (GTK_WINDOW (info->filesel), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - str); - g_free (str); - - gtk_widget_show (dialog); - + e_error_run (GTK_WINDOW (info->filesel), "addressbook:save-error", filename, g_strerror (errno)); return; } |