[evolution-data-server] EDataFactory: Add a "backend-created" signal.



commit 9c4d563646efa3d447545213bfa6ba808410f119
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Nov 12 09:31:16 2012 -0500

    EDataFactory: Add a "backend-created" signal.
    
    Allows EDataFactory extensions to catch newly-created backends and
    perform additional initialization on it.
    
    The use case I have in mind is to move all the GOA initialization in
    EDataBookFactory to the gnome-online-accounts module as an extension.
    
    Note this uses one of the reserved pointer slots in EDataFactoryClass
    and therefore does not break ABI.

 libebackend/e-data-factory.c |   32 ++++++++++++++++++++++++++++++++
 libebackend/e-data-factory.h |    6 +++++-
 2 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 99ce551..efaac1f 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -47,6 +47,13 @@ struct _EDataFactoryPrivate {
 	GHashTable *backend_factories;
 };
 
+enum {
+	BACKEND_CREATED,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
 G_DEFINE_ABSTRACT_TYPE (
 	EDataFactory, e_data_factory, E_TYPE_DBUS_SERVER)
 
@@ -166,6 +173,27 @@ e_data_factory_class_init (EDataFactoryClass *class)
 	object_class->constructed = data_factory_constructed;
 
 	class->backend_factory_type = E_TYPE_BACKEND_FACTORY;
+
+	/**
+	 * EDataFactory::backend-created:
+	 * @data_factory: the #EDataFactory which emitted the signal
+	 * @backend: the newly-created #EBackend
+	 *
+	 * Emitted when a new #EBackend is instantiated by way of
+	 * e_data_factory_ref_backend().  Extensions can connect to this
+	 * signal to perform additional initialization on the #EBackend.
+	 *
+	 * Since: 3.8
+	 **/
+	signals[BACKEND_CREATED] = g_signal_new (
+		"backend-created",
+		G_OBJECT_CLASS_TYPE (object_class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EDataFactoryClass, backend_created),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__OBJECT,
+		G_TYPE_NONE, 1,
+		E_TYPE_BACKEND);
 }
 
 static void
@@ -253,6 +281,10 @@ e_data_factory_ref_backend (EDataFactory *data_factory,
 
 	g_object_unref (backend_factory);
 
+	if (backend != NULL)
+		g_signal_emit (
+			data_factory, signals[BACKEND_CREATED], 0, backend);
+
 exit:
 	g_mutex_unlock (&data_factory->priv->mutex);
 
diff --git a/libebackend/e-data-factory.h b/libebackend/e-data-factory.h
index 3aefbf6..2c8ee2a 100644
--- a/libebackend/e-data-factory.h
+++ b/libebackend/e-data-factory.h
@@ -69,7 +69,11 @@ struct _EDataFactoryClass {
 
 	GType backend_factory_type;
 
-	gpointer reserved[16];
+	/* Signals */
+	void		(*backend_created)	(EDataFactory *data_factory,
+						 EBackend *backend);
+
+	gpointer reserved[15];
 };
 
 GType		e_data_factory_get_type		(void) G_GNUC_CONST;



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