From 5e766d8fb292fb1a3727d240210b658fce34325e Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 16 Apr 2004 21:32:52 +0000 Subject: new function, use the async interface to load the book. 2004-04-16 Chris Toshok * gui/component/addressbook-component.c (book_loaded_cb): new function, use the async interface to load the book. (impl_requestCreateItem): use e_book_async_get_default_addressbook. svn path=/trunk/; revision=25496 --- addressbook/gui/component/addressbook-component.c | 57 ++++++++++++++--------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'addressbook/gui/component/addressbook-component.c') diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 6138aaf6ea..3c5ad9ce83 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -117,44 +117,57 @@ impl__get_userCreatableItems (PortableServer_Servant servant, } static void -impl_requestCreateItem (PortableServer_Servant servant, - const CORBA_char *item_type_name, - CORBA_Environment *ev) +book_loaded_cb (EBook *book, EBookStatus status, gpointer data) { - AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant)); - AddressbookComponentPrivate *priv; - EBook *book = NULL; EContact *contact; + char *item_type_name = data; - priv = addressbook_component->priv; - - if (!strcmp (item_type_name, "address_book")) { - addressbook_config_create_new_source (NULL); - return; - } - - if (!e_book_get_default_addressbook (&book, NULL)) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_Failed, NULL); + if (status != E_BOOK_ERROR_OK) { + /* XXX we really need a dialog here, but we don't have + access to the ESource so we can't use + eab_load_error_dialog. fun! */ return; } contact = e_contact_new (); - if (!item_type_name) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); - } - else if (!strcmp (item_type_name, "contact")) { + if (!strcmp (item_type_name, "contact")) { eab_show_contact_editor (book, contact, TRUE, TRUE); } else if (!strcmp (item_type_name, "contact_list")) { eab_show_contact_list_editor (book, contact, TRUE, TRUE); } - else { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); - } g_object_unref (book); g_object_unref (contact); + + g_free (item_type_name); +} + +static void +impl_requestCreateItem (PortableServer_Servant servant, + const CORBA_char *item_type_name, + CORBA_Environment *ev) +{ + AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant)); + AddressbookComponentPrivate *priv; + + priv = addressbook_component->priv; + + if (!item_type_name || + (strcmp (item_type_name, "address_book") && + strcmp (item_type_name, "contact") && + strcmp (item_type_name, "contact_list"))) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); + return; + } + + if (!strcmp (item_type_name, "address_book")) { + addressbook_config_create_new_source (NULL); + return; + } + + e_book_async_get_default_addressbook (book_loaded_cb, g_strdup (item_type_name)); } static CORBA_boolean -- cgit v1.2.3