diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-02-12 10:03:58 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 2000-02-12 10:03:58 +0800 |
commit | d2fe58c56857e9e4b2e37f87174da6956b0d985c (patch) | |
tree | e71df413e8a7862616755f64700b1dbbc513f9be /calendar/pcs/cal-factory.c | |
parent | 123f506198c535dcb073c1998fed37c25ad131f9 (diff) | |
download | gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.gz gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.zst gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.zip |
Implemented.
2000-02-11 Federico Mena Quintero <federico@helixcode.com>
* cal-client.c (cal_client_update_object): Implemented.
* cal.c (cal_notify_update): New function to notify the listener
about an updated object.
(Cal_update_object): Implemented.
(Cal_get_uids): set_release() the sequence to TRUE.
(Cal_get_events_in_range): Likewise.
* cal-backend.c (remove_object): New function to remove objects
from a calendar backend.
(cal_backend_update_object): New public function to update an
object and notify clients about it.
* evolution-calendar.idl (Cal): Added update_object() and
delete_object() methods.
(Listener): Removed the obj_changed method and renamed obj_added
to obj_updated. We now only have updated and removed notifiers.
* cal-listener.[ch]: Removed the "changed" notification code.
Changed the "added" notification code to the "updated"
notification.
* cal-client.c: Likewise.
* tlacuache.c (create_cal_factory): Connect to "destroy" on the
factory and exit the main loop when the factory is destroyed.
* cal-factory.c (backend_destroy_cb): New callback used when a
backend is destroyed. Removes the backend from the factory's hash
table and unrefs the factory if all backends go away.
(add_calendar_client): Free the environment.
* cal.c (cal_new): Use bonobo_object_unref() if we fail to
initialize.
* cal-listener.c (cal_listener_new): Likewise.
* layout.c (layout_events): Plug li.partition memory leak.
svn path=/trunk/; revision=1742
Diffstat (limited to 'calendar/pcs/cal-factory.c')
-rw-r--r-- | calendar/pcs/cal-factory.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c index 14b7ac9cb6..a170718678 100644 --- a/calendar/pcs/cal-factory.c +++ b/calendar/pcs/cal-factory.c @@ -20,6 +20,7 @@ */ #include <config.h> +#include <gtk/gtksignal.h> #include "cal.h" #include "cal-backend.h" #include "cal-factory.h" @@ -139,6 +140,8 @@ cal_factory_destroy (GtkObject *object) factory = CAL_FACTORY (object); priv = factory->priv; + /* Should we assert that there are no more backends? */ + g_hash_table_foreach (priv->backends, free_backend, NULL); g_hash_table_destroy (priv->backends); priv->backends = NULL; @@ -244,6 +247,41 @@ lookup_backend (CalFactory *factory, GnomeVFSURI *uri) return backend; } +/* Callback used when a backend is destroyed */ +static void +backend_destroy_cb (GtkObject *object, gpointer data) +{ + CalFactory *factory; + CalFactoryPrivate *priv; + CalBackend *backend; + GnomeVFSURI *uri; + gpointer orig_key; + gboolean result; + GnomeVFSURI *orig_uri; + + factory = CAL_FACTORY (data); + priv = factory->priv; + + /* Remove the backend from the hash table */ + + backend = CAL_BACKEND (object); + uri = cal_backend_get_uri (backend); + g_assert (uri != NULL); + + result = g_hash_table_lookup_extended (priv->backends, uri, &orig_key, NULL); + g_assert (result != FALSE); + + orig_uri = orig_key; + + g_hash_table_remove (priv->backends, orig_uri); + gnome_vfs_uri_unref (orig_uri); + + /* If there are no more backends, then the factory can go away */ + + if (g_hash_table_size (priv->backends) == 0) + bonobo_object_unref (BONOBO_OBJECT (factory)); +} + /* Adds a backend to the calendar factory's hash table */ static void add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend) @@ -254,9 +292,10 @@ add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend) gnome_vfs_uri_ref (uri); g_hash_table_insert (priv->backends, uri, backend); - /* FIXME: connect to destroy on the backend and remove it from - * the hash table when it dies. - */ + + gtk_signal_connect (GTK_OBJECT (backend), "destroy", + GTK_SIGNAL_FUNC (backend_destroy_cb), + factory); } /* Loads a calendar backend and puts it in the factory's backend hash table */ @@ -350,6 +389,8 @@ add_calendar_client (CalFactory *factory, CalBackend *backend, Evolution_Calenda g_message ("add_calendar_client(): could not notify the listener"); bonobo_object_unref (BONOBO_OBJECT (cal)); } + + CORBA_exception_free (&ev); } /* Job handler for the load calendar command */ @@ -566,7 +607,7 @@ cal_factory_new (void) if (ev._major != CORBA_NO_EXCEPTION || retval) { g_message ("cal_factory_new(): could not create the CORBA factory"); - gtk_object_unref (GTK_OBJECT (factory)); + bonobo_object_unref (BONOBO_OBJECT (factory)); CORBA_exception_free (&ev); return NULL; } |