diff options
-rw-r--r-- | doc/reference/shell/eshell-sections.txt | 1 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-shell.sgml | 9 | ||||
-rw-r--r-- | modules/offline-alert/evolution-offline-alert.c | 16 | ||||
-rw-r--r-- | shell/e-shell.c | 66 | ||||
-rw-r--r-- | shell/e-shell.h | 3 |
5 files changed, 81 insertions, 14 deletions
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index 444efb9e8c..81ff256188 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -12,6 +12,7 @@ e_shell_get_shell_settings e_shell_get_gconf_client e_shell_create_shell_window e_shell_handle_uris +e_shell_submit_alert e_shell_watch_window e_shell_get_watched_windows e_shell_get_active_window diff --git a/doc/reference/shell/tmpl/e-shell.sgml b/doc/reference/shell/tmpl/e-shell.sgml index 0afd89d53b..2badec4d7d 100644 --- a/doc/reference/shell/tmpl/e-shell.sgml +++ b/doc/reference/shell/tmpl/e-shell.sgml @@ -225,6 +225,15 @@ EShell @Returns: +<!-- ##### FUNCTION e_shell_submit_alert ##### --> +<para> + +</para> + +@shell: +@alert: + + <!-- ##### FUNCTION e_shell_watch_window ##### --> <para> diff --git a/modules/offline-alert/evolution-offline-alert.c b/modules/offline-alert/evolution-offline-alert.c index 74a63bf697..ad6cd3607c 100644 --- a/modules/offline-alert/evolution-offline-alert.c +++ b/modules/offline-alert/evolution-offline-alert.c @@ -76,8 +76,6 @@ offline_alert_network_available_cb (EShell *shell, GParamSpec *pspec, EOfflineAlert *extension) { - GList *list, *iter; - if (e_shell_get_network_available (shell)) return; @@ -88,17 +86,7 @@ offline_alert_network_available_cb (EShell *shell, g_object_add_weak_pointer ( G_OBJECT (extension->alert), &extension->alert); - /* Broadcast the alert to all EShellWindows. */ - list = e_shell_get_watched_windows (shell); - for (iter = list; iter != NULL; iter = g_list_next (iter)) { - GtkWidget *window = iter->data; - - if (!E_IS_SHELL_WINDOW (window)) - continue; - - e_alert_sink_submit_alert ( - E_ALERT_SINK (window), extension->alert); - } + e_shell_submit_alert (shell, extension->alert); g_object_unref (extension->alert); } @@ -149,7 +137,7 @@ offline_alert_window_created_cb (EShell *shell, g_object_add_weak_pointer ( G_OBJECT (extension->alert), &extension->alert); - e_alert_sink_submit_alert (E_ALERT_SINK (window), extension->alert); + e_shell_submit_alert (shell, extension->alert); g_object_unref (extension->alert); } diff --git a/shell/e-shell.c b/shell/e-shell.c index b52d77186b..b1891ce3b8 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -47,6 +47,7 @@ ((obj), E_TYPE_SHELL, EShellPrivate)) struct _EShellPrivate { + GQueue alerts; GList *watched_windows; EShellSettings *settings; GConfClient *gconf_client; @@ -133,6 +134,19 @@ shell_parse_debug_string (EShell *shell) } static void +shell_alert_response_cb (EShell *shell, + gint response_id, + EAlert *alert) +{ + g_signal_handlers_disconnect_by_func ( + alert, shell_alert_response_cb, shell); + + g_queue_remove (&shell->priv->alerts, alert); + + g_object_unref (alert); +} + +static void shell_notify_online_cb (EShell *shell) { gboolean online; @@ -623,9 +637,16 @@ static void shell_dispose (GObject *object) { EShellPrivate *priv; + EAlert *alert; priv = E_SHELL_GET_PRIVATE (object); + while ((alert = g_queue_pop_head (&priv->alerts)) != NULL) { + g_signal_handlers_disconnect_by_func ( + alert, shell_alert_response_cb, object); + g_object_unref (alert); + } + if (priv->startup_view != NULL) { g_free (priv->startup_view); priv->startup_view = NULL; @@ -1156,6 +1177,8 @@ e_shell_init (EShell *shell) backends_by_name = g_hash_table_new (g_str_hash, g_str_equal); backends_by_scheme = g_hash_table_new (g_str_hash, g_str_equal); + g_queue_init (&shell->priv->alerts); + shell->priv->settings = g_object_new (E_TYPE_SHELL_SETTINGS, NULL); shell->priv->gconf_client = gconf_client_get_default (); shell->priv->preferences_window = e_preferences_window_new (shell); @@ -1432,6 +1455,7 @@ e_shell_create_shell_window (EShell *shell, GtkWidget *shell_window; UniqueMessageData *data; UniqueApp *app; + GList *link; g_return_val_if_fail (E_IS_SHELL (shell), NULL); @@ -1464,6 +1488,15 @@ e_shell_create_shell_window (EShell *shell, shell->priv->safe_mode, shell->priv->geometry); + /* Submit any outstanding alerts. */ + link = g_queue_peek_head_link (&shell->priv->alerts); + while (link != NULL) { + e_alert_sink_submit_alert ( + E_ALERT_SINK (shell_window), + E_ALERT (link->data)); + link = g_list_next (link); + } + /* Clear the first-time-only options. */ shell->priv->safe_mode = FALSE; g_free (shell->priv->geometry); @@ -1565,6 +1598,39 @@ unique: /* Send a message to the other Evolution process. */ } /** + * e_shell_submit_alert: + * @shell: an #EShell + * @alert: an #EAlert + * + * Broadcasts @alert to all #EShellWindow<!-- -->s. This should only + * be used for application-wide alerts such as a network outage. Submit + * view-specific alerts to the appropriate #EShellContent instance. + **/ +void +e_shell_submit_alert (EShell *shell, + EAlert *alert) +{ + GList *list, *iter; + + g_return_if_fail (E_IS_SHELL (shell)); + g_return_if_fail (E_IS_ALERT (alert)); + + g_queue_push_tail (&shell->priv->alerts, g_object_ref (alert)); + + g_signal_connect_swapped ( + alert, "response", + G_CALLBACK (shell_alert_response_cb), shell); + + list = e_shell_get_watched_windows (shell); + + /* Submit the alert to all available EShellWindows. */ + for (iter = list; iter != NULL; iter = g_list_next (iter)) + if (E_IS_SHELL_WINDOW (iter->data)) + e_alert_sink_submit_alert ( + E_ALERT_SINK (iter->data), alert); +} + +/** * e_shell_watch_window: * @shell: an #EShell * @window: a #GtkWindow diff --git a/shell/e-shell.h b/shell/e-shell.h index 3f037ba2d6..22aef9252f 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -26,6 +26,7 @@ #include <gconf/gconf-client.h> #include <e-util/e-activity.h> +#include <e-util/e-alert.h> #include <shell/e-shell-common.h> #include <shell/e-shell-backend.h> @@ -128,6 +129,8 @@ GtkWidget * e_shell_create_shell_window (EShell *shell, guint e_shell_handle_uris (EShell *shell, gchar **uris, gboolean do_import); +void e_shell_submit_alert (EShell *shell, + EAlert *alert); void e_shell_watch_window (EShell *shell, GtkWindow *window); GList * e_shell_get_watched_windows (EShell *shell); |