diff options
-rw-r--r-- | calendar/calendar.error.xml | 8 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-sidebar.c | 27 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-sidebar.c | 49 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-sidebar.c | 49 | ||||
-rw-r--r-- | widgets/misc/e-alert-bar.c | 32 |
5 files changed, 85 insertions, 80 deletions
diff --git a/calendar/calendar.error.xml b/calendar/calendar.error.xml index 3d1f2c94a5..3d7d657f9d 100644 --- a/calendar/calendar.error.xml +++ b/calendar/calendar.error.xml @@ -289,6 +289,14 @@ <button stock ="gtk-ok" response="GTK_RESPONSE_YES"/> </error> + <error id="backend-error" type="error" default="GTK_RESPONSE_YES"> + <!-- Translators: {0} is replaced with a group name, like CalDAV, Google, or such; + {1} is replaced with a calendar/task/memo list name, where the error happened --> + <_primary>Error on {0}: {1}</_primary> + <secondary>{2}</secondary> + <button stock ="gtk-ok" response="GTK_RESPONSE_YES"/> + </error> + <error id="server-version" type="warning"> <_primary>Some features may not work properly with your current server.</_primary> <_secondary>You are connecting to an unsupported GroupWise server and may encounter problems using Evolution. For best results, the server should be upgraded to a supported version.</_secondary> diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 1e291989cf..81ab858186 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -111,7 +111,6 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; GHashTable *client_table; ESource *source; @@ -121,7 +120,6 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, 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); source = e_cal_get_source (client); uid = e_source_peek_uid (source); @@ -131,8 +129,7 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, g_hash_table_remove (client_table, uid); cal_shell_sidebar_emit_status_message (cal_shell_sidebar, 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:calendar-crashed", NULL); g_object_unref (source); @@ -144,36 +141,18 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; ESourceGroup *source_group; ESource *source; - GtkWidget *dialog; 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); source = e_cal_get_source (client); source_group = e_source_peek_group (source); - /* Translators: This string is displayed in a message dialog when - * our connection to the calendar service detects an - * out-of-band error. The first string is a name of - * group in which calendar for the source of error is - * defined and the second string is name of calendar - * and the third string is the error message. */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (shell_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error on %s: %s\n%s"), - e_source_group_peek_name (source_group), - e_source_peek_name (source), message); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - + e_alert_submit (E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)), + "calendar:backend-error", e_source_group_peek_name (source_group), e_source_peek_name (source), message, NULL); } static void diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 5bc5dfd132..14d4b36e11 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -101,12 +101,24 @@ memo_shell_sidebar_emit_status_message (EMemoShellSidebar *memo_shell_sidebar, g_signal_emit (memo_shell_sidebar, signal_id, 0, status_message, -1.0); } +static EAlertSink * +get_alert_sink (EShellView *shell_view) +{ + EShellWindow *shell_window; + + shell_window = e_shell_view_get_shell_window (shell_view); + + if (g_strcmp0 (e_shell_window_get_active_view (shell_window), "calendar") == 0) + shell_view = e_shell_window_peek_shell_view (shell_window, "calendar"); + + return E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); +} + static void memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; GHashTable *client_table; ESource *source; @@ -116,7 +128,6 @@ memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, 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); source = e_cal_get_source (client); uid = e_source_peek_uid (source); @@ -126,8 +137,7 @@ memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, g_hash_table_remove (client_table, uid); memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL); - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:memos-crashed", NULL); g_object_unref (source); @@ -139,35 +149,18 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; - GtkWidget *dialog; - const gchar *uri; - gchar *uri_no_passwd; + ESourceGroup *source_group; + ESource *source; 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); - uri = e_cal_get_uri (client); - uri_no_passwd = get_uri_without_password (uri); - - /* Translators: This string is displayed in a message dialog when - * our connection to the calendar service detects an - * out-of-band error. The first string is a URI for - * the source of the error, the second string is the - * error message. */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (shell_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error on %s\n%s"), - uri_no_passwd, message); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_no_passwd); + source = e_cal_get_source (client); + source_group = e_source_peek_group (source); + + e_alert_submit (get_alert_sink (shell_view), + "calendar:backend-error", e_source_group_peek_name (source_group), e_source_peek_name (source), message, NULL); } static void diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 52887faf03..99bc67f8ad 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -101,12 +101,24 @@ task_shell_sidebar_emit_status_message (ETaskShellSidebar *task_shell_sidebar, g_signal_emit (task_shell_sidebar, signal_id, 0, status_message, -1.0); } +static EAlertSink * +get_alert_sink (EShellView *shell_view) +{ + EShellWindow *shell_window; + + shell_window = e_shell_view_get_shell_window (shell_view); + + if (g_strcmp0 (e_shell_window_get_active_view (shell_window), "calendar") == 0) + shell_view = e_shell_window_peek_shell_view (shell_window, "calendar"); + + return E_ALERT_SINK (e_shell_view_get_shell_content (shell_view)); +} + static void task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; GHashTable *client_table; ESource *source; @@ -116,7 +128,6 @@ task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, 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); source = e_cal_get_source (client); uid = e_source_peek_uid (source); @@ -126,8 +137,7 @@ task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, g_hash_table_remove (client_table, uid); task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL); - e_alert_run_dialog_for_args ( - GTK_WINDOW (shell_window), + e_alert_submit (get_alert_sink (shell_view), "calendar:tasks-crashed", NULL); g_object_unref (source); @@ -139,35 +149,18 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar, ECal *client) { EShellView *shell_view; - EShellWindow *shell_window; EShellSidebar *shell_sidebar; - GtkWidget *dialog; - const gchar *uri; - gchar *uri_no_passwd; + ESourceGroup *source_group; + ESource *source; 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); - uri = e_cal_get_uri (client); - uri_no_passwd = get_uri_without_password (uri); - - /* Translators: This string is displayed in a message dialog when - * our connection to the calendar service detects an - * out-of-band error. The first string is a URI for - * the source of the error, the second string is the - * error message. */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (shell_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error on %s\n%s"), - uri_no_passwd, message); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_no_passwd); + source = e_cal_get_source (client); + source_group = e_source_peek_group (source); + + e_alert_submit (get_alert_sink (shell_view), + "calendar:backend-error", e_source_group_peek_name (source_group), e_source_peek_name (source), message, NULL); } static void diff --git a/widgets/misc/e-alert-bar.c b/widgets/misc/e-alert-bar.c index cae1bc0172..c20a74e4d0 100644 --- a/widgets/misc/e-alert-bar.c +++ b/widgets/misc/e-alert-bar.c @@ -243,13 +243,45 @@ e_alert_bar_new (void) return g_object_new (E_TYPE_ALERT_BAR, NULL); } +struct DuplicateData +{ + gboolean found; + EAlert *looking_for; +}; + +static void +find_duplicate_cb (gpointer data, gpointer user_data) +{ + EAlert *alert = data; + struct DuplicateData *dd = user_data; + + g_return_if_fail (alert != NULL); + g_return_if_fail (dd != NULL); + g_return_if_fail (dd->looking_for != NULL); + + dd->found = dd->found || ( + e_alert_get_message_type (alert) == e_alert_get_message_type (dd->looking_for) && + g_strcmp0 (e_alert_get_primary_text (alert), e_alert_get_primary_text (dd->looking_for)) == 0 && + g_strcmp0 (e_alert_get_secondary_text (alert), e_alert_get_secondary_text (dd->looking_for)) == 0); +} + void e_alert_bar_add_alert (EAlertBar *alert_bar, EAlert *alert) { + struct DuplicateData dd; + g_return_if_fail (E_IS_ALERT_BAR (alert_bar)); g_return_if_fail (E_IS_ALERT (alert)); + dd.found = FALSE; + dd.looking_for = alert; + + g_queue_foreach (&alert_bar->priv->alerts, find_duplicate_cb, &dd); + + if (dd.found) + return; + g_signal_connect ( alert, "response", G_CALLBACK (alert_bar_response_cb), alert_bar); |