aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-04-26 09:08:06 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-04-26 09:08:06 +0800
commit555668c928408f0b27cb22a8225b9d3b55a5b57d (patch)
treef32db539856c6c0737da03e124b39f365b5dcb7f /calendar
parent23bcb0bbd8fefb952d751951b2bf3b19717e707d (diff)
downloadgsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar.gz
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar.bz2
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar.lz
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar.xz
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.tar.zst
gsoc2013-evolution-555668c928408f0b27cb22a8225b9d3b55a5b57d.zip
Renamed from backend_destroy_cb. Now we use it for the "last_client_gone"
2000-04-25 Federico Mena Quintero <federico@helixcode.com> * 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
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog17
-rw-r--r--calendar/pcs/cal-backend.c29
-rw-r--r--calendar/pcs/cal-backend.h3
-rw-r--r--calendar/pcs/cal-factory.c40
-rw-r--r--calendar/pcs/cal-factory.h3
5 files changed, 82 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ec34110476..dee7f11841 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,20 @@
+2000-04-25 Federico Mena Quintero <federico@helixcode.com>
+
+ * 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.
+
2000-04-25 Seth Alves <alves@hungry.com>
* gui/e-day-view.c (e_day_view_find_event_from_ico): compare
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 4d0e659037..364a4670c6 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -61,12 +61,20 @@ typedef struct {
+/* Signal IDs */
+enum {
+ LAST_CLIENT_GONE,
+ LAST_SIGNAL
+};
+
static void cal_backend_class_init (CalBackendClass *class);
static void cal_backend_init (CalBackend *backend);
static void cal_backend_destroy (GtkObject *object);
static GtkObjectClass *parent_class;
+static guint cal_backend_signals[LAST_SIGNAL];
+
/**
@@ -112,6 +120,16 @@ cal_backend_class_init (CalBackendClass *class)
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
+ cal_backend_signals[LAST_CLIENT_GONE] =
+ gtk_signal_new ("last_client_gone",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalBackendClass, last_client_gone),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, cal_backend_signals, LAST_SIGNAL);
+
object_class->destroy = cal_backend_destroy;
}
@@ -128,7 +146,8 @@ cal_backend_init (CalBackend *backend)
priv->format = CAL_VCAL;
}
-static void save_to_vcal (CalBackend *backend, char *fname)
+static void
+save_to_vcal (CalBackend *backend, char *fname)
{
FILE *fp;
CalBackendPrivate *priv = backend->priv;
@@ -174,7 +193,6 @@ static void save_to_vcal (CalBackend *backend, char *fname)
cleanStrTbl ();
}
-
/* Saves a calendar */
static void
save (CalBackend *backend)
@@ -547,12 +565,11 @@ cal_destroy_cb (GtkObject *object, gpointer data)
priv->clients = g_list_remove_link (priv->clients, l);
g_list_free_1 (l);
- /* When all clients go away, the backend can go away, too. Commit
- * suicide here.
+ /* When all clients go away, notify the parent factory about it so that
+ * it may decide whether to kill the backend or not.
*/
-
if (!priv->clients)
- gtk_object_unref (GTK_OBJECT (backend));
+ gtk_signal_emit (GTK_OBJECT (backend), cal_backend_signals[LAST_CLIENT_GONE]);
}
/**
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index af487f7551..e5102bf8bc 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -55,6 +55,9 @@ struct _CalBackend {
struct _CalBackendClass {
GtkObjectClass parent_class;
+
+ /* Notification signals */
+ void (* last_client_gone) (CalBackend *backend);
};
typedef enum {
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);
+}
diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h
index 7100a35d69..85435e45ae 100644
--- a/calendar/pcs/cal-factory.h
+++ b/calendar/pcs/cal-factory.h
@@ -50,6 +50,7 @@ struct _CalFactory {
struct _CalFactoryClass {
BonoboObjectClass parent_class;
+ /* Notification signals */
void (* last_calendar_gone) (CalFactory *factory);
};
@@ -63,6 +64,8 @@ CalFactory *cal_factory_new (void);
void cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
void cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
+int cal_factory_get_n_backends (CalFactory *factory);
+
POA_Evolution_Calendar_CalFactory__epv *cal_factory_get_epv (void);