aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-02-13 22:52:28 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-02-17 07:57:09 +0800
commit208d779b00a410dc1f1734ad1c8b3ccdc53db3d3 (patch)
tree691d9a9d5ac67d6e3508ad6f9081b650c70cce16 /shell
parenta26c98ad5ae39d2b60eb727eea81a9eab1dda01a (diff)
downloadgsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar.gz
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar.bz2
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar.lz
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar.xz
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.tar.zst
gsoc2013-evolution-208d779b00a410dc1f1734ad1c8b3ccdc53db3d3.zip
EShell: Add a read-only "client-cache" property.
Give EShell its own EClientCache. This should be used throughout Evolution, wherever an EClient is needed. New functions: e_shell_get_client_cache()
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell.c86
-rw-r--r--shell/e-shell.h1
2 files changed, 81 insertions, 6 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index f938f45e73..00bcd61226 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -49,6 +49,7 @@ struct _EShellPrivate {
GQueue alerts;
EShellSettings *settings;
ESourceRegistry *registry;
+ EClientCache *client_cache;
GtkWidget *preferences_window;
/* Shell Backends */
@@ -66,6 +67,8 @@ struct _EShellPrivate {
guint inhibit_cookie;
+ gulong backend_died_handler_id;
+
guint auto_reconnect : 1;
guint express_mode : 1;
guint meego_mode : 1;
@@ -80,6 +83,7 @@ struct _EShellPrivate {
enum {
PROP_0,
+ PROP_CLIENT_CACHE,
PROP_EXPRESS_MODE,
PROP_MEEGO_MODE,
PROP_SMALL_SCREEN_MODE,
@@ -518,6 +522,17 @@ shell_process_backend (EShellBackend *shell_backend,
}
static void
+shell_backend_died_cb (EClientCache *client_cache,
+ EClient *client,
+ EAlert *alert,
+ EShell *shell)
+{
+ /* Backend crashes are quite serious.
+ * Post the alert to all shell views. */
+ e_shell_submit_alert (shell, alert);
+}
+
+static void
shell_sm_quit_cb (EShell *shell,
gpointer user_data)
{
@@ -623,6 +638,12 @@ shell_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_CLIENT_CACHE:
+ g_value_set_object (
+ value, e_shell_get_client_cache (
+ E_SHELL (object)));
+ return;
+
case PROP_EXPRESS_MODE:
g_value_set_boolean (
value, e_shell_get_express_mode (
@@ -695,6 +716,13 @@ shell_dispose (GObject *object)
g_object_unref (alert);
}
+ if (priv->backend_died_handler_id > 0) {
+ g_signal_handler_disconnect (
+ priv->client_cache,
+ priv->backend_died_handler_id);
+ priv->backend_died_handler_id = 0;
+ }
+
if (priv->startup_view != NULL) {
g_free (priv->startup_view);
priv->startup_view = NULL;
@@ -710,6 +738,11 @@ shell_dispose (GObject *object)
priv->registry = NULL;
}
+ if (priv->client_cache != NULL) {
+ g_object_unref (priv->client_cache);
+ priv->client_cache = NULL;
+ }
+
if (priv->preferences_window != NULL) {
g_object_unref (priv->preferences_window);
priv->preferences_window = NULL;
@@ -839,19 +872,29 @@ shell_initable_init (GInitable *initable,
GError **error)
{
GApplication *application = G_APPLICATION (initable);
- EShellPrivate *priv;
-
- priv = E_SHELL_GET_PRIVATE (initable);
+ EShell *shell = E_SHELL (initable);
+ ESourceRegistry *registry;
+ gulong handler_id;
shell_add_actions (application);
- priv->registry = e_source_registry_new_sync (cancellable, error);
- if (priv->registry == NULL)
+ if (!g_application_register (application, cancellable, error))
return FALSE;
- if (!g_application_register (application, cancellable, error))
+ registry = e_source_registry_new_sync (cancellable, error);
+ if (registry == NULL)
return FALSE;
+ shell->priv->registry = g_object_ref (registry);
+ shell->priv->client_cache = e_client_cache_new (registry);
+
+ handler_id = g_signal_connect (
+ shell->priv->client_cache, "backend-died",
+ G_CALLBACK (shell_backend_died_cb), shell);
+ shell->priv->backend_died_handler_id = handler_id;
+
+ g_object_unref (registry);
+
return TRUE;
}
@@ -879,6 +922,21 @@ e_shell_class_init (EShellClass *class)
gtk_application_class->window_added = shell_window_added;
/**
+ * EShell:client-cache:
+ *
+ * Shared #EClient instances.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_CLIENT_CACHE,
+ g_param_spec_object (
+ "client-cache",
+ "Client Cache",
+ "Shared EClient instances",
+ E_TYPE_CLIENT_CACHE,
+ G_PARAM_READABLE));
+
+ /**
* EShell:express-mode
*
* Express mode alters Evolution's user interface to be more
@@ -1372,6 +1430,22 @@ e_shell_get_backend_by_scheme (EShell *shell,
}
/**
+ * e_shell_get_client_cache:
+ * @shell: an #EShell
+ *
+ * Returns the #EClientCache instance for @shell.
+ *
+ * Returns: the #EClientCache instance for @shell
+ **/
+EClientCache *
+e_shell_get_client_cache (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->client_cache;
+}
+
+/**
* e_shell_get_shell_settings:
* @shell: an #EShell
*
diff --git a/shell/e-shell.h b/shell/e-shell.h
index a0ef1f6bae..bdbbf0942f 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -116,6 +116,7 @@ EShellBackend * e_shell_get_backend_by_name (EShell *shell,
const gchar *name);
EShellBackend * e_shell_get_backend_by_scheme (EShell *shell,
const gchar *scheme);
+EClientCache * e_shell_get_client_cache (EShell *shell);
EShellSettings *e_shell_get_shell_settings (EShell *shell);
ESourceRegistry *
e_shell_get_registry (EShell *shell);