aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell.c66
-rw-r--r--shell/e-shell.h3
2 files changed, 69 insertions, 0 deletions
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);