From 653cfffc0e00dfb59b36813c1b45c53d3f773c65 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Tue, 21 Oct 2003 18:49:34 +0000 Subject: Merge new-ui-branch to the trunk. svn path=/trunk/; revision=22965 --- .../Evolution-Addressbook-SelectNames.idl | 72 ------- ..._Evolution_Addressbook_SelectNames.server.in.in | 4 +- addressbook/gui/component/select-names/Makefile.am | 4 +- .../component/select-names/e-select-names-bonobo.c | 41 +--- .../select-names/e-select-names-completion.c | 238 ++++++++++++--------- .../select-names/e-select-names-completion.h | 2 +- .../select-names/e-select-names-manager.c | 27 +-- .../component/select-names/e-select-names-model.c | 181 ++++++---------- .../component/select-names/e-select-names-model.h | 27 ++- .../component/select-names/e-select-names-popup.c | 96 +++++---- .../select-names/e-select-names-table-model.c | 18 +- .../select-names/e-select-names-text-model.c | 65 +++--- .../gui/component/select-names/e-select-names.c | 83 ++++--- .../gui/component/select-names/e-select-names.h | 2 +- .../component/select-names/e-simple-card-bonobo.c | 216 ------------------- .../component/select-names/e-simple-card-bonobo.h | 71 ------ 16 files changed, 355 insertions(+), 792 deletions(-) delete mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.c delete mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.h (limited to 'addressbook/gui/component/select-names') diff --git a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl index 2959597cc5..6feb6b54bb 100644 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl @@ -14,78 +14,6 @@ module GNOME { module Evolution { module Addressbook { - interface SimpleCard : Bonobo::Unknown { - struct Arbitrary { - string key; - string type; - string value; - }; - - enum Field { - FileAs, - FullName, - Email, - PhonePrimary, - PhoneAssistant, - PhoneBusiness, - PhoneCallback, - PhoneCompany, - PhoneHome, - Org, - AddressBusiness, - AddressHome, - PhoneMobile, - PhoneCar, - PhoneBusinessFax, - PhoneHomeFax, - PhoneBusiness2, - PhoneHome2, - PhoneIsdn, - PhoneOther, - PhoneOtherFax, - PhonePager, - PhoneRadio, - PhoneTelex, - PhoneTtytdd, - AddressOther, - Email2, - Email3, - Url, - OrgUnit, - Office, - Title, - Role, - Manager, - Assistant, - Nickname, - Spouse, - Note, - Caluri, - Fburl, - Icscalendar, - Anniversary, - BirthDate, - Mailer, - NameOrOrg, - Categories, - FamilyName, - GivenName, - AdditionalName, - NameSuffix, - WantsHtml, - IsList, - Last - }; - - Arbitrary getArbitrary (in string key); - void setArbitrary (in string key, in string type, in string value); - - string get (in Field field); - void set (in Field field, in string value); - }; - - typedef sequence SimpleCardList; - interface SelectNames : Bonobo::Unknown { struct Section { string id; diff --git a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in index 6e4d156051..80b138f1dc 100644 --- a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in +++ b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in @@ -17,7 +17,7 @@ + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -28,4 +28,4 @@ - \ No newline at end of file + diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am index 051a168815..b78e5b69fe 100644 --- a/addressbook/gui/component/select-names/Makefile.am +++ b/addressbook/gui/component/select-names/Makefile.am @@ -69,9 +69,7 @@ libeselectnames_la_SOURCES = \ e-select-names-text-model.c \ e-select-names-text-model.h \ e-select-names.c \ - e-select-names.h \ - e-simple-card-bonobo.c \ - e-simple-card-bonobo.h + e-select-names.h libeselectnames_la_LIBADD = \ $(top_builddir)/addressbook/backend/ebook/libebook.la \ diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c index 10fc9caee7..f10fa3b804 100644 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c @@ -25,7 +25,6 @@ #endif #include "e-select-names-bonobo.h" -#include "e-simple-card-bonobo.h" #include @@ -63,7 +62,6 @@ enum _EntryPropertyID { ENTRY_PROPERTY_ID_TEXT, ENTRY_PROPERTY_ID_ADDRESSES, ENTRY_PROPERTY_ID_DESTINATIONS, - ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, ENTRY_PROPERTY_ID_ENTRY_CHANGED }; @@ -122,38 +120,6 @@ entry_get_property_fn (BonoboPropertyBag *bag, } break; - case ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST: - { - ESelectNamesModel *model; - int count; - int i; - GNOME_Evolution_Addressbook_SimpleCardList *card_list; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - count = e_select_names_model_count (model); - - card_list = GNOME_Evolution_Addressbook_SimpleCardList__alloc (); - card_list->_buffer = CORBA_sequence_GNOME_Evolution_Addressbook_SimpleCard_allocbuf (count); - card_list->_maximum = count; - card_list->_length = count; - - for (i = 0; i < count; i++) { - const EDestination *destination = e_select_names_model_get_destination (model, i); - const ECard *card = e_destination_get_card (destination); - ECardSimple *simple = e_card_simple_new ((ECard *) card); - ESimpleCardBonobo *simple_card = e_simple_card_bonobo_new (simple); - g_object_unref (simple); - - card_list->_buffer[i] = bonobo_object_corba_objref (BONOBO_OBJECT (simple_card)); - } - - CORBA_free (*(GNOME_Evolution_Addressbook_SimpleCardList **)arg->_value); - BONOBO_ARG_SET_GENERAL (arg, *card_list, TC_GNOME_Evolution_Addressbook_SimpleCardList, GNOME_Evolution_Addressbook_SimpleCardList, NULL); - } - break; - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: { ESelectNamesCompletion *comp; @@ -195,7 +161,7 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_entry_set_text (E_ENTRY (w), BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); + e_select_names_model_load_all_contacts (model, NULL); break; } @@ -206,7 +172,7 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); + e_select_names_model_load_all_contacts (model, NULL); break; } @@ -499,9 +465,6 @@ impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, bonobo_property_bag_add (property_bag, "destinations", ENTRY_PROPERTY_ID_DESTINATIONS, BONOBO_ARG_STRING, NULL, NULL, BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "simple_card_list", ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, - TC_GNOME_Evolution_Addressbook_SimpleCardList, NULL, NULL, - BONOBO_PROPERTY_READABLE); bonobo_property_bag_add (property_bag, "allow_contact_lists", ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index 5a9fc2deb4..7bfbfd2a5a 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -34,17 +34,17 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include typedef struct { EBook *book; guint book_view_tag; EBookView *book_view; ESelectNamesCompletion *comp; - guint card_added_tag; + guint contacts_added_tag; guint seq_complete_tag; gboolean sequence_complete_received; @@ -76,7 +76,7 @@ static void e_select_names_completion_init (ESelectNamesCompletion *); static void e_select_names_completion_dispose (GObject *object); static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data); -static void e_select_names_completion_card_added_cb (EBookView *, const GList *cards, gpointer user_data); +static void e_select_names_completion_contacts_added_cb (EBookView *, const GList *cards, gpointer user_data); static void e_select_names_completion_seq_complete_cb (EBookView *, EBookViewStatus status, gpointer user_data); static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text, gint pos, gint limit); @@ -95,7 +95,7 @@ static FILE *out; */ typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); +typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EABDestination *); static int utf8_casefold_collate_len (const gchar *str1, const gchar *str2, int len) @@ -125,14 +125,16 @@ our_match_destroy (ECompletionMatch *match) } static ECompletionMatch * -make_match (EDestination *dest, const gchar *menu_form, double score) +make_match (EABDestination *dest, const gchar *menu_form, double score) { ECompletionMatch *match; - ECard *card = e_destination_get_card (dest); +#if notyet + EContact *contact = eab_destination_get_contact (dest); +#endif - match = e_completion_match_new (e_destination_get_name (dest), menu_form, score); + match = e_completion_match_new (eab_destination_get_name (dest), menu_form, score); - e_completion_match_set_text (match, e_destination_get_name (dest), menu_form); + e_completion_match_set_text (match, eab_destination_get_name (dest), menu_form); /* Reject any match that has null text fields. */ if (! (e_completion_match_get_match_text (match) && e_completion_match_get_menu_text (match))) { @@ -140,10 +142,15 @@ make_match (EDestination *dest, const gchar *menu_form, double score) return NULL; } +#if notyet + /* XXX toshok - EContact doesn't have the use_score stuff */ /* Since we sort low to high, we negate so that larger use scores will come first */ - match->sort_major = card ? -floor (e_card_get_use_score (card)) : 0; + match->sort_major = contact ? -floor (e_contact_get_use_score (contact)) : 0; +#else + match->sort_major = 0; +#endif - match->sort_minor = e_destination_get_email_num (dest); + match->sort_minor = eab_destination_get_email_num (dest); match->user_data = dest; g_object_ref (dest); @@ -166,31 +173,33 @@ sexp_nickname (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_nickname (ESelectNamesCompletion *comp, EDestination *dest) +match_nickname (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *match = NULL; gint len; - ECard *card = e_destination_get_card (dest); + EContact *contact = eab_destination_get_contact (dest); double score; + const char *nickname; - if (card->nickname == NULL) + nickname = e_contact_get_const (contact, E_CONTACT_NICKNAME); + if (nickname == NULL) return NULL; len = g_utf8_strlen (comp->priv->query_text, -1); - if (card->nickname && !utf8_casefold_collate_len (comp->priv->query_text, card->nickname, len)) { + if (nickname && !utf8_casefold_collate_len (comp->priv->query_text, nickname, len)) { const gchar *name; gchar *str; score = len * 2; /* nickname gives 2 points per matching character */ - if (len == g_utf8_strlen (card->nickname, -1)) /* boost score on an exact match */ + if (len == g_utf8_strlen (nickname, -1)) /* boost score on an exact match */ score *= 10; - name = e_destination_get_name (dest); + name = eab_destination_get_name (dest); if (name && *name) - str = g_strdup_printf ("'%s' %s <%s>", card->nickname, name, e_destination_get_email (dest)); + str = g_strdup_printf ("'%s' %s <%s>", nickname, name, eab_destination_get_email (dest)); else - str = g_strdup_printf ("'%s' <%s>", card->nickname, e_destination_get_email (dest)); + str = g_strdup_printf ("'%s' <%s>", nickname, eab_destination_get_email (dest)); match = make_match (dest, str, score); g_free (str); @@ -210,17 +219,17 @@ sexp_email (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_email (ESelectNamesCompletion *comp, EDestination *dest) +match_email (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *match; gint len = strlen (comp->priv->query_text); - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); + const gchar *name = eab_destination_get_name (dest); + const gchar *email = eab_destination_get_email (dest); double score; if (email && !utf8_casefold_collate_len (comp->priv->query_text, email, len) - && !e_destination_is_evolution_list (dest)) { + && !eab_destination_is_evolution_list (dest)) { gchar *str; @@ -294,78 +303,82 @@ sexp_name (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_name (ESelectNamesCompletion *comp, EDestination *dest) +match_name (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *final_match = NULL; gchar *menu_text = NULL; - ECard *card; + EContact *contact; const gchar *email; gint match_len = 0; - ECardMatchType match; - ECardMatchPart first_match; + EABContactMatchType match; + EABContactMatchPart first_match; double score = 0; gboolean have_given, have_additional, have_family; + EContactName *contact_name; - card = e_destination_get_card (dest); - - if (card->name == NULL) + contact = eab_destination_get_contact (dest); + + contact_name = e_contact_get (contact, E_CONTACT_NAME); + if (!contact_name) return NULL; - email = e_destination_get_email (dest); + email = eab_destination_get_email (dest); - match = e_card_compare_name_to_string_full (card, comp->priv->query_text, TRUE /* yes, allow partial matches */, - NULL, &first_match, &match_len); + match = eab_contact_compare_name_to_string_full (contact, comp->priv->query_text, TRUE /* yes, allow partial matches */, + NULL, &first_match, &match_len); - if (match <= E_CARD_MATCH_NONE) + if (match <= EAB_CONTACT_MATCH_NONE) { + e_contact_name_free (contact_name); return NULL; + } score = match_len * 3; /* three points per match character */ - have_given = card->name->given && *card->name->given; - have_additional = card->name->additional && *card->name->additional; - have_family = card->name->family && *card->name->family; + have_given = contact_name->given && *contact_name->given; + have_additional = contact_name->additional && *contact_name->additional; + have_family = contact_name->family && *contact_name->family; - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - menu_text = e_card_name_to_string (card->name); + menu_text = e_contact_name_to_string (contact_name); - } else if (first_match == E_CARD_MATCH_PART_GIVEN_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_GIVEN_NAME) { if (have_family) - menu_text = g_strdup_printf ("%s %s <%s>", card->name->given, card->name->family, email); + menu_text = g_strdup_printf ("%s %s <%s>", contact_name->given, contact_name->family, email); else - menu_text = g_strdup_printf ("%s <%s>", card->name->given, email); + menu_text = g_strdup_printf ("%s <%s>", contact_name->given, email); - } else if (first_match == E_CARD_MATCH_PART_ADDITIONAL_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME) { if (have_given) { menu_text = g_strdup_printf ("%s%s%s, %s <%s>", - card->name->additional, + contact_name->additional, have_family ? " " : "", - have_family ? card->name->family : "", - card->name->given, + have_family ? contact_name->family : "", + contact_name->given, email); } else { menu_text = g_strdup_printf ("%s%s%s <%s>", - card->name->additional, + contact_name->additional, have_family ? " " : "", - have_family ? card->name->family : "", + have_family ? contact_name->family : "", email); } - } else if (first_match == E_CARD_MATCH_PART_FAMILY_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_FAMILY_NAME) { if (have_given) menu_text = g_strdup_printf ("%s, %s%s%s <%s>", - card->name->family, - card->name->given, + contact_name->family, + contact_name->given, have_additional ? " " : "", - have_additional ? card->name->additional : "", + have_additional ? contact_name->additional : "", email); else - menu_text = g_strdup_printf ("%s <%s>", card->name->family, email); + menu_text = g_strdup_printf ("%s <%s>", contact_name->family, email); } else { /* something funny happened */ @@ -379,6 +392,8 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest) g_free (menu_text); } + e_contact_name_free (contact_name); + return final_match; } @@ -393,7 +408,7 @@ sexp_file_as (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_file_as (ESelectNamesCompletion *comp, EDestination *dest) +match_file_as (ESelectNamesCompletion *comp, EABDestination *dest) { const gchar *name; const gchar *email; @@ -402,8 +417,8 @@ match_file_as (ESelectNamesCompletion *comp, EDestination *dest) double score = 0.00001; ECompletionMatch *match; - name = e_destination_get_name (dest); - email = e_destination_get_email (dest); + name = eab_destination_get_name (dest); + email = eab_destination_get_email (dest); if (!(name && *name)) return NULL; @@ -491,13 +506,13 @@ book_query_sexp (ESelectNamesCompletion *comp) * string that applies to a given destination. */ static ECompletionMatch * -book_query_score (ESelectNamesCompletion *comp, EDestination *dest) +book_query_score (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *best_match = NULL; gint i; g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - g_return_val_if_fail (E_IS_DESTINATION (dest), NULL); + g_return_val_if_fail (EAB_IS_DESTINATION (dest), NULL); if (! (comp->priv->query_text && *comp->priv->query_text)) return NULL; @@ -506,7 +521,7 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest) ECompletionMatch *this_match = NULL; - if (book_queries[i].tester && e_destination_get_card (dest)) { + if (book_queries[i].tester && eab_destination_get_contact (dest)) { this_match = book_queries[i].tester (comp, dest); } @@ -524,18 +539,18 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest) } static void -book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards) +book_query_process_card_list (ESelectNamesCompletion *comp, const GList *contacts) { - while (cards) { - ECard *card = E_CARD (cards->data); + while (contacts) { + EContact *contact = E_CONTACT (contacts->data); - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { if (comp->priv->match_contact_lists) { - EDestination *dest = e_destination_new (); + EABDestination *dest = eab_destination_new (); ECompletionMatch *match; - e_destination_set_card (dest, card, 0); + eab_destination_set_contact (dest, contact, 0); match = book_query_score (comp, dest); if (match && match->score > 0) { e_completion_found_match (E_COMPLETION (comp), match); @@ -546,31 +561,38 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards) } - } else if (card->email) { - gint i; - for (i=0; iemail); ++i) { - EDestination *dest = e_destination_new (); - const gchar *email; - ECompletionMatch *match; + } + else { + GList *email = e_contact_get (contact, E_CONTACT_EMAIL); + if (email) { + GList *iter; + gint i; + for (i=0, iter = email; iter; ++i, iter = iter->next) { + EABDestination *dest = eab_destination_new (); + gchar *e; + ECompletionMatch *match; - e_destination_set_card (dest, card, i); - email = e_destination_get_email (dest); + eab_destination_set_contact (dest, contact, i); + e = iter->data; - if (email && *email) { + if (e && *e) { - match = book_query_score (comp, dest); - if (match && match->score > 0) { - e_completion_found_match (E_COMPLETION (comp), match); - } else { - e_completion_match_unref (match); + match = book_query_score (comp, dest); + if (match && match->score > 0) { + e_completion_found_match (E_COMPLETION (comp), match); + } else { + e_completion_match_unref (match); + } } - } - g_object_unref (dest); + g_object_unref (dest); + } } + g_list_foreach (email, (GFunc)g_free, NULL); + g_list_free (email); } - cards = g_list_next (cards); + contacts = contacts->next; } } @@ -640,9 +662,9 @@ e_select_names_completion_clear_book_data (ESelectNamesCompletion *comp) for (l = comp->priv->book_data; l; l = l->next) { ESelectNamesCompletionBookData *book_data = l->data; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { @@ -756,7 +778,7 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo book_data = (ESelectNamesCompletionBookData*)user_data; comp = book_data->comp; - if (status != E_BOOK_STATUS_SUCCESS) { + if (status != E_BOOK_ERROR_OK) { comp->priv->pending_completion_seq--; if (!comp->priv->pending_completion_seq) e_select_names_completion_done (comp); @@ -765,9 +787,9 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo book_data->book_view_tag = 0; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -781,10 +803,10 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo } book_data->book_view = view; - book_data->card_added_tag = + book_data->contacts_added_tag = g_signal_connect (view, - "card_added", - G_CALLBACK (e_select_names_completion_card_added_cb), + "contacts_added", + G_CALLBACK (e_select_names_completion_contacts_added_cb), book_data); book_data->seq_complete_tag = @@ -792,11 +814,14 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo "sequence_complete", G_CALLBACK (e_select_names_completion_seq_complete_cb), book_data); + + e_book_view_start (view); + book_data->sequence_complete_received = FALSE; } static void -e_select_names_completion_card_added_cb (EBookView *book_view, const GList *cards, gpointer user_data) +e_select_names_completion_contacts_added_cb (EBookView *book_view, const GList *cards, gpointer user_data) { ESelectNamesCompletionBookData *book_data = user_data; ESelectNamesCompletion *comp = book_data->comp; @@ -834,7 +859,7 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus } if (book_data->cached_query_text - && status == E_BOOK_STATUS_SUCCESS + && status == E_BOOK_ERROR_OK && !book_data->cache_complete && !strcmp (book_data->cached_query_text, comp->priv->query_text)) book_data->cache_complete = TRUE; @@ -845,9 +870,9 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus if (!book_data->sequence_complete_received) { book_data->sequence_complete_received = TRUE; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -888,13 +913,15 @@ e_select_names_completion_stop_query (ESelectNamesCompletion *comp) for (l = comp->priv->book_data; l; l = l->next) { ESelectNamesCompletionBookData *book_data = l->data; if (book_data->book_view_tag) { +#if notyet e_book_cancel (book_data->book, book_data->book_view_tag); +#endif book_data->book_view_tag = 0; } if (book_data->book_view) { - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -977,13 +1004,10 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar e_select_names_completion_clear_cache (book_data); book_data->cached_query_text = g_strdup (query_text); - book_data->book_view_tag = e_book_get_completion_view (book_data->book, + book_data->book_view_tag = e_book_async_get_book_view (book_data->book, sexp, e_select_names_completion_got_book_view_cb, book_data); - if (! book_data->book_view_tag) - g_warning ("Exception calling e_book_get_completion_view"); - else - comp->priv->pending_completion_seq++; + comp->priv->pending_completion_seq++; } if (out) diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h index 6565208378..435fe80041 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ b/addressbook/gui/component/select-names/e-select-names-completion.h @@ -28,7 +28,7 @@ #define E_SELECT_NAMES_COMPLETION_H #include -#include +#include #include "e-select-names-text-model.h" G_BEGIN_DECLS diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index a3875cea97..e095f7308f 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -24,8 +24,8 @@ #include "e-select-names-completion.h" #include "e-select-names-popup.h" #include "e-folder-list.h" -#include -#include +#include +#include #include "addressbook/gui/component/addressbook.h" #include @@ -175,7 +175,7 @@ focus_in_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) entry->cleaning_tag = 0; } - e_select_names_model_cancel_cardify_all (entry->model); + e_select_names_model_cancel_all_contact_load (entry->model); return FALSE; } @@ -189,7 +189,7 @@ focus_out_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) gboolean visible = e_entry_completion_popup_is_visible (entry->entry); if (! visible) { - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 100); + e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 100); if (entry->cleaning_tag == 0) entry->cleaning_tag = gtk_timeout_add (100, clean_cb, entry); } @@ -205,7 +205,7 @@ completion_popup_cb (EEntry *w, gint visible, gpointer user_data) ESelectNamesManagerEntry *entry = user_data; if (!visible && !GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (entry->entry->canvas))) - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 0); + e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 0); #endif } @@ -214,14 +214,14 @@ completion_handler (EEntry *entry, ECompletionMatch *match) { ESelectNamesManagerEntry *mgr_entry; ESelectNamesTextModel *text_model; - EDestination *dest; + EABDestination *dest; gint i, pos, start_pos, len; if (match == NULL || match->user_data == NULL) return; mgr_entry = get_entry_info (entry); - dest = E_DESTINATION (match->user_data); + dest = EAB_DESTINATION (match->user_data); /* Sometimes I really long for garbage collection. Reference counting makes you feel 31337, but sometimes it is just a @@ -377,7 +377,7 @@ e_select_names_manager_discard_saved_models (ESelectNamesManager *manager) static void open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager) { - if (status == E_BOOK_STATUS_SUCCESS) { + if (status == E_BOOK_ERROR_OK) { GList *l; for (l = manager->entries; l; l = l->next) { ESelectNamesManagerEntry *entry = l->data; @@ -398,15 +398,10 @@ load_completion_books (ESelectNamesManager *manager) EFolderListItem *f; for (f = folders; f && f->physical_uri; f++) { - char *uri; EBook *book = e_book_new (); g_object_ref (manager); /* ref ourself before our async call */ - uri = e_book_expand_uri (f->physical_uri); - - addressbook_load_uri (book, uri, (EBookCallback)open_book_cb, manager); - - g_free (uri); + addressbook_load_uri (book, f->physical_uri, (EBookCallback)open_book_cb, manager); } e_folder_list_free_items (folders); } @@ -485,7 +480,7 @@ e_select_names_manager_new (void) ESelectNamesManager *manager = g_object_new (E_TYPE_SELECT_NAMES_MANAGER, NULL); EConfigListener *db; - db = e_book_get_config_database(); + db = eab_get_config_database(); manager->listener_id = g_signal_connect (db, "key_changed", @@ -685,7 +680,7 @@ e_select_names_manager_dispose (GObject *object) } if (manager->listener_id) { - g_signal_handler_disconnect (e_book_get_config_database(), manager->listener_id); + g_signal_handler_disconnect (eab_get_config_database(), manager->listener_id); manager->listener_id = 0; } diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index 6c3cb0f9c6..d95aebde5d 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -19,7 +19,7 @@ #include "e-select-names-model.h" #include "e-select-names-marshal.h" -#include "addressbook/backend/ebook/e-card-simple.h" +#include "addressbook/backend/ebook/e-contact.h" #define MAX_LENGTH 2047 @@ -35,14 +35,14 @@ static guint e_select_names_model_signals[E_SELECT_NAMES_MODEL_LAST_SIGNAL] = { /* Object argument IDs */ enum { ARG_0, - ARG_CARD, + ARG_CONTACT, }; struct _ESelectNamesModelPrivate { gchar *id; gchar *title; - GList *data; /* of EDestination */ + GList *data; /* of EABDestination */ gint limit; @@ -159,7 +159,7 @@ e_select_names_model_changed (ESelectNamesModel *model) } static void -destination_changed_proxy (EDestination *dest, gpointer closure) +destination_changed_proxy (EABDestination *dest, gpointer closure) { e_select_names_model_changed (E_SELECT_NAMES_MODEL (closure)); } @@ -184,7 +184,7 @@ e_select_names_model_duplicate (ESelectNamesModel *old) model->priv->title = g_strdup (old->priv->title); for (iter = old->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dup = e_destination_copy (E_DESTINATION (iter->data)); + EABDestination *dup = eab_destination_copy (EAB_DESTINATION (iter->data)); e_select_names_model_append (model, dup); } @@ -212,8 +212,8 @@ e_select_names_model_get_textification (ESelectNamesModel *model, const char *se GList *iter = model->priv->data; while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_textrep (dest, FALSE); + EABDestination *dest = EAB_DESTINATION (iter->data); + strv[i] = (gchar *) eab_destination_get_textrep (dest, FALSE); ++i; iter = g_list_next (iter); } @@ -252,8 +252,8 @@ e_select_names_model_get_address_text (ESelectNamesModel *model, const char *sep GList *iter = model->priv->data; while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_address (dest); + EABDestination *dest = EAB_DESTINATION (iter->data); + strv[i] = (gchar *) eab_destination_get_address (dest); if (strv[i]) ++i; iter = g_list_next (iter); @@ -304,43 +304,42 @@ e_select_names_model_at_limit (ESelectNamesModel *model) return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; } -const EDestination * +const EABDestination * e_select_names_model_get_destination (ESelectNamesModel *model, gint index) { g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - return E_DESTINATION (g_list_nth_data (model->priv->data, index)); + return EAB_DESTINATION (g_list_nth_data (model->priv->data, index)); } gchar * e_select_names_model_export_destinationv (ESelectNamesModel *model) { - EDestination **destv; + EABDestination **destv; gchar *str; gint i, len = 0; GList *j; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); len = g_list_length (model->priv->data); - destv = g_new0 (EDestination *, len+1); + destv = g_new0 (EABDestination *, len+1); for (i=0, j = model->priv->data; j != NULL; j = g_list_next (j)) { - EDestination *dest = E_DESTINATION (j->data); + EABDestination *dest = EAB_DESTINATION (j->data); if (dest) destv[i++] = dest; } - str = e_destination_exportv (destv); + str = eab_destination_exportv (destv); g_free (destv); return str; } -static -void send_changed (EDestination *dest, ECard *card, gpointer closure) +static void send_changed (EABDestination *dest, EContact *contact, gpointer closure) { ESelectNamesModel *model = closure; e_select_names_model_changed (model); @@ -350,12 +349,12 @@ void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv) { - EDestination **destv; + EABDestination **destv; gint i; g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - destv = e_destination_importv (destinationv); + destv = eab_destination_importv (destinationv); e_select_names_model_delete_all (model); @@ -363,30 +362,30 @@ e_select_names_model_import_destinationv (ESelectNamesModel *model, return; for (i = 0; destv[i]; i++) { - e_destination_use_card (destv[i], send_changed, model); + eab_destination_use_contact (destv[i], send_changed, model); e_select_names_model_append (model, destv[i]); } g_free (destv); } -ECard * -e_select_names_model_get_card (ESelectNamesModel *model, gint index) +EContact * +e_select_names_model_get_contact (ESelectNamesModel *model, gint index) { - const EDestination *dest; + const EABDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_card (dest) : NULL; + return dest ? eab_destination_get_contact (dest) : NULL; } const gchar * e_select_names_model_get_string (ESelectNamesModel *model, gint index) { - const EDestination *dest; + const EABDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); @@ -394,11 +393,11 @@ e_select_names_model_get_string (ESelectNamesModel *model, gint index) dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_textrep (dest, FALSE) : ""; + return dest ? eab_destination_get_textrep (dest, FALSE) : ""; } static void -connect_destination (ESelectNamesModel *model, EDestination *dest) +connect_destination (ESelectNamesModel *model, EABDestination *dest) { g_signal_connect (dest, "changed", @@ -407,21 +406,21 @@ connect_destination (ESelectNamesModel *model, EDestination *dest) } static void -disconnect_destination (ESelectNamesModel *model, EDestination *dest) +disconnect_destination (ESelectNamesModel *model, EABDestination *dest) { g_signal_handlers_disconnect_by_func (dest, destination_changed_proxy, model); } gboolean -e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest) +e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest) { GList *iter; g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); + g_return_val_if_fail (EAB_IS_DESTINATION (dest), FALSE); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - if (iter->data != NULL && e_destination_equal (dest, E_DESTINATION (iter->data))) + if (iter->data != NULL && eab_destination_equal (dest, EAB_DESTINATION (iter->data))) return TRUE; } @@ -429,12 +428,12 @@ e_select_names_model_contains (ESelectNamesModel *model, const EDestination *des } void -e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) +e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest) { g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index <= g_list_length (model->priv->data)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -452,10 +451,10 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination } void -e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) +e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest) { g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -473,7 +472,7 @@ e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) } void -e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) +e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest) { GList *node; const gchar *new_str, *old_str; @@ -482,9 +481,9 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); - new_str = e_destination_get_textrep (dest, FALSE); + new_str = eab_destination_get_textrep (dest, FALSE); new_strlen = new_str ? strlen (new_str) : 0; if (model->priv->data == NULL) { @@ -500,10 +499,10 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination if (node->data != dest) { - disconnect_destination (model, E_DESTINATION (node->data)); + disconnect_destination (model, EAB_DESTINATION (node->data)); connect_destination (model, dest); - old_str = e_destination_get_textrep (E_DESTINATION (node->data), FALSE); + old_str = eab_destination_get_textrep (EAB_DESTINATION (node->data), FALSE); old_strlen = old_str ? strlen (old_str) : 0; g_object_unref (node->data); @@ -523,14 +522,14 @@ void e_select_names_model_delete (ESelectNamesModel *model, gint index) { GList *node; - EDestination *dest; + EABDestination *dest; g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); node = g_list_nth (model->priv->data, index); - dest = E_DESTINATION (node->data); + dest = EAB_DESTINATION (node->data); disconnect_destination (model, dest); g_object_unref (dest); @@ -552,16 +551,16 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) iter = model->priv->data; while (iter) { - EDestination *dest; + EABDestination *dest; next = g_list_next (iter); if (next == NULL && !clean_last_entry) break; - dest = iter->data ? E_DESTINATION (iter->data) : NULL; + dest = iter->data ? EAB_DESTINATION (iter->data) : NULL; - if (dest == NULL || e_destination_is_empty (dest)) { + if (dest == NULL || eab_destination_is_empty (dest)) { if (dest) { disconnect_destination (model, dest); g_object_unref (dest); @@ -581,7 +580,7 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) static void delete_all_iter (gpointer data, gpointer closure) { - disconnect_destination (E_SELECT_NAMES_MODEL (closure), E_DESTINATION (data)); + disconnect_destination (E_SELECT_NAMES_MODEL (closure), EAB_DESTINATION (data)); g_object_unref (data); } @@ -611,9 +610,9 @@ e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel e_select_names_model_delete_all (dest); len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); + const EABDestination *d = e_select_names_model_get_destination (src, i); if (d) - e_select_names_model_append (dest, e_destination_copy (d)); + e_select_names_model_append (dest, eab_destination_copy (d)); } } @@ -630,9 +629,9 @@ e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src) len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); + const EABDestination *d = e_select_names_model_get_destination (src, i); if (d && !e_select_names_model_contains (dest, d)) - e_select_names_model_append (dest, e_destination_copy (d)); + e_select_names_model_append (dest, eab_destination_copy (d)); } } @@ -650,7 +649,7 @@ e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index iter = model->priv->data; while (iter && i <= index) { rp += len + (i > 0 ? seplen : 0); - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); + str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; ++i; iter = g_list_next (iter); @@ -680,7 +679,7 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, iter = model->priv->data; while (iter != NULL) { - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); + str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; if (sp <= pos && pos <= sp + len + adj) { @@ -719,65 +718,7 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, } void -e_select_names_model_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); - } -} - -gboolean -e_select_names_model_uncardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - gboolean rv = FALSE; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (0 <= index && index < g_list_length (model->priv->data), FALSE); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - EDestination *cpy_dest = e_destination_copy (dest); - - rv = e_destination_uncardify (cpy_dest); - - if (rv) { - e_select_names_model_replace (model, index, cpy_dest); - } - - } - - return rv; -} - -void -e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - e_destination_cancel_cardify (dest); -} - -void -e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay) +e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book) { GList *iter; @@ -785,27 +726,27 @@ e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint de g_return_if_fail (book == NULL || E_IS_BOOK (book)); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - if (!e_destination_is_empty (dest)) { + EABDestination *dest = EAB_DESTINATION (iter->data); + if (!eab_destination_is_empty (dest)) { - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); + eab_destination_load_contact (dest, book); } } } void -e_select_names_model_cancel_cardify_all (ESelectNamesModel *model) +e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model) { GList *iter; g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - e_destination_cancel_cardify (dest); + EABDestination *dest = EAB_DESTINATION (iter->data); + if (!eab_destination_is_empty (dest)) { + + eab_destination_cancel_contact_load (dest); + } } } diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 8a3c5381b7..41d5100f59 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) #define E_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) @@ -54,18 +54,18 @@ gint e_select_names_model_get_limit (ESelectNamesModel void e_select_names_model_set_limit (ESelectNamesModel *model, gint limit); gboolean e_select_names_model_at_limit (ESelectNamesModel *model); -const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); -gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); -void e_select_names_model_import_destinationv (ESelectNamesModel *model, +const EABDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); +gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); +void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv); -ECard *e_select_names_model_get_card (ESelectNamesModel *model, gint index); +EContact *e_select_names_model_get_contact (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); -gboolean e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest); +gboolean e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest); -void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); -void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); +void e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest); +void e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest); +void e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest); void e_select_names_model_delete (ESelectNamesModel *model, gint index); void e_select_names_model_delete_all (ESelectNamesModel *model); void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); @@ -76,11 +76,8 @@ void e_select_names_model_clean (ESelectNamesModel *model, gboolea void e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length); void e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length); -void e_select_names_model_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay); -gboolean e_select_names_model_uncardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay); -void e_select_names_model_cancel_cardify_all (ESelectNamesModel *model); +void e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book); +void e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model); /* This is a mildly annoying freeze/thaw pair, in that it only applies to the 'changed' signal and not to 'resized'. This could cause unexpected results in some cases. */ diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index d7fabd9426..bb0f331516 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -39,10 +39,11 @@ #include #include -#include +#include #include +#include #include -#include "e-addressbook-util.h" +#include "eab-gui-util.h" #include "e-select-names-popup.h" #define LIST_ICON_FILENAME "contact-list-16.png" @@ -51,13 +52,13 @@ typedef struct _PopupInfo PopupInfo; struct _PopupInfo { ESelectNamesTextModel *text_model; - EDestination *dest; + EABDestination *dest; gint pos; gint index; }; static PopupInfo * -popup_info_new (ESelectNamesTextModel *text_model, EDestination *dest, gint pos, gint index) +popup_info_new (ESelectNamesTextModel *text_model, EABDestination *dest, gint pos, gint index) { PopupInfo *info = g_new0 (PopupInfo, 1); info->text_model = text_model; @@ -97,29 +98,29 @@ popup_info_cleanup (GtkWidget *w, gpointer info) /* You are in a maze of twisty little callbacks, all alike... */ +#if TOO_MANY_MENU_ITEMS static void make_contact_editor_cb (EBook *book, gpointer user_data) { if (book) { - EDestination *dest = E_DESTINATION (user_data); - ECard *card; + EABDestination *dest = EAB_DESTINATION (user_data); + EContact *contact; - card = (ECard *) e_destination_get_card (dest); - if (e_card_evolution_list (card)) { + contact = (EContact *) eab_destination_get_contact (dest); + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (book, card, FALSE, TRUE); + ce = e_addressbook_show_contact_list_editor (book, contact, FALSE, TRUE); e_contact_list_editor_raise (ce); } else { EContactEditor *ce; - ce = e_addressbook_show_contact_editor (book, card, FALSE, TRUE); + ce = e_addressbook_show_contact_editor (book, contact, FALSE, TRUE); e_contact_editor_raise (ce); } g_object_unref (dest); } } -#if TOO_MANY_MENU_ITEMS static void edit_contact_info_cb (GtkWidget *w, gpointer user_data) { @@ -137,7 +138,7 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; gint n; - EDestination *dest; + EABDestination *dest; if (info == NULL) return; @@ -147,9 +148,9 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "number")); - if (n != e_destination_get_email_num (info->dest)) { - dest = e_destination_new (); - e_destination_set_card (dest, e_destination_get_card (info->dest), n); + if (n != eab_destination_get_email_num (info->dest)) { + dest = eab_destination_new (); + eab_destination_set_contact (dest, eab_destination_get_contact (info->dest), n); e_select_names_model_replace (info->text_model->source, info->index, dest); } } @@ -174,7 +175,7 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (w); - const EDestination *dest; + const EABDestination *dest; if (info == NULL) return; @@ -182,19 +183,19 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) dest = info->dest; item = GTK_CHECK_MENU_ITEM (item); - e_destination_set_html_mail_pref ((EDestination *) dest, item->active); + eab_destination_set_html_mail_pref ((EABDestination *) dest, item->active); } #endif static void -populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) +populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) { GtkWidget *image; - ECard *card; - EIterator *iterator; + EContact *contact; GtkWidget *menuitem; + GList *email_list; - card = e_destination_get_card (info->dest); + contact = eab_destination_get_contact (info->dest); #if TOO_MANY_MENU_ITEMS menuitem = gtk_separator_menu_item_new(); @@ -224,7 +225,7 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); + eab_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -232,25 +233,27 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); #endif - if (card->email) { + email_list = e_contact_get (contact, E_CONTACT_EMAIL); + + if (email_list) { menuitem = gtk_separator_menu_item_new(); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - if (e_list_length (card->email) > 1) { + if (g_list_length (email_list) > 1) { + GList *l; GSList *radiogroup = NULL; - gint n = e_destination_get_email_num (info->dest); - gint j = e_list_length (card->email) - 1; + gint n = eab_destination_get_email_num (info->dest); + gint j = g_list_length (email_list) - 1; - iterator = e_list_get_iterator (card->email); - for (e_iterator_last (iterator); e_iterator_is_valid (iterator); e_iterator_prev (iterator)) { - char *email = (char *)e_iterator_get (iterator); + for (l = g_list_last (email_list); l; l = l->prev) { + char *email = l->data; char *label = NULL; if (!strncmp (email, "dest)); + menuitem = gtk_menu_item_new_with_label (eab_destination_get_email (info->dest)); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); } + + g_list_foreach (email_list, (GFunc)g_free, NULL); + g_list_free (email_list); } menuitem = gtk_separator_menu_item_new (); @@ -297,7 +301,7 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) ? EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME : EVOLUTION_IMAGESDIR "/" CONTACT_ICON_FILENAME); gtk_widget_show (image); - menuitem = gtk_image_menu_item_new_with_label (e_destination_get_name (info->dest)); + menuitem = gtk_image_menu_item_new_with_label (eab_destination_get_name (info->dest)); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_widget_show (menuitem); @@ -308,11 +312,11 @@ static void quick_add_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); + e_contact_quick_add_free_form (eab_destination_get_address (info->dest), NULL, NULL); } static void -populate_popup_nocard (GtkWidget *pop, PopupInfo *info) +populate_popup_nocontact (GtkWidget *pop, PopupInfo *info) { const gchar *str; GtkWidget *menuitem; @@ -331,7 +335,7 @@ populate_popup_nocard (GtkWidget *pop, PopupInfo *info) #if TOO_MANY_MENU_ITEMS menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); + eab_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -343,9 +347,9 @@ populate_popup_nocard (GtkWidget *pop, PopupInfo *info) gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - str = e_destination_get_name (info->dest); + str = eab_destination_get_name (info->dest); if (! (str && *str)) - str = e_destination_get_email (info->dest); + str = eab_destination_get_email (info->dest); if (! (str && *str)) str = _("Unnamed Contact"); @@ -360,7 +364,7 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode { ESelectNamesModel *model; PopupInfo *info; - EDestination *dest; + EABDestination *dest; gint index; g_return_if_fail (GTK_IS_MENU_SHELL (menu)); @@ -375,16 +379,16 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode return; /* XXX yuck, why does this return a const? */ - dest = (EDestination *)e_select_names_model_get_destination (model, index); - if (e_destination_is_empty (dest)) + dest = (EABDestination *)e_select_names_model_get_destination (model, index); + if (eab_destination_is_empty (dest)) return; info = popup_info_new (text_model, dest, pos, index); - if (e_destination_contains_card (dest)) { - populate_popup_card (menu, e_destination_is_evolution_list (dest), info); + if (eab_destination_get_contact (dest)) { + populate_popup_contact (menu, eab_destination_is_evolution_list (dest), info); } else { - populate_popup_nocard (menu, info); + populate_popup_nocontact (menu, info); } /* Clean up our info item after we've made our selection. */ diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index 1c55c3804d..14261e9d80 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -16,7 +16,7 @@ #include #include "e-select-names-table-model.h" -#include "addressbook/backend/ebook/e-card-simple.h" +#include "addressbook/backend/ebook/e-contact.h" /* Object argument IDs */ enum { @@ -118,21 +118,19 @@ fill_in_info (ESelectNamesTableModel *model) model->data = g_new(ESelectNamesTableModelData, count); for (i = 0; i < count; ++i) { - const EDestination *dest = e_select_names_model_get_destination (model->source, i); - ECard *card = dest ? e_destination_get_card (dest) : NULL; + const EABDestination *dest = e_select_names_model_get_destination (model->source, i); + EContact *contact = dest ? eab_destination_get_contact (dest) : NULL; - if (card) { - ECardSimple *simple = e_card_simple_new(card); - model->data[i].name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG); + if (contact) { + model->data[i].name = e_contact_get(contact, E_CONTACT_FULL_NAME); if (model->data[i].name == 0) model->data[i].name = g_strdup(""); - model->data[i].email = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_EMAIL); + model->data[i].email = e_contact_get(contact, E_CONTACT_EMAIL_1); if (model->data[i].email == 0) model->data[i].email = g_strdup(""); - g_object_unref(simple); } else { - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); + const gchar *name = eab_destination_get_name (dest); + const gchar *email = eab_destination_get_email (dest); model->data[i].name = g_strdup (name && *name ? name : email); model->data[i].email = g_strdup (email); diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c index 7859d5b056..e885de5bf6 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -19,7 +19,7 @@ #include #include "e-select-names-text-model.h" -#include "e-addressbook-util.h" +#include "eab-gui-util.h" static FILE *out = NULL; /* stream for debugging spew */ @@ -137,7 +137,7 @@ dump_model (ESelectNamesTextModel *text_model) for (i=0; i" : ""); + e_select_names_model_get_contact (model, i) ? "" : ""); fprintf (out, "\n"); } @@ -372,9 +372,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha /* Is this a quoted or an unquoted separator we are dealing with? */ if (ut == g_utf8_get_char(text_model->sep) && index >= 0) { - const EDestination *dest = e_select_names_model_get_destination (source, index); + const EABDestination *dest = e_select_names_model_get_destination (source, index); if (dest) { - const gchar *str = e_destination_get_textrep (dest, FALSE); + const gchar *str = eab_destination_get_textrep (dest, FALSE); int j; const char *jp; @@ -400,8 +400,8 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (index == -1) { EReposAbsolute repos; - e_select_names_model_insert (source, 0, e_destination_new ()); - e_select_names_model_insert (source, 0, e_destination_new ()); + e_select_names_model_insert (source, 0, eab_destination_new ()); + e_select_names_model_insert (source, 0, eab_destination_new ()); repos.model = model; repos.pos = -1; /* At end */ @@ -420,7 +420,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha (e_select_names_model_get_string (source, ins_point) == NULL)) || (ins_point > 0 && (e_select_names_model_get_string (source, ins_point-1) == NULL)))) { - e_select_names_model_insert (source, ins_point, e_destination_new ()); + e_select_names_model_insert (source, ins_point, eab_destination_new ()); repos.model = model; repos.pos = pos; @@ -435,10 +435,10 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha const gchar *str = e_select_names_model_get_string (source, index); gchar *str1 = g_strndup (str, offset); gchar *str2 = g_strdup (str+offset); - EDestination *d1 = e_destination_new (), *d2 = e_destination_new (); + EABDestination *d1 = eab_destination_new (), *d2 = eab_destination_new (); - e_destination_set_raw (d1, str1); - e_destination_set_raw (d2, str2); + eab_destination_set_raw (d1, str1); + eab_destination_set_raw (d2, str2); e_select_names_model_replace (source, index, d1); e_select_names_model_insert (source, index+1, d2); @@ -498,9 +498,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (new_str->len) { - EDestination *dest; - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str->str); + EABDestination *dest; + dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); + eab_destination_set_raw (dest, new_str->str); e_select_names_model_replace (source, index, dest); /* e_select_names_model_replace (source, index, dest); */ @@ -589,7 +589,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) if (index+1 < e_select_names_model_count (source)) { EReposDeleteShift repos; - EDestination *new_dest; + EABDestination *new_dest; const gchar *str1 = e_select_names_model_get_string (source, index); const gchar *str2 = e_select_names_model_get_string (source, index+1); gchar *new_str; @@ -613,8 +613,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) e_select_names_model_delete (source, index+1); - new_dest = e_destination_new (); - e_destination_set_raw (new_dest, new_str); + new_dest = eab_destination_new (); + eab_destination_set_raw (new_dest, new_str); e_select_names_model_replace (source, index, new_dest); g_free (new_str); @@ -689,7 +689,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) char *np; int i; EReposDeleteShift repos; - EDestination *dest; + EABDestination *dest; new_str = g_new0 (char, strlen (str) * 6 + 1); /* worse case it can't be any longer than this */ @@ -718,8 +718,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) np = g_utf8_next_char (np); } - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str); + dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); + eab_destination_set_raw (dest, new_str); e_select_names_model_replace (source, index, dest); if (out) @@ -764,10 +764,10 @@ e_select_names_text_model_obj_count (ETextModel *model) count = i = e_select_names_model_count (source); while (i > 0) { - const EDestination *dest; + const EABDestination *dest; --i; dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_card (dest) == NULL) + if (eab_destination_get_contact (dest) == NULL) --count; } @@ -783,8 +783,8 @@ nth_obj_index (ESelectNamesModel *source, gint n) N = e_select_names_model_count (source); do { - const EDestination *dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_card (dest)) + const EABDestination *dest = e_select_names_model_get_destination (source, i); + if (eab_destination_get_contact (dest)) --n; ++i; } while (n >= 0 && i < N); @@ -820,27 +820,32 @@ e_select_names_text_model_get_nth_obj (ETextModel *model, gint n, gint *len) static void e_select_names_text_model_activate_obj (ETextModel *model, gint n) { +#if notyet + /* XXX the new ebook doesn't have e_contact_get_book, and we + don't really want to add it, so this can't be implemented + this simply anymore */ ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - ECard *card; + EContact *contact; gint i; i = nth_obj_index (source, n); g_return_if_fail (i >= 0); - card = e_select_names_model_get_card (source, i); - g_return_if_fail (card != NULL); + contact = e_select_names_model_get_contact (source, i); + g_return_if_fail (contact != NULL); /* present read-only contact editor when someone double clicks from here */ - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (e_card_get_book(card), card, FALSE, FALSE); + ce = e_addressbook_show_contact_list_editor (e_contact_get_book(contact), contact, FALSE, FALSE); e_contact_list_editor_raise (ce); } else { - EContactEditor *ce; - ce = e_addressbook_show_contact_editor (e_card_get_book(card), card, FALSE, FALSE); + EABContactEditor *ce; + ce = e_addressbook_show_contact_editor (e_contact_get_book(contact), contact, FALSE, FALSE); e_contact_editor_raise (ce); } +#endif } diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index f009fbbd63..b50a6d0ca0 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -30,9 +30,8 @@ #include #include -#include -#include -#include +#include +#include #include #include #include @@ -40,7 +39,7 @@ #include #include "e-select-names.h" -#include +#include #include "e-select-names-table-model.h" #include #include @@ -113,7 +112,7 @@ GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *str GtkWidget *e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2); static void -search_result (EAddressbookModel *model, EBookViewStatus status, ESelectNames *esn) +search_result (EABModel *model, EBookViewStatus status, ESelectNames *esn) { sync_table_and_models (NULL, esn); } @@ -131,19 +130,15 @@ set_book(EBook *book, EBookStatus status, ESelectNames *esn) } static void -addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model, const char *uri) +addressbook_model_set_uri(ESelectNames *e_select_names, EABModel *model, const char *uri) { EBook *book; - char *book_uri; - - book_uri = e_book_expand_uri (uri); /* If uri == the current uri, then we don't have to do anything */ - book = e_addressbook_model_get_ebook (model); + book = eab_model_get_ebook (model); if (book) { const gchar *current_uri = e_book_get_uri (book); - if (current_uri && !strcmp (book_uri, current_uri)) { - g_free (book_uri); + if (current_uri && !strcmp (uri, current_uri)) { return; } } @@ -152,25 +147,28 @@ addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model g_object_ref(e_select_names); g_object_ref(model); - addressbook_load_uri(book, book_uri, (EBookCallback) set_book, e_select_names); - - g_free (book_uri); + addressbook_load_uri(book, uri, (EBookCallback) set_book, e_select_names); } static void * -card_key (ECard *card) +contact_key (const EContact *contact) { - EBook *book; + EBook *book = NULL; const gchar *book_uri; - if (card == NULL) + if (contact == NULL) return NULL; - g_assert (E_IS_CARD (card)); + g_assert (E_IS_CONTACT (contact)); - book = e_card_get_book (card); +#if notyet + /* XXX we need a way to reproduce this here somehow.. or at + least make sure we never collide between two contacts in + different books. */ + book = e_contact_get_book (contact); +#endif book_uri = book ? e_book_get_uri (book) : "NoBook"; - return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", e_card_get_id (card)); + return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", (char*)e_contact_get_const ((EContact*)contact, E_CONTACT_UID)); } static void @@ -180,14 +178,14 @@ sync_one_model (gpointer k, gpointer val, gpointer closure) ESelectNamesChild *child = val; ESelectNamesModel *model = child->source; gint i, count; - ECard *card; + EContact *contact; void *key; count = e_select_names_model_count (model); for (i = 0; i < count; ++i) { - card = e_select_names_model_get_card (model, i); - if (card) { - key = card_key (card); + contact = e_select_names_model_get_contact (model, i); + if (contact) { + key = contact_key (contact); e_table_without_hide (etw, key); g_free (key); } @@ -206,21 +204,19 @@ real_add_address_cb (int model_row, gpointer closure) { ESelectNamesChild *child = closure; ESelectNames *names = child->names; - ECard *card; - EDestination *dest = e_destination_new (); + const EContact *contact; + EABDestination *dest = eab_destination_new (); gint mapped_row; mapped_row = e_table_subset_view_to_model_row (E_TABLE_SUBSET (names->without), model_row); - card = e_addressbook_model_get_card (E_ADDRESSBOOK_MODEL(names->model), mapped_row); + contact = eab_model_contact_at (EAB_MODEL(names->model), mapped_row); - if (card != NULL) { - e_destination_set_card (dest, card, 0); + if (contact != NULL) { + eab_destination_set_contact (dest, (EContact*)contact, 0); e_select_names_model_append (child->source, dest); e_select_names_model_clean (child->source, FALSE); - - g_object_unref(card); } } @@ -266,10 +262,9 @@ selection_change (ETable *table, ESelectNames *names) static void * esn_get_key_fn (ETableModel *source, int row, void *closure) { - EAddressbookModel *model = E_ADDRESSBOOK_MODEL (closure); - ECard *card = e_addressbook_model_get_card (model, row); - void *key = card_key (card); - g_object_unref (card); + EABModel *model = EAB_MODEL (closure); + const EContact *contact = eab_model_contact_at (model, row); + void *key = contact_key (contact); return key; } @@ -297,11 +292,11 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n { ETableModel *adapter; ETableModel *without; - EAddressbookModel *model; + EABModel *model; GtkWidget *table; - model = e_addressbook_model_new (); - adapter = E_TABLE_MODEL (e_addressbook_table_adapter_new (model)); + model = eab_model_new (); + adapter = E_TABLE_MODEL (eab_table_adapter_new (model)); g_object_set(model, "editable", FALSE, @@ -340,7 +335,7 @@ folder_selected (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder * { addressbook_model_set_uri(e_select_names, e_select_names->model, folder->physicalUri); - e_config_listener_set_string (e_book_get_config_database(), + e_config_listener_set_string (eab_get_config_database(), "/apps/evolution/addressbook/select_names/last_used_uri", folder->physicalUri); } @@ -392,7 +387,7 @@ update_query (GtkWidget *widget, ESelectNames *e_select_names) } static void -status_message (EAddressbookModel *model, const gchar *message, ESelectNames *e_select_names) +status_message (EABModel *model, const gchar *message, ESelectNames *e_select_names) { if (message == NULL) gtk_label_set_text (GTK_LABEL (e_select_names->status_message), ""); @@ -424,7 +419,7 @@ select_entry_changed (GtkWidget *widget, ESelectNames *e_select_names) int model_row = e_table_view_to_model_row (table, i); char *row_strcoll_string = g_utf8_collate_key (e_table_model_value_at (e_select_names->without, - E_CARD_SIMPLE_FIELD_NAME_OR_ORG, + E_CONTACT_FULL_NAME, model_row), -1); if (g_utf8_collate (select_strcoll_string, row_strcoll_string) <= 0) { @@ -637,12 +632,14 @@ e_select_names_new (EvolutionShellClient *shell_client) e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL); - db = e_book_get_config_database (); + db = eab_get_config_database (); contacts_uri = e_config_listener_get_string_with_default ( db, "/apps/evolution/addressbook/select_names/last_used_uri", NULL, NULL); +#if notyet if (!contacts_uri) contacts_uri = g_strdup (e_book_get_default_book_uri ()); +#endif button = glade_xml_get_widget (e_select_names->gui, "folder-selector"); evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button), diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h index 8e672da92a..e67f64b70b 100644 --- a/addressbook/gui/component/select-names/e-select-names.h +++ b/addressbook/gui/component/select-names/e-select-names.h @@ -67,7 +67,7 @@ struct _ESelectNames ETableScrolled *table; ETableModel *adapter; ETableModel *without; - EAddressbookModel *model; + EABModel *model; GtkWidget *categories; GtkWidget *select_entry; GtkWidget *status_message; diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.c b/addressbook/gui/component/select-names/e-simple-card-bonobo.c deleted file mode 100644 index 07203618b3..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli - * Chris Lahey - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "e-simple-card-bonobo.h" - -#include - -#include "Evolution-Addressbook-SelectNames.h" - - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -static BonoboObjectClass *parent_class = NULL; - -struct _ESimpleCardBonoboPrivate { - ECardSimple *card_simple; -}; - - - -static GNOME_Evolution_Addressbook_SimpleCard_Arbitrary * -impl_SimpleCard_get_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - GNOME_Evolution_Addressbook_SimpleCard_Arbitrary *ret_val = GNOME_Evolution_Addressbook_SimpleCard_Arbitrary__alloc (); - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - const ECardArbitrary *arbitrary = e_card_simple_get_arbitrary (priv->card_simple, key); - ret_val->key = CORBA_string_dup (arbitrary->key); - ret_val->value = CORBA_string_dup (arbitrary->value); - ret_val->type = CORBA_string_dup (arbitrary->type); - } else { - ret_val->key = CORBA_string_dup (""); - ret_val->value = CORBA_string_dup (""); - ret_val->type = CORBA_string_dup (""); - } - - return ret_val; -} - -static void -impl_SimpleCard_set_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - const CORBA_char *type, - const CORBA_char *value, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set_arbitrary (priv->card_simple, key, type, value); - } -} - -static CORBA_char * -impl_SimpleCard_get (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - char *value = e_card_simple_get (priv->card_simple, - field); - char *ret_val = CORBA_string_dup (value ? value : ""); - g_free (value); - return ret_val; - } else { - return CORBA_string_dup (""); - } -} - -static void -impl_SimpleCard_set (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - const CORBA_char *value, - CORBA_Environment *ev) -{ - - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set (priv->card_simple, - field, - value); - } -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (object); - priv = simple_card->priv; - - if (priv) { - if (priv->card_simple) { - g_object_unref (priv->card_simple); - } - - g_free (priv); - simple_card->priv = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - - -static void -e_simple_card_bonobo_class_init (ESimpleCardBonoboClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Addressbook_SimpleCard__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT); - - object_class->dispose = impl_dispose; - - epv = &klass->epv; - epv->getArbitrary = impl_SimpleCard_get_arbitrary; - epv->setArbitrary = impl_SimpleCard_set_arbitrary; - epv->get = impl_SimpleCard_get; - epv->set = impl_SimpleCard_set; -} - -static void -e_simple_card_bonobo_init (ESimpleCardBonobo *simple_card) -{ - ESimpleCardBonoboPrivate *priv; - - priv = g_new (ESimpleCardBonoboPrivate, 1); - - priv->card_simple = NULL; - - simple_card->priv = priv; -} - - -void -e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple) -{ - g_return_if_fail (simple_card != NULL); - g_return_if_fail (E_IS_SIMPLE_CARD_BONOBO (simple_card)); - - simple_card->priv->card_simple = card_simple; - g_object_ref (card_simple); -} - -ESimpleCardBonobo * -e_simple_card_bonobo_new (ECardSimple *card_simple) -{ - ESimpleCardBonobo *simple_card; - - simple_card = g_object_new (E_TYPE_SIMPLE_CARD_BONOBO, NULL); - - e_simple_card_bonobo_construct (simple_card, card_simple); - - return simple_card; -} - - -BONOBO_TYPE_FUNC_FULL ( - ESimpleCardBonobo, - GNOME_Evolution_Addressbook_SimpleCard, - PARENT_TYPE, - e_simple_card_bonobo); diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.h b/addressbook/gui/component/select-names/e-simple-card-bonobo.h deleted file mode 100644 index 7bc2d65830..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli - * Chris Lahey - */ - -#ifndef __E_SIMPLE_CARD_BONOBO_H__ -#define __E_SIMPLE_CARD_BONOBO_H__ - -#include - -#include "Evolution-Addressbook-SelectNames.h" -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SIMPLE_CARD_BONOBO (e_simple_card_bonobo_get_type ()) -#define E_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonobo)) -#define E_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonoboClass)) -#define E_IS_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIMPLE_CARD_BONOBO)) -#define E_IS_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SIMPLE_CARD_BONOBO)) - - -typedef struct _ESimpleCardBonobo ESimpleCardBonobo; -typedef struct _ESimpleCardBonoboPrivate ESimpleCardBonoboPrivate; -typedef struct _ESimpleCardBonoboClass ESimpleCardBonoboClass; - -struct _ESimpleCardBonobo { - BonoboObject parent; - - ESimpleCardBonoboPrivate *priv; -}; - -struct _ESimpleCardBonoboClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_SimpleCard__epv epv; -}; - - -GType e_simple_card_bonobo_get_type (void); -ESimpleCardBonobo *e_simple_card_bonobo_new (ECardSimple *card_simple); -void e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SIMPLE_CARD_BONOBO_H__ */ -- cgit v1.2.3