From 240af05417b2f326140a2ac8fe4043f457b00976 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 25 Sep 2001 12:41:55 +0000 Subject: Handle creating the new contact in the current folder if it's a contacts 2001-09-25 Christopher James Lahey * gui/component/addressbook-component.c (user_create_new_item_cb): Handle creating the new contact in the current folder if it's a contacts folder. Fixes Ximian bug #7814. svn path=/trunk/; revision=13109 --- addressbook/ChangeLog | 6 ++++ addressbook/gui/component/addressbook-component.c | 35 +++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 3d3089b412..339a9ce750 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,9 @@ +2001-09-25 Christopher James Lahey + + * gui/component/addressbook-component.c (user_create_new_item_cb): + Handle creating the new contact in the current folder if it's a + contacts folder. Fixes Ximian bug #7814. + 2001-09-24 Chris Toshok * backend/pas/Makefile.am (LDAP_SCHEMA): add diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 8117ced2cf..3e414f86f9 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -279,12 +279,23 @@ static void local_addressbook_cb (EBook *book, gpointer closure) { gboolean is_list = GPOINTER_TO_INT (closure); + if (book == NULL) + return; if (is_list) e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, TRUE); else e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, TRUE); } +static void +nonlocal_addressbook_cb (EBook *book, EBookStatus status, gpointer closure) +{ + if (status == E_BOOK_STATUS_SUCCESS) + local_addressbook_cb (book, closure); + else + local_addressbook_cb (NULL, closure); +} + static void user_create_new_item_cb (EvolutionShellComponent *shell_component, const char *id, @@ -292,15 +303,29 @@ user_create_new_item_cb (EvolutionShellComponent *shell_component, const char *parent_folder_type, gpointer data) { + gboolean is_contact_list; if (!strcmp (id, "contact")) { - e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (0)); - return; + is_contact_list = FALSE; } else if (!strcmp (id, "contact_list")) { - e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (1)); + is_contact_list = TRUE; + } else { + g_warning ("Don't know how to create item of type \"%s\"", id); return; - } + } + if (IS_CONTACT_TYPE (parent_folder_type)) { + EBook *book; + gchar *uri; + + book = e_book_new (); + uri = g_strdup_printf ("%s/addressbook.db", parent_folder_physical_uri); - g_warning ("Don't know how to create item of type \"%s\"", id); + if (e_book_load_uri (book, uri, nonlocal_addressbook_cb, GINT_TO_POINTER (is_contact_list)) == 0) + g_warning ("Couldn't load addressbook %s", uri); + + g_free (uri); + } else { + e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (is_contact_list)); + } } -- cgit v1.2.3