aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@novell.com>2004-05-25 22:57:04 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-05-25 22:57:04 +0800
commit479e75883911fc03b2b7d09d69f48faf0f3812eb (patch)
treee0fd0f15f7abaf56031e6be4262a2cc3aea74ba7 /addressbook
parentf87fe83e1df3a2370b9b2dcef90eb8869f4b0eff (diff)
downloadgsoc2013-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')
-rw-r--r--addressbook/ChangeLog32
-rw-r--r--addressbook/Makefile.am18
-rw-r--r--addressbook/addressbook-errors.xml81
-rw-r--r--addressbook/addressbook-errors.xml.h55
-rw-r--r--addressbook/gui/component/addressbook-config.c71
-rw-r--r--addressbook/gui/component/addressbook-view.c15
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c48
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c10
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c160
9 files changed, 261 insertions, 229 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 9848001dfc..a9eef79892 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,35 @@
+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.
+
2004-05-24 Chris Toshok <toshok@ximian.com>
* Makefile.am (SUBDIRS): add tools back to the build.
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am
index d307057f02..4fde08a4a9 100644
--- a/addressbook/Makefile.am
+++ b/addressbook/Makefile.am
@@ -5,5 +5,19 @@ endif
SUBDIRS = \
util printing gui importers tools $(CONDUIT_SUBDIR)
-EXTRA_DIST = \
- ChangeLog.pre-1-4
+error_DATA = addressbook-errors.xml
+error_i18n = $(error_DATA:.xml=.xml.h)
+errordir = $(privdatadir)/errors
+%.xml.h: %.xml
+ $(top_builddir)/e-util/e-error-tool $^
+
+EXTRA_DIST = \
+ ChangeLog.pre-1-4 \
+ $(error_DATA)
+
+dist-hook:
+ cd $(distdir); rm -f $(BUILT_SOURCES)
+
+BUILT_SOURCES = $(error_i18n)
+
+CLEANFILES = $(BUILT_SOURCES)
diff --git a/addressbook/addressbook-errors.xml b/addressbook/addressbook-errors.xml
new file mode 100644
index 0000000000..b574eeb086
--- /dev/null
+++ b/addressbook/addressbook-errors.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="addressbook">
+
+ <error id="ldap-init" type="error" modal="true">
+ <primary>This addressbook could not be opened.</primary>
+ <secondary>This addressbook server might unreachable or the server name may be misspelled or your network connection could be down.</secondary>
+ </error>
+
+ <error id="ldap-auth" type="error" modal="true">
+ <primary>Failed to authenticate with LDAP server.</primary>
+ <secondary>Check to make sure your password is spelled correctly and that you are using a supported login method. Remember that many passwords are case sensitive; your caps lock might be on.</secondary>
+ </error>
+
+ <error id="ldap-search-base" type="error" modal="true">
+ <primary>This addressbook server does not have any suggested search bases.</primary>
+ <secondary>This LDAP server may use an older version of LDAP, which does not support this functionality or it may be misconfigured. Ask your administrator for supported search bases.</secondary>
+ </error>
+
+ <error id="ldap-v3-schema" type="error" modal="true">
+ <primary>This server does not support LDAPv3 schema information.</primary>
+ </error>
+
+ <error id="ldap-get-schema" type="error" modal="true">
+ <primary>Could not get schema information for LDAP server.</primary>
+ </error>
+
+ <error id="ldap-invalid-schema" type="error" modal="true">
+ <primary>LDAP server did not respond with valid schema information.</primary>
+ </error>
+
+ <error id="remove-addressbook" type="error" modal="true">
+ <primary>Could not remove addressbook.</primary>
+ <secondary>{0}</secondary>
+ </error>
+
+ <error id="edit-categories" type="error">
+ <primary>Category editor not available.</primary>
+ </error>
+
+ <error id="generic-error" type="error">
+ <primary>{0}</primary>
+ <secondary>{1}</secondary>
+ </error>
+
+ <error id="load-error" type="error">
+ <title>Unable to open addressbook</title>
+ <primary>Error loading addressbook.</primary>
+ <secondary>{0}</secondary>
+ </error>
+
+ <error id="search-error" type="error">
+ <primary>Unable to perform search.</primary>
+ <secondary>{0}</secondary>
+ </error>
+
+ <error id="prompt-save" type="question" default="GTK_RESPONSE_YES">
+ <primary>Would you like to save your changes?</primary>
+ <secondary>You have made modifications to this contact. Do you want to save these changes?</secondary>
+ <button label="_Discard" response="GTK_RESPONSE_NO"/>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button stock="gtk-save" response="GTK_RESPONSE_YES"/>
+ </error>
+
+ <error id="prompt-move" type="question" default="GTK_RESPONSE_NO">
+ <primary>Cannot move contact.</primary>
+ <secondary>You are attempting to move a contact from one addressbook to another but it cannot be removed from the source. Do you want to save a copy instead?</secondary>
+ <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+ <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+ </error>
+
+ <error id="save-error" type="error">
+ <primary>Unable to save contact(s).</primary>
+ <secondary>Error saving contacts to {0}: {1}</secondary>
+ </error>
+
+ <error id="backend-died" type="error">
+ <primary>The Evolution addressbook has quit unexpectedly.</primary>
+ <secondary>Your contacts for {0} will not be available until Evolution is restarted.</secondary>
+ </error>
+
+</error-list>
diff --git a/addressbook/addressbook-errors.xml.h b/addressbook/addressbook-errors.xml.h
new file mode 100644
index 0000000000..54650cd65a
--- /dev/null
+++ b/addressbook/addressbook-errors.xml.h
@@ -0,0 +1,55 @@
+/* addressbook:ldap-init primary */
+char *s = N_("This addressbook could not be opened.");
+/* addressbook:ldap-init secondary */
+char *s = N_("This addressbook server might unreachable or the server name may be misspelled or your network connection could be down.");
+/* addressbook:ldap-auth primary */
+char *s = N_("Failed to authenticate with LDAP server.");
+/* addressbook:ldap-auth secondary */
+char *s = N_("Check to make sure your password is spelled correctly and that you are using a supported login method. Remember that many passwords are case sensitive; your caps lock might be on.");
+/* addressbook:ldap-search-base primary */
+char *s = N_("This addressbook server does not have any suggested search bases.");
+/* addressbook:ldap-search-base secondary */
+char *s = N_("This LDAP server may use an older version of LDAP, which does not support this functionality or it may be misconfigured. Ask your administrator for supported search bases.");
+/* addressbook:ldap-v3-schema primary */
+char *s = N_("This server does not support LDAPv3 schema information.");
+/* addressbook:ldap-get-schema primary */
+char *s = N_("Could not get schema information for LDAP server.");
+/* addressbook:ldap-invalid-schema primary */
+char *s = N_("LDAP server did not respond with valid schema information.");
+/* addressbook:remove-addressbook primary */
+char *s = N_("Could not remove addressbook.");
+/* addressbook:remove-addressbook secondary */
+char *s = N_("{0}");
+/* addressbook:edit-categories primary */
+char *s = N_("Category editor not available.");
+/* addressbook:generic-error primary */
+char *s = N_("{0}");
+/* addressbook:generic-error secondary */
+char *s = N_("{1}");
+/* addressbook:load-error title */
+char *s = N_("Unable to open addressbook");
+/* addressbook:load-error primary */
+char *s = N_("Error loading addressbook.");
+/* addressbook:load-error secondary */
+char *s = N_("{0}");
+/* addressbook:search-error primary */
+char *s = N_("Unable to perform search.");
+/* addressbook:search-error secondary */
+char *s = N_("{0}");
+/* addressbook:prompt-save primary */
+char *s = N_("Would you like to save your changes?");
+/* addressbook:prompt-save secondary */
+char *s = N_("You have made modifications to this contact. Do you want to save these changes?");
+char *s = N_("_Discard");
+/* addressbook:prompt-move primary */
+char *s = N_("Cannot move contact.");
+/* addressbook:prompt-move secondary */
+char *s = N_("You are attempting to move a contact from one addressbook to another but it cannot be removed from the source. Do you want to save a copy instead?");
+/* addressbook:save-error primary */
+char *s = N_("Unable to save contact(s).");
+/* addressbook:save-error secondary */
+char *s = N_("Error saving contacts to {0}: {1}");
+/* addressbook:backend-died primary */
+char *s = N_("The Evolution addressbook has quit unexpectedly.");
+/* addressbook:backend-died secondary */
+char *s = N_("Your contacts for {0} will not be available until Evolution is restarted.");
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;
}