Add e_shell_submit_alert().
An easy way to broadcast application-wide alerts to shell windows. These alerts will persist in all current and future shell windows until responded to (either programmatically or by the user).
This commit is contained in:
committed by
Rodrigo Moya
parent
6217c41106
commit
fdf1c024b5
@ -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
|
||||
|
||||
@ -225,6 +225,15 @@ EShell
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION e_shell_submit_alert ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@shell:
|
||||
@alert:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION e_shell_watch_window ##### -->
|
||||
<para>
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
((obj), E_TYPE_SHELL, EShellPrivate))
|
||||
|
||||
struct _EShellPrivate {
|
||||
GQueue alerts;
|
||||
GList *watched_windows;
|
||||
EShellSettings *settings;
|
||||
GConfClient *gconf_client;
|
||||
@ -132,6 +133,19 @@ shell_parse_debug_string (EShell *shell)
|
||||
e_shell_settings_enable_debug (shell->priv->settings);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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);
|
||||
@ -1564,6 +1597,39 @@ unique: /* Send a message to the other Evolution process. */
|
||||
return g_strv_length (uris);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user