From 479e75883911fc03b2b7d09d69f48faf0f3812eb Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 25 May 2004 14:57:04 +0000 Subject: Generate the addressbook-errors.xml.h file and install the xml file and 2004-05-25 Jeffrey Stedfast * 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 --- addressbook/gui/widgets/e-addressbook-view.c | 10 +- addressbook/gui/widgets/eab-gui-util.c | 160 ++++++++------------------- 2 files changed, 48 insertions(+), 122 deletions(-) (limited to 'addressbook/gui/widgets') 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 #include @@ -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 @@ -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; } -- cgit v1.2.3