aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-17 02:42:43 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-19 00:32:36 +0800
commitb674a37a381d0328a7273bafa62d80203c8cdf70 (patch)
tree3d3982335580bb59c977fab4180704ca668f07b2
parent51ebf20237270a785af0aa0e614db42275a05c62 (diff)
downloadgsoc2013-evolution-b674a37a381d0328a7273bafa62d80203c8cdf70.tar.gz
gsoc2013-evolution-b674a37a381d0328a7273bafa62d80203c8cdf70.tar.zst
gsoc2013-evolution-b674a37a381d0328a7273bafa62d80203c8cdf70.zip
Add an EOfflineAlert module.
This module posts an alert to the first EShellWindow when starting offline, and also posts an alert when the network connection drops. We get frequent questions on the mailing list from users not realizing Evolution is starting in offline mode, so this is meant to help address that confusion.
-rw-r--r--configure.ac5
-rw-r--r--modules/Makefile.am1
-rw-r--r--modules/offline-alert/Makefile.am1
-rw-r--r--modules/offline-alert/evolution-offline-alert.c221
-rw-r--r--modules/offline-alert/evolution-offline-alert.error13
-rw-r--r--modules/offline-alert/evolution-offline-alert.error.xml2
-rw-r--r--po/POTFILES.in1
7 files changed, 241 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 75f034a91a..cf71456d2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1802,10 +1802,11 @@ modules/Makefile
modules/addressbook/Makefile
modules/calendar/Makefile
modules/mail/Makefile
-modules/mailto-handler/Makefile
-modules/network-manager/Makefile
modules/composer-autosave/Makefile
modules/connman/Makefile
+modules/mailto-handler/Makefile
+modules/network-manager/Makefile
+modules/offline-alert/Makefile
modules/plugin-lib/Makefile
modules/plugin-manager/Makefile
modules/plugin-mono/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index da2ccec6e0..ae95614c2a 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -24,6 +24,7 @@ SUBDIRS = \
mail \
composer-autosave \
mailto-handler \
+ offline-alert \
plugin-lib \
plugin-manager \
startup-wizard \
diff --git a/modules/offline-alert/Makefile.am b/modules/offline-alert/Makefile.am
index cdad615797..2979343869 100644
--- a/modules/offline-alert/Makefile.am
+++ b/modules/offline-alert/Makefile.am
@@ -3,6 +3,7 @@ module_LTLIBRARIES = libevolution-module-offline-alert.la
libevolution_module_offline_alert_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(top_srcdir) \
+ -I$(top_srcdir)/widgets \
-DG_LOG_DOMAIN=\"evolution-offline-alert\" \
$(GNOME_PLATFORM_CFLAGS)
diff --git a/modules/offline-alert/evolution-offline-alert.c b/modules/offline-alert/evolution-offline-alert.c
new file mode 100644
index 0000000000..8b1de84d6c
--- /dev/null
+++ b/modules/offline-alert/evolution-offline-alert.c
@@ -0,0 +1,221 @@
+/*
+ * evolution-offline-alert.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-window-actions.h>
+#include <e-util/e-alert-sink.h>
+#include <e-util/e-extension.h>
+
+/* Standard GObject macros */
+#define E_TYPE_OFFLINE_ALERT \
+ (e_offline_alert_get_type ())
+#define E_OFFLINE_ALERT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_OFFLINE_ALERT, EOfflineAlert))
+
+typedef struct _EOfflineAlert EOfflineAlert;
+typedef struct _EOfflineAlertClass EOfflineAlertClass;
+
+struct _EOfflineAlert {
+ EExtension parent;
+ gpointer alert; /* weak pointer */
+};
+
+struct _EOfflineAlertClass {
+ EExtensionClass parent_class;
+};
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_offline_alert_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (EOfflineAlert, e_offline_alert, E_TYPE_EXTENSION)
+
+static EShell *
+offline_alert_get_shell (EOfflineAlert *extension)
+{
+ EExtensible *extensible;
+
+ extensible = e_extension_get_extensible (E_EXTENSION (extension));
+
+ return E_SHELL (extensible);
+}
+
+static void
+offline_alert_online_cb (EShell *shell,
+ GParamSpec *pspec,
+ EOfflineAlert *extension)
+{
+ if (!e_shell_get_online (shell))
+ return;
+
+ if (extension->alert != NULL)
+ e_alert_response (extension->alert, GTK_RESPONSE_OK);
+}
+
+static void
+offline_alert_network_available_cb (EShell *shell,
+ GParamSpec *pspec,
+ EOfflineAlert *extension)
+{
+ GList *list, *iter;
+
+ if (e_shell_get_network_available (shell))
+ return;
+
+ g_return_if_fail (extension->alert == NULL);
+
+ extension->alert = e_alert_new ("offline-alert:no-network", NULL);
+
+ 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 (window, extension->alert);
+ }
+
+ g_object_unref (extension->alert);
+}
+
+static void
+offline_alert_window_created_cb (EShell *shell,
+ GtkWindow *window,
+ EOfflineAlert *extension)
+{
+ GtkAction *action;
+
+ if (!E_IS_SHELL_WINDOW (window))
+ return;
+
+ /* Connect these signals after we have the first EShellWindow
+ * to avoid false-positive signals during EShell initialization. */
+
+ g_signal_connect (
+ shell, "notify::online",
+ G_CALLBACK (offline_alert_online_cb), extension);
+
+ g_signal_connect (
+ shell, "notify::network-available",
+ G_CALLBACK (offline_alert_network_available_cb), extension);
+
+ g_signal_handlers_disconnect_by_func (
+ shell, offline_alert_window_created_cb, extension);
+
+ if (e_shell_get_online (shell))
+ return;
+
+ if (!e_shell_get_network_available (shell)) {
+ g_object_notify (G_OBJECT (shell), "network-available");
+ return;
+ }
+
+ g_return_if_fail (extension->alert == NULL);
+
+ /* This alert only shows at startup, not when the user
+ * chooses to work offline. That's why we only wanted
+ * the first EShellWindow. */
+
+ action = E_SHELL_WINDOW_ACTION_WORK_ONLINE (window);
+
+ extension->alert = e_alert_new ("offline-alert:offline", NULL);
+ e_alert_add_action (extension->alert, action, GTK_RESPONSE_NONE);
+
+ g_object_add_weak_pointer (
+ G_OBJECT (extension->alert), &extension->alert);
+
+ e_alert_sink_submit_alert (GTK_WIDGET (window), extension->alert);
+
+ g_object_unref (extension->alert);
+}
+
+static void
+offline_alert_dispose (GObject *object)
+{
+ EOfflineAlert *extension;
+
+ extension = E_OFFLINE_ALERT (object);
+
+ if (extension->alert != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (extension->alert), &extension->alert);
+ extension->alert = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_offline_alert_parent_class)->dispose (object);
+}
+
+static void
+offline_alert_constructed (GObject *object)
+{
+ EShell *shell;
+ EOfflineAlert *extension;
+
+ extension = E_OFFLINE_ALERT (object);
+ shell = offline_alert_get_shell (extension);
+
+ /* Watch for the first EShellWindow. */
+ g_signal_connect (
+ shell, "window-created",
+ G_CALLBACK (offline_alert_window_created_cb), extension);
+}
+
+static void
+e_offline_alert_class_init (EOfflineAlertClass *class)
+{
+ GObjectClass *object_class;
+ EExtensionClass *extension_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = offline_alert_dispose;
+ object_class->constructed = offline_alert_constructed;
+
+ extension_class = E_EXTENSION_CLASS (class);
+ extension_class->extensible_type = E_TYPE_SHELL;
+}
+
+static void
+e_offline_alert_class_finalize (EOfflineAlertClass *class)
+{
+}
+
+static void
+e_offline_alert_init (EOfflineAlert *extension)
+{
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+ e_offline_alert_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
diff --git a/modules/offline-alert/evolution-offline-alert.error b/modules/offline-alert/evolution-offline-alert.error
new file mode 100644
index 0000000000..13ba4ff238
--- /dev/null
+++ b/modules/offline-alert/evolution-offline-alert.error
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="offline-alert">
+ <error type="info" id="offline">
+ <primary>Evolution is currently offline.</primary>
+ <secondary>Click 'Work Online' to return to online mode.</secondary>
+ <button response="GTK_RESPONSE_OK" label="_Dismiss"></button>
+ </error>
+ <error type="info" id="no-network">
+ <primary>Evolution is currently offline due to a network outage.</primary>
+ <secondary>Evolution will return to online mode once a network connection is established.</secondary>
+ <button response="GTK_RESPONSE_OK" label="_Dismiss"></button>
+ </error>
+</error-list> \ No newline at end of file
diff --git a/modules/offline-alert/evolution-offline-alert.error.xml b/modules/offline-alert/evolution-offline-alert.error.xml
index 65a1ec7099..a6362da42e 100644
--- a/modules/offline-alert/evolution-offline-alert.error.xml
+++ b/modules/offline-alert/evolution-offline-alert.error.xml
@@ -7,7 +7,7 @@
</error>
<error id="no-network" type="info">
<_primary>Evolution is currently offline due to a network outage.</_primary>
- <_secondary>Evolution will return to online mode once a network connection is established.</secondary>
+ <_secondary>Evolution will return to online mode once a network connection is established.</_secondary>
<button _label="_Dismiss" response="GTK_RESPONSE_OK"/>
</error>
</error-list>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f75d48845b..852a27961f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -281,6 +281,7 @@ modules/mail/em-composer-prefs.c
modules/mail/em-mailer-prefs.c
modules/mailto-handler/apps-evolution-mail-prompts-checkdefault.schemas.in
modules/mailto-handler/evolution-mailto-handler.c
+modules/offline-alert/evolution-offline-alert.error.xml
modules/plugin-manager/evolution-plugin-manager.c
modules/plugin-python/example/org-gnome-hello-python-ui.xml
modules/plugin-python/example/org-gnome-hello-python.eplug.xml