From 555668c928408f0b27cb22a8225b9d3b55a5b57d Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 26 Apr 2000 01:08:06 +0000 Subject: Renamed from backend_destroy_cb. Now we use it for the "last_client_gone" 2000-04-25 Federico Mena Quintero * pcs/cal-factory.c (backend_last_client_gone_cb): Renamed from backend_destroy_cb. Now we use it for the "last_client_gone" signal from the backend. Also, unref the backend to destroy it. (add_backend): Connect to the "last_client_gone" signal of the backend. (cal_factory_get_n_backends): New function to query the number of running backends. * pcs/cal-backend.c (cal_backend_class_init): Register the new "last_client_gone" signal. It is emitted when the last Cal client goes away. It is used to notify the factory when a backend may be safely destroyed. (cal_destroy_cb): Emit the "last_client_gone" signal when the last client disconnects from the backend. svn path=/trunk/; revision=2619 --- calendar/pcs/cal-factory.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'calendar/pcs/cal-factory.c') diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c index 63f6eb22c6..b89d5c450e 100644 --- a/calendar/pcs/cal-factory.c +++ b/calendar/pcs/cal-factory.c @@ -265,9 +265,9 @@ lookup_backend (CalFactory *factory, GnomeVFSURI *uri) return backend; } -/* Callback used when a backend is destroyed */ +/* Callback used when a backend loses its last connected client */ static void -backend_destroy_cb (GtkObject *object, gpointer data) +backend_last_client_gone_cb (GtkObject *object, gpointer data) { CalFactory *factory; CalFactoryPrivate *priv; @@ -294,6 +294,8 @@ backend_destroy_cb (GtkObject *object, gpointer data) g_hash_table_remove (priv->backends, orig_uri); gnome_vfs_uri_unref (orig_uri); + gtk_object_unref (GTK_OBJECT (backend)); + /* Notify upstream if there are no more backends */ if (g_hash_table_size (priv->backends) == 0) @@ -311,8 +313,8 @@ add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend) gnome_vfs_uri_ref (uri); g_hash_table_insert (priv->backends, uri, backend); - gtk_signal_connect (GTK_OBJECT (backend), "destroy", - GTK_SIGNAL_FUNC (backend_destroy_cb), + gtk_signal_connect (GTK_OBJECT (backend), "last_client_gone", + GTK_SIGNAL_FUNC (backend_last_client_gone_cb), factory); } @@ -692,8 +694,38 @@ cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Liste queue_load_create_job (factory, uri, listener, load_fn); } +/** + * cal_factory_create: + * @factory: A calendar factory. + * @uri: URI of calendar to create. + * @listener: Listener for notification of the create result. + * + * Initiates a create request in a calendar factory. A calendar will be created + * asynchronously and the result code will be reported to the specified + * listener. + **/ void cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener) { queue_load_create_job (factory, uri, listener, create_fn); } + +/** + * cal_factory_get_n_backends: + * @factory: A calendar factory. + * + * Queries the number of running calendar backends in a calendar factory. + * + * Return value: Number of running backends. + **/ +int +cal_factory_get_n_backends (CalFactory *factory) +{ + CalFactoryPrivate *priv; + + g_return_val_if_fail (factory != NULL, -1); + g_return_val_if_fail (IS_CAL_FACTORY (factory), -1); + + priv = factory->priv; + return g_hash_table_size (priv->backends); +} -- cgit