diff options
author | Milan Crha <mcrha@redhat.com> | 2010-12-15 00:44:16 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:41:11 +0800 |
commit | 4231716442dc6bca34a563a17c068d126b37ea7c (patch) | |
tree | 53d1367972f62f1f867fcf0f06909af0b31c2484 | |
parent | f18f55f251bcf12d7320b2f442daa0dcb1c40908 (diff) | |
download | gsoc2013-evolution-4231716442dc6bca34a563a17c068d126b37ea7c.tar.gz gsoc2013-evolution-4231716442dc6bca34a563a17c068d126b37ea7c.tar.zst gsoc2013-evolution-4231716442dc6bca34a563a17c068d126b37ea7c.zip |
Show common addressbook and calendar errors in an alert sink
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 8 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 8 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 28 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 47 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.h | 9 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-private.c | 11 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-sidebar.c | 13 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-sidebar.c | 13 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-sidebar.c | 13 |
11 files changed, 80 insertions, 74 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index e1794572a5..d071e9bab6 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -208,7 +208,7 @@ e_contact_editor_contact_added (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error adding contact"), error); + eab_error_dialog (NULL, _("Error adding contact"), error); } static void @@ -222,7 +222,7 @@ e_contact_editor_contact_modified (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error modifying contact"), error); + eab_error_dialog (NULL, _("Error modifying contact"), error); } static void @@ -236,7 +236,7 @@ e_contact_editor_contact_deleted (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error removing contact"), error); + eab_error_dialog (NULL, _("Error removing contact"), error); } static void @@ -2735,7 +2735,7 @@ contact_editor_book_loaded_cb (ESource *source, g_warn_if_fail (book == NULL); parent = eab_editor_get_window (EAB_EDITOR (editor)); - eab_load_error_dialog (GTK_WIDGET (parent), source, error); + eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error); source_combo_box = e_builder_get_widget ( editor->builder, "source-combo-box-source"); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 2ffee04b91..7c5d9a9c98 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -221,7 +221,7 @@ contact_list_editor_book_loaded_cb (ESource *source, GtkWindow *parent; parent = eab_editor_get_window (EAB_EDITOR (editor)); - eab_load_error_dialog (GTK_WIDGET (parent), source, error); + eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error); e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)), @@ -1157,7 +1157,7 @@ contact_list_editor_contact_added (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error adding list"), error); + eab_error_dialog (NULL, _("Error adding list"), error); } static void @@ -1171,7 +1171,7 @@ contact_list_editor_contact_modified (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error modifying list"), error); + eab_error_dialog (NULL, _("Error modifying list"), error); } static void @@ -1185,7 +1185,7 @@ contact_list_editor_contact_deleted (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error removing list"), error); + eab_error_dialog (NULL, _("Error removing list"), error); } static void diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index e6b24abe75..e64848f527 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -324,7 +324,7 @@ book_view_loaded (EBook *book, EAddressbookModel *model = closure; if (error) { - eab_error_dialog (_("Error getting book view"), error); + eab_error_dialog (NULL, _("Error getting book view"), error); return; } diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index 156f30753e..aa12810b84 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -147,7 +147,7 @@ contact_modified_cb (EBook* book, const GError *error, gpointer user_data) { if (error) - eab_error_dialog (_("Error modifying card"), error); + eab_error_dialog (NULL, _("Error modifying card"), error); } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 0f7bacd781..5879d9970d 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -1099,11 +1099,12 @@ search_result (EAddressbookView *view, const gchar *error_msg) { EShellView *shell_view; - EShellWindow *shell_window; + EAlertSink *alert_sink; shell_view = e_addressbook_view_get_shell_view (view); - shell_window = e_shell_view_get_shell_window (shell_view); - eab_search_result_dialog (GTK_WIDGET (shell_window), status, error_msg); + alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); + + eab_search_result_dialog (alert_sink, status, error_msg); } static void @@ -1141,18 +1142,17 @@ static void backend_died (EAddressbookView *view) { EShellView *shell_view; - EShellWindow *shell_window; + EAlertSink *alert_sink; EAddressbookModel *model; EBook *book; shell_view = e_addressbook_view_get_shell_view (view); - shell_window = e_shell_view_get_shell_window (shell_view); + alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); model = e_addressbook_view_get_model (view); book = e_addressbook_model_get_book (model); - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (alert_sink, "addressbook:backend-died", e_book_get_uri (book), NULL); } @@ -1277,7 +1277,7 @@ delete_contacts_cb (EBook *book, const GError *error, gpointer closure) break; default : /* Unknown error */ - eab_error_dialog (_("Failed to delete contact"), error); + eab_error_dialog (NULL, _("Failed to delete contact"), error); break; } } @@ -1520,10 +1520,12 @@ view_transfer_contacts (EAddressbookView *view, { EBook *book; GList *contacts = NULL; - GtkWindow *parent; + EShellView *shell_view; + EAlertSink *alert_sink; book = e_addressbook_model_get_book (view->priv->model); - parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); + shell_view = e_addressbook_view_get_shell_view (view); + alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); if (all) { EBookQuery *query; @@ -1534,8 +1536,8 @@ view_transfer_contacts (EAddressbookView *view, e_book_query_unref (query); if (error) { - e_alert_run_dialog_for_args ( - parent, "addressbook:search-error", + e_alert_submit ( + alert_sink, "addressbook:search-error", error->message, NULL); g_error_free (error); return; @@ -1544,7 +1546,7 @@ view_transfer_contacts (EAddressbookView *view, contacts = e_addressbook_view_get_selected (view); } - eab_transfer_contacts (book, contacts, delete_from_source, parent); + eab_transfer_contacts (book, contacts, delete_from_source, alert_sink); g_object_unref (book); } diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 51e00fd17d..280758f26d 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -47,19 +47,25 @@ #include <camel/camel.h> void -eab_error_dialog (const gchar *msg, const GError *error) +eab_error_dialog (EAlertSink *alert_sink, const gchar *msg, const GError *error) { - if (error && error->message) - e_alert_run_dialog_for_args (e_shell_get_active_window (NULL), - "addressbook:generic-error", - msg, error->message, NULL); + if (error && error->message) { + if (alert_sink) + e_alert_submit (alert_sink, + "addressbook:generic-error", + msg, error->message, NULL); + else + e_alert_run_dialog_for_args ( + e_shell_get_active_window (NULL), + "addressbook:generic-error", + msg, error->message, NULL); + } } void -eab_load_error_dialog (GtkWidget *parent, ESource *source, const GError *error) +eab_load_error_dialog (GtkWidget *parent, EAlertSink *alert_sink, ESource *source, const GError *error) { gchar *label_string, *label = NULL, *uri; - GtkWidget *dialog; gboolean can_detail_error = TRUE; g_return_if_fail (source != NULL); @@ -130,16 +136,22 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, const GError *error) } } - dialog = e_alert_dialog_new_for_args ((GtkWindow *) parent, "addressbook:load-error", label_string, NULL); - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); + if (alert_sink) { + e_alert_submit (alert_sink, "addressbook:load-error", label_string, NULL); + } else { + GtkWidget *dialog; + + dialog = e_alert_dialog_new_for_args ((GtkWindow *) parent, "addressbook:load-error", label_string, NULL); + g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + } - gtk_widget_show (dialog); g_free (label); g_free (uri); } void -eab_search_result_dialog (GtkWidget *parent, +eab_search_result_dialog (EAlertSink *alert_sink, EBookViewStatus status, const gchar *error_msg) { @@ -181,7 +193,7 @@ eab_search_result_dialog (GtkWidget *parent, g_return_if_reached (); } - e_alert_run_dialog_for_args ((GtkWindow *) parent, "addressbook:search-error", str, NULL); + e_alert_submit (alert_sink, "addressbook:search-error", str, NULL); g_free (str); } @@ -318,6 +330,7 @@ struct ContactCopyProcess_ { EBook *source; EBook *destination; ContactCopyDone done_cb; + EAlertSink *alert_sink; }; static void @@ -365,7 +378,7 @@ contact_added_cb (EBook* book, const GError *error, const gchar *id, gpointer us if (error && !g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) { process->book_status = FALSE; - eab_error_dialog (_("Error adding contact"), error); + eab_error_dialog (process->alert_sink, _("Error adding contact"), error); } else if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) { process->book_status = FALSE; @@ -421,12 +434,13 @@ void eab_transfer_contacts (EBook *source_book, GList *contacts /* adopted */, gboolean delete_from_source, - GtkWindow *parent_window) + EAlertSink *alert_sink) { ESource *destination; static gchar *last_uid = NULL; ContactCopyProcess *process; gchar *desc; + GtkWindow *window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (alert_sink))); g_return_if_fail (E_IS_BOOK (source_book)); @@ -450,7 +464,7 @@ eab_transfer_contacts (EBook *source_book, destination = eab_select_source ( e_book_get_source (source_book), - desc, NULL, last_uid, parent_window); + desc, NULL, last_uid, window); if (!destination) return; @@ -466,6 +480,7 @@ eab_transfer_contacts (EBook *source_book, process->source = g_object_ref (source_book); process->contacts = contacts; process->destination = NULL; + process->alert_sink = alert_sink; if (delete_from_source) process->done_cb = delete_contacts; @@ -473,7 +488,7 @@ eab_transfer_contacts (EBook *source_book, process->done_cb = NULL; e_load_book_source_async ( - destination, parent_window, NULL, + destination, window, NULL, (GAsyncReadyCallback) book_loaded_cb, process); } diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h index e1fd43fdf3..45c7d40b79 100644 --- a/addressbook/gui/widgets/eab-gui-util.h +++ b/addressbook/gui/widgets/eab-gui-util.h @@ -26,22 +26,25 @@ #include <gtk/gtk.h> #include <libebook/e-book.h> +#include "e-util/e-alert-sink.h" G_BEGIN_DECLS -void eab_error_dialog (const gchar *msg, +void eab_error_dialog (EAlertSink *alert_sink, + const gchar *msg, const GError *error); void eab_load_error_dialog (GtkWidget *parent, + EAlertSink *alert_sink, ESource *source, const GError *error); -void eab_search_result_dialog (GtkWidget *parent, +void eab_search_result_dialog (EAlertSink *alert_sink, EBookViewStatus status, const gchar *error_msg); gint eab_prompt_save_dialog (GtkWindow *parent); void eab_transfer_contacts (EBook *source_book, GList *contacts, /* adopted */ gboolean delete_from_source, - GtkWindow *parent_window); + EAlertSink *alert_sink); gchar * eab_suggest_filename (GList *contact_list); ESource * eab_select_source (ESource *except_source, const gchar *title, diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c index 097e6128d5..9228905323 100644 --- a/modules/addressbook/e-book-shell-view-private.c +++ b/modules/addressbook/e-book-shell-view-private.c @@ -197,8 +197,15 @@ book_shell_view_loaded_cb (ESource *source, e_addressbook_model_set_book (model, book); e_addressbook_model_force_folder_bar_message (model); - } else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - eab_load_error_dialog (NULL /* XXX */, source, error); + } else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + EShellView *shell_view; + EAlertSink *alert_sink; + + shell_view = e_addressbook_view_get_shell_view (view); + alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); + + eab_load_error_dialog (NULL, alert_sink, source, error); + } if (error != NULL) g_error_free (error); diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 81ab858186..45bb5a37fb 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -161,13 +161,11 @@ cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; const gchar *message; shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || @@ -188,16 +186,14 @@ cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, return; case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)), "calendar:prompt-no-contents-offline-calendar", NULL); /* fall through */ default: if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)), "calendar:failed-open-calendar", error->message, NULL); } @@ -226,7 +222,6 @@ cal_shell_sidebar_default_loaded_cb (ESource *source, EShellSidebar *shell_sidebar) { ECalShellSidebarPrivate *priv; - EShellWindow *shell_window; EShellView *shell_view; ECal *client; GError *error = NULL; @@ -234,7 +229,6 @@ cal_shell_sidebar_default_loaded_cb (ESource *source, priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); client = e_load_cal_source_finish (source, result, &error); @@ -243,8 +237,7 @@ cal_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } else if (error != NULL) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)), "calendar:failed-open-calendar", error->message, NULL); g_error_free (error); diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 14d4b36e11..c22cff35dc 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -169,13 +169,11 @@ memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; const gchar *message; shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || @@ -196,16 +194,14 @@ memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, return; case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:prompt-no-contents-offline-memos", NULL); /* fall through */ default: if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:failed-open-memos", error->message, NULL); } @@ -234,7 +230,6 @@ memo_shell_sidebar_default_loaded_cb (ESource *source, EShellSidebar *shell_sidebar) { EMemoShellSidebarPrivate *priv; - EShellWindow *shell_window; EShellView *shell_view; ECal *client; GError *error = NULL; @@ -242,7 +237,6 @@ memo_shell_sidebar_default_loaded_cb (ESource *source, priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); client = e_load_cal_source_finish (source, result, &error); @@ -251,8 +245,7 @@ memo_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } else if (error != NULL) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:failed-open-memos", error->message, NULL); g_error_free (error); diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 99bc67f8ad..a688da41cd 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -169,13 +169,11 @@ task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; const gchar *message; shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || @@ -196,16 +194,14 @@ task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, return; case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:prompt-no-contents-offline-tasks", NULL); /* fall through */ default: if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:failed-open-tasks", error->message, NULL); } @@ -234,7 +230,6 @@ task_shell_sidebar_default_loaded_cb (ESource *source, EShellSidebar *shell_sidebar) { ETaskShellSidebarPrivate *priv; - EShellWindow *shell_window; EShellView *shell_view; ECal *client; GError *error = NULL; @@ -242,7 +237,6 @@ task_shell_sidebar_default_loaded_cb (ESource *source, priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_window = e_shell_view_get_shell_window (shell_view); client = e_load_cal_source_finish (source, result, &error); @@ -251,8 +245,7 @@ task_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } else if (error != NULL) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:failed-open-tasks", error->message, NULL); g_error_free (error); |