[evolution] EShellBackend: Start tracking activities



commit 02452930e7df21bd1f09271d361e2067a3fb1b7b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Sep 29 22:51:08 2010 -0400

    EShellBackend: Start tracking activities
    
    EShellBackend now keeps an internal queue of live EActivity objects
    passed to it via e_shell_backend_add_activity().  This will eventually
    replace "mail_msg_active_table" in mail-mt.c and be used to coordinate
    shutdown for all shell backends.
    
    But first I have to eliminate mail_msg_wait().

 shell/e-shell-backend.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c
index c0fd14a..aa95a78 100644
--- a/shell/e-shell-backend.c
+++ b/shell/e-shell-backend.c
@@ -49,6 +49,9 @@ struct _EShellBackendPrivate {
 	 * would leak its EShellBackend reference. */
 	EShellViewClass *shell_view_class;
 
+	/* This tracks what the backend is busy doing. */
+	GQueue *activities;
+
 	gchar *config_dir;
 	gchar *data_dir;
 
@@ -57,6 +60,7 @@ struct _EShellBackendPrivate {
 
 enum {
 	ACTIVITY_ADDED,
+	ACTIVITY_REMOVED,
 	LAST_SIGNAL
 };
 
@@ -64,6 +68,14 @@ static guint signals[LAST_SIGNAL];
 
 G_DEFINE_ABSTRACT_TYPE (EShellBackend, e_shell_backend, E_TYPE_EXTENSION)
 
+static void
+shell_backend_activity_finalized_cb (EShellBackend *shell_backend,
+                                     EActivity *finalized_activity)
+{
+	g_queue_remove (shell_backend->priv->activities, finalized_activity);
+	g_object_unref (shell_backend);
+}
+
 static GObject *
 shell_backend_constructor (GType type,
                            guint n_construct_properties,
@@ -113,6 +125,9 @@ shell_backend_finalize (GObject *object)
 
 	priv = E_SHELL_BACKEND_GET_PRIVATE (object);
 
+	g_warn_if_fail (g_queue_is_empty (priv->activities));
+	g_queue_free (priv->activities);
+
 	g_free (priv->config_dir);
 	g_free (priv->data_dir);
 
@@ -200,6 +215,7 @@ static void
 e_shell_backend_init (EShellBackend *shell_backend)
 {
 	shell_backend->priv = E_SHELL_BACKEND_GET_PRIVATE (shell_backend);
+	shell_backend->priv->activities = g_queue_new ();
 }
 
 /**
@@ -304,6 +320,15 @@ e_shell_backend_add_activity (EShellBackend *shell_backend,
 	g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend));
 	g_return_if_fail (E_IS_ACTIVITY (activity));
 
+	g_queue_push_tail (shell_backend->priv->activities, activity);
+
+	/* We reference the backend on every activity to
+	 * guarantee the backend outlives the activity. */
+	g_object_weak_ref (
+		G_OBJECT (activity), (GWeakNotify)
+		shell_backend_activity_finalized_cb,
+		g_object_ref (shell_backend));
+
 	g_signal_emit (shell_backend, signals[ACTIVITY_ADDED], 0, activity);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]