From d24747d1b54305bbad38b0845e3d05a5401ed781 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 26 Apr 2000 21:47:51 +0000 Subject: Added an address label field. 2000-04-26 Christopher James Lahey * backend/ebook/e-card-types.h, backend/ebook/e-card.c, backend/ebook/e-card.h: Added an address label field. * contact-editor/contact-editor.glade, contact-editor/e-contact-editor-strings.h: Got rid of some unused fields. * contact-editor/e-contact-editor.c, contact-editor/e-contact-editor.h: Added the address label field. Load only. Editing these fields seems to mess things up. svn path=/trunk/; revision=2646 --- addressbook/ChangeLog | 13 + addressbook/backend/ebook/e-card-types.h | 2 +- addressbook/backend/ebook/e-card.c | 97 ++++- addressbook/backend/ebook/e-card.h | 7 +- addressbook/contact-editor/contact-editor.glade | 484 ++++++++------------- .../contact-editor/e-contact-editor-strings.h | 2 - addressbook/contact-editor/e-contact-editor.c | 243 ++++++----- addressbook/contact-editor/e-contact-editor.h | 2 +- .../gui/contact-editor/contact-editor.glade | 484 ++++++++------------- .../gui/contact-editor/e-contact-editor-strings.h | 2 - addressbook/gui/contact-editor/e-contact-editor.c | 243 ++++++----- addressbook/gui/contact-editor/e-contact-editor.h | 2 +- 12 files changed, 737 insertions(+), 844 deletions(-) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index d8a7152bb9..859932ff81 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2000-04-26 Christopher James Lahey + + * backend/ebook/e-card-types.h, backend/ebook/e-card.c, + backend/ebook/e-card.h: Added an address label field. + + * contact-editor/contact-editor.glade, + contact-editor/e-contact-editor-strings.h: Got rid of some unused + fields. + + * contact-editor/e-contact-editor.c, + contact-editor/e-contact-editor.h: Added the address label field. + Load only. Editing these fields seems to mess things up. + 2000-04-26 Christopher James Lahey * contact-editor/e-contact-editor.c: Added proper handling of the diff --git a/addressbook/backend/ebook/e-card-types.h b/addressbook/backend/ebook/e-card-types.h index d530f69f8b..eb39565aa6 100644 --- a/addressbook/backend/ebook/e-card-types.h +++ b/addressbook/backend/ebook/e-card-types.h @@ -200,12 +200,12 @@ typedef struct { char *country; } ECardDeliveryAddress; -#if 0 typedef struct { ECardAddressFlags flags; char *data; } ECardAddrLabel; +#if 0 /* ORGANIZATIONAL PROPERTIES */ typedef struct { diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c index 23c9df5d36..8c7139da79 100644 --- a/addressbook/backend/ebook/e-card.c +++ b/addressbook/backend/ebook/e-card.c @@ -28,6 +28,7 @@ enum { ARG_FULL_NAME, ARG_NAME, ARG_ADDRESS, + ARG_ADDRESS_LABEL, ARG_PHONE, ARG_EMAIL, ARG_BIRTH_DATE, @@ -65,6 +66,7 @@ static void parse_name(ECard *card, VObject *object); static void parse_email(ECard *card, VObject *object); static void parse_phone(ECard *card, VObject *object); static void parse_address(ECard *card, VObject *object); +static void parse_address_label(ECard *card, VObject *object); static void parse_url(ECard *card, VObject *object); static void parse_org(ECard *card, VObject *object); static void parse_title(ECard *card, VObject *object); @@ -86,20 +88,21 @@ struct { ParsePropertyFunc function; } attribute_jump_array[] = { - { VCFullNameProp, parse_full_name }, - { VCNameProp, parse_name }, - { VCBirthDateProp, parse_bday }, - { VCEmailAddressProp, parse_email }, - { VCTelephoneProp, parse_phone }, - { VCAdrProp, parse_address }, - { VCURLProp, parse_url }, - { VCOrgProp, parse_org }, - { VCTitleProp, parse_title }, - { VCBusinessRoleProp, parse_role }, - { "NICKNAME", parse_nickname }, - { "FBURL", parse_fburl }, - { VCNoteProp, parse_note }, - { VCUniqueStringProp, parse_id } + { VCFullNameProp, parse_full_name }, + { VCNameProp, parse_name }, + { VCBirthDateProp, parse_bday }, + { VCEmailAddressProp, parse_email }, + { VCTelephoneProp, parse_phone }, + { VCAdrProp, parse_address }, + { VCDeliveryLabelProp, parse_address_label }, + { VCURLProp, parse_url }, + { VCOrgProp, parse_org }, + { VCTitleProp, parse_title }, + { VCBusinessRoleProp, parse_role }, + { "NICKNAME", parse_nickname }, + { "FBURL", parse_fburl }, + { VCNoteProp, parse_note }, + { VCUniqueStringProp, parse_id } }; /** @@ -251,6 +254,22 @@ char gtk_object_unref(GTK_OBJECT(iterator)); } + if ( card->address_label ) { + ECardIterator *iterator = e_card_list_get_iterator(card->address_label); + for ( ; e_card_iterator_is_valid(iterator) ;e_card_iterator_next(iterator) ) { + VObject *labelprop; + ECardAddrLabel *address_label = (ECardAddrLabel *) e_card_iterator_get(iterator); + if (address_label->data) + labelprop = addPropValue(vobj, VCDeliveryLabelProp, address_label->data); + else + labelprop = addProp(vobj, VCDeliveryLabelProp); + + set_address_flags (labelprop, address_label->flags); + addProp(labelprop, VCQuotedPrintableProp); + } + gtk_object_unref(GTK_OBJECT(iterator)); + } + if ( card->phone ) { ECardIterator *iterator = e_card_list_get_iterator(card->phone); for ( ; e_card_iterator_is_valid(iterator) ;e_card_iterator_next(iterator) ) { @@ -506,6 +525,22 @@ parse_address(ECard *card, VObject *vobj) e_card_delivery_address_free (next_addr); } +static void +parse_address_label(ECard *card, VObject *vobj) +{ + ECardAddrLabel *next_addr = g_new(ECardAddrLabel, 1); + ECardList *list; + + next_addr->flags = get_address_flags (vobj); + assign_string(vobj, &next_addr->data); + + gtk_object_get(GTK_OBJECT(card), + "address_label", &list, + NULL); + e_card_list_append(list, next_addr); + e_card_address_label_free (next_addr); +} + static void parse_url(ECard *card, VObject *vobj) { @@ -619,6 +654,8 @@ e_card_class_init (ECardClass *klass) GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_NAME); gtk_object_add_arg_type ("ECard::address", GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS); + gtk_object_add_arg_type ("ECard::address_label", + GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS_LABEL); gtk_object_add_arg_type ("ECard::phone", GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_PHONE); gtk_object_add_arg_type ("ECard::email", @@ -712,6 +749,28 @@ e_card_delivery_address_copy (const ECardDeliveryAddress *addr) return NULL; } +void +e_card_address_label_free (ECardAddrLabel *addr) +{ + if ( addr ) { + if ( addr->data ) + g_free(addr->data); + g_free(addr); + } +} + +ECardAddrLabel * +e_card_address_label_copy (const ECardAddrLabel *addr) +{ + if ( addr ) { + ECardAddrLabel *addr_copy = g_new(ECardAddrLabel, 1); + addr_copy->data = g_strdup(addr->data); + addr_copy->flags = addr->flags; + return addr_copy; + } else + return NULL; +} + /* * ECard lifecycle management and vCard loading/saving. */ @@ -752,6 +811,8 @@ e_card_destroy (GtkObject *object) gtk_object_unref(GTK_OBJECT(card->phone)); if (card->address) gtk_object_unref(GTK_OBJECT(card->address)); + if (card->address_label) + gtk_object_unref(GTK_OBJECT(card->address_label)); } @@ -851,6 +912,13 @@ e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) NULL); GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address); break; + case ARG_ADDRESS_LABEL: + if (!card->address_label) + card->address_label = e_card_list_new((ECardListCopyFunc) e_card_address_label_copy, + (ECardListFreeFunc) e_card_address_label_free, + NULL); + GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address_label); + break; case ARG_PHONE: if (!card->phone) card->phone = e_card_list_new((ECardListCopyFunc) e_card_phone_copy, @@ -916,6 +984,7 @@ e_card_init (ECard *card) card->email = NULL; card->phone = NULL; card->address = NULL; + card->address_label = NULL; card->url = NULL; card->org = NULL; card->org_unit = NULL; diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h index b10585c4a8..774c327371 100644 --- a/addressbook/backend/ebook/e-card.h +++ b/addressbook/backend/ebook/e-card.h @@ -34,10 +34,9 @@ struct _ECard { char *fname; /* The full name. */ ECardName *name; /* The structured name. */ ECardList *address; /* Delivery addresses (ECardDeliveryAddress *) */ -#if 0 - GList *del_labels; /* Delivery address labels + ECardList *address_label; /* Delivery address labels * (ECardAddrLabel *) */ -#endif + ECardList *phone; /* Phone numbers (ECardPhone *) */ ECardList *email; /* Email addresses (char *) */ char *url; /* The person's web page. */ @@ -106,6 +105,8 @@ void e_card_phone_free (ECardPhone *phone); ECardPhone *e_card_phone_copy (const ECardPhone *phone); void e_card_delivery_address_free (ECardDeliveryAddress *addr); ECardDeliveryAddress *e_card_delivery_address_copy (const ECardDeliveryAddress *addr); +void e_card_address_label_free (ECardAddrLabel *addr); +ECardAddrLabel *e_card_address_label_copy (const ECardAddrLabel *addr); /* Standard Gtk function */ diff --git a/addressbook/contact-editor/contact-editor.glade b/addressbook/contact-editor/contact-editor.glade index 139e652056..cd17ffd288 100644 --- a/addressbook/contact-editor/contact-editor.glade +++ b/addressbook/contact-editor/contact-editor.glade @@ -47,7 +47,7 @@ GtkTable table-contact-editor-general 7 - 12 + 11 8 False 4 @@ -149,54 +149,6 @@ - - GtkEntry - entry-fullname - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-web - True - True - True - 0 - - - 3 - 4 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - GtkLabel label-phone3 @@ -483,7 +435,7 @@ 0 0 - 8 + 7 10 11 0 @@ -527,81 +479,6 @@ - - GtkHBox - hbox3 - False - 6 - - 0 - 8 - 11 - 12 - 0 - 0 - True - False - False - False - True - True - - - - GtkButton - button-contacts - True - - - 0 - False - False - - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button-categories - True - - - 0 - False - False - - - - - GtkEntry - entry-categories - True - True - True - 0 - - - 0 - False - False - - - - GtkAlignment alignment2 @@ -655,141 +532,6 @@ - - GtkEntry - entry-jobtitle - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-company - True - True - True - 0 - - - 3 - 4 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCombo - combo-fileas - True - False - True - True - True - False - - - 3 - 4 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-fileas - True - True - True - 0 - - - - - - GtkHBox - hbox4 - False - 4 - - 3 - 4 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - entry-email1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button23 - - 0 - False - False - - - - Placeholder - - - - GtkAlignment alignment3 @@ -978,12 +720,12 @@ GtkHSeparator - hseparator6 + hseparator4 - 0 - 4 - 7 - 8 + 4 + 8 + 4 + 5 0 2 True @@ -991,20 +733,153 @@ False False True + False + + + + + GtkAlignment + alignment6 + 1 + 0.5 + 0 + 0 + + 6 + 7 + 2 + 3 + 0 + 0 + False + False + False + False + True True + + + GtkButton + button-phone3 + + + Placeholder + + - GtkHSeparator - hseparator4 + GtkEntry + entry-fullname + True + True + True + 0 + - 4 - 8 - 4 - 5 + 3 + 4 + 0 + 1 0 - 2 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-jobtitle + True + True + True + 0 + + + 3 + 4 + 1 + 2 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-company + True + True + True + 0 + + + 3 + 4 + 2 + 3 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-email1 + True + True + True + 0 + + + 3 + 4 + 5 + 6 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-web + True + True + True + 0 + + + 3 + 4 + 8 + 9 + 0 + 0 True False False @@ -1034,37 +909,60 @@ - GtkAlignment - alignment6 - 1 - 0.5 - 0 - 0 + GtkCombo + combo-fileas + False + True + True + True + False + - 6 - 7 - 2 - 3 + 3 + 4 + 3 + 4 0 0 - False + True False False False True - True + False - GtkButton - button-phone3 - - - Placeholder - + GtkEntry + GtkCombo:entry + combo-entry1 + True + True + True + 0 + + + GtkHSeparator + hseparator6 + + 0 + 4 + 7 + 8 + 0 + 2 + True + False + False + False + True + True + + + GtkCheckButton checkbutton-htmlmail @@ -1081,10 +979,10 @@ 0 True False - False - False + True + True True - False + True diff --git a/addressbook/contact-editor/e-contact-editor-strings.h b/addressbook/contact-editor/e-contact-editor-strings.h index 28fce326e1..7f0a8a83f1 100644 --- a/addressbook/contact-editor/e-contact-editor-strings.h +++ b/addressbook/contact-editor/e-contact-editor-strings.h @@ -15,8 +15,6 @@ gchar *s = N_("Job Title:"); gchar *s = N_("Company:"); gchar *s = N_("File As:"); gchar *s = N_("Web page address:"); -gchar *s = N_("Contacts..."); -gchar *s = N_("Categories..."); gchar *s = N_("This is the mailing address"); gchar *s = N_("A_ddress..."); gchar *s = N_("Business"); diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c index f12660be18..91339e9da3 100644 --- a/addressbook/contact-editor/e-contact-editor.c +++ b/addressbook/contact-editor/e-contact-editor.c @@ -76,14 +76,12 @@ ECardPhoneFlags phone_correspondences[] = { 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TTYTTD, */ }; -#if 0 -enum _EContactEditorAddressId { - E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, - E_CONTACT_EDITOR_ADDRESS_ID_HOME, - E_CONTACT_EDITOR_ADDRESS_ID_OTHER, +ECardAddressFlags addr_correspondences[] = { + E_CARD_ADDR_WORK, /* E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, */ + E_CARD_ADDR_HOME, /* E_CONTACT_EDITOR_ADDRESS_ID_HOME, */ + E_CARD_ADDR_POSTAL, /* E_CONTACT_EDITOR_ADDRESS_ID_OTHER, */ E_CONTACT_EDITOR_ADDRESS_ID_LAST }; -#endif GtkType e_contact_editor_get_type (void) @@ -161,8 +159,7 @@ _add_details_images(GtkTable *table) { _add_image(table, DATADIR "/evolution/briefcase.png", 0, 1, 0, 2); _add_image(table, DATADIR "/evolution/head.png", 0, 1, 4, 6); - _add_image(table, DATADIR "/evolution/netmeeting.png", 0, 1, 7, 9); - _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 10, 12); + _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 7, 9); } static void @@ -191,7 +188,7 @@ _replace_buttons(EContactEditor *editor) } static void -phone_label_changed (GtkWidget *widget, EContactEditor *editor) +phone_entry_changed (GtkWidget *widget, EContactEditor *editor) { int which; gchar *string; @@ -208,30 +205,21 @@ phone_label_changed (GtkWidget *widget, EContactEditor *editor) } else return; string = gtk_entry_get_text(entry); - if (string) { - if (editor->phone[editor->phone_choice[which - 1]]) { - if (editor->phone[editor->phone_choice[which - 1]]->number) - g_free(editor->phone[editor->phone_choice[which - 1]]->number); - editor->phone[editor->phone_choice[which - 1]]->number = NULL; - } else { - editor->phone[editor->phone_choice[which - 1]] = g_new(ECardPhone, 1); - editor->phone[editor->phone_choice[which - 1]]->number = NULL; - editor->phone[editor->phone_choice[which - 1]]->flags = 0; - } - editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string); + if (editor->phone[editor->phone_choice[which - 1]]) { + if (editor->phone[editor->phone_choice[which - 1]]->number) + g_free(editor->phone[editor->phone_choice[which - 1]]->number); + editor->phone[editor->phone_choice[which - 1]]->number = NULL; } else { - if (editor->phone[editor->phone_choice[which - 1]]) { - if (editor->phone[editor->phone_choice[which - 1]]->number) { - g_free(editor->phone[editor->phone_choice[which - 1]]->number); - editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(""); - } - } + editor->phone[editor->phone_choice[which - 1]] = g_new(ECardPhone, 1); + editor->phone[editor->phone_choice[which - 1]]->number = NULL; + editor->phone[editor->phone_choice[which - 1]]->flags = 0; } + editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string); set_fields(editor); } static void -email_label_changed (GtkWidget *widget, EContactEditor *editor) +email_entry_changed (GtkWidget *widget, EContactEditor *editor) { gchar *string; GtkEntry *entry = GTK_ENTRY(widget); @@ -244,8 +232,31 @@ email_label_changed (GtkWidget *widget, EContactEditor *editor) string = gtk_entry_get_text(entry); editor->email[editor->email_choice] = g_strdup(string); +} - set_fields(editor); +static void +address_text_changed (GtkWidget *widget, EContactEditor *editor) +{ + gchar *string; + GtkEditable *editable = GTK_EDITABLE(widget); + + if (editor->address[editor->address_choice]) { + g_free(editor->address[editor->address_choice]); + editor->address[editor->address_choice] = NULL; + } + + string = gtk_editable_get_chars(editable, 0, -1); + if (editor->address[editor->address_choice]) { + if (editor->address[editor->address_choice]->data) + g_free(editor->address[editor->address_choice]->data); + editor->address[editor->address_choice]->data = NULL; + } else { + editor->address[editor->address_choice] = g_new(ECardAddrLabel, 1); + editor->address[editor->address_choice]->data = NULL; + editor->address[editor->address_choice]->flags = 0; + } + editor->address[editor->address_choice]->data = g_strdup(string); + g_free(string); } static void @@ -253,7 +264,7 @@ set_entry_changed_signal_phone(EContactEditor *editor, char *id) { GtkWidget *widget = glade_xml_get_widget(editor->gui, id); gtk_signal_connect(GTK_OBJECT(widget), "changed", - phone_label_changed, editor); + phone_entry_changed, editor); } static void @@ -266,7 +277,10 @@ set_entry_changed_signals(EContactEditor *editor) set_entry_changed_signal_phone(editor, "entry-phone4"); widget = glade_xml_get_widget(editor->gui, "entry-email1"); gtk_signal_connect(GTK_OBJECT(widget), "changed", - email_label_changed, editor); + email_entry_changed, editor); + widget = glade_xml_get_widget(editor->gui, "text-address"); + gtk_signal_connect(GTK_OBJECT(widget), "changed", + address_text_changed, editor); } static void @@ -699,8 +713,12 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito editor->address_popup = gnome_popup_menu_new(editor->address_info); } - result = _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type"); - result ++; + result = _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "text-address", "Add new Address type"); + + if (result != -1) { + editor->address_choice = result; + set_fields(editor); + } } static void @@ -715,6 +733,9 @@ static void set_fields(EContactEditor *editor) { GtkEntry *entry; + GtkEditable *editable; + char *string = NULL; + int position; entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone1")); if (editor->phone[editor->phone_choice[0]]) @@ -731,6 +752,7 @@ set_fields(EContactEditor *editor) set_field(entry, editor->phone[editor->phone_choice[2]]->number); else set_field(entry, ""); + entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone4")); if (editor->phone[editor->phone_choice[3]]) set_field(entry, editor->phone[editor->phone_choice[3]]->number); @@ -741,6 +763,17 @@ set_fields(EContactEditor *editor) set_field(entry, editor->email[editor->email_choice]); else set_field(entry, ""); + + if (editor->address[editor->address_choice]) { + string = g_strdup (editor->address[editor->address_choice]->data); + } + position = 0; + editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); + gtk_editable_delete_text(editable, 0, -1); + if (string) { + gtk_editable_insert_text(editable, string, strlen(string), &position); + g_free(string); + } } static void @@ -763,25 +796,26 @@ fill_in_info(EContactEditor *editor) const ECardPhone *phone; const char *email; const ECardDate *bday; + const ECardAddrLabel *address; GtkEditable *editable; int position = 0; ECardIterator *iterator; gtk_object_get(GTK_OBJECT(card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "note", ¬e, - "birth_date", &bday, + "full_name", &fname, + "address_label", &address_list, + "phone", &phone_list, + "email", &email_list, + "url", &url, + "org", &org, + "org_unit", &org_unit, + "title", &title, + "role", &role, + "nickname", &nickname, + "fburl", &fburl, + "note", ¬e, + "birth_date", &bday, NULL); position = 0; @@ -789,39 +823,7 @@ fill_in_info(EContactEditor *editor) gtk_editable_delete_text(editable, 0, -1); if (fname) gtk_editable_insert_text(editable, fname, strlen(fname), &position); -#if 0 - position = 0; - iterator = e_card_list_get_iterator(address_list); - for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - address = e_card_iterator_get(iterator); - if (address->flags & E_CARD_ADDR_WORK) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS] = - e_card_delivery_address_copy(address); - } - if (address->flags & E_CARD_ADDR_HOME) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME] = - e_card_delivery_address_copy(address); - } - if (address->flags & E_CARD_ADDR_PARCEL) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER] = - e_card_delivery_address_copy(address); - } - } - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - gtk_editable_delete_text(editable, 0, -1); - if (address) - gtk_editable_insert_text(editable, address->city, strlen(address->city), &position); - gtk_object_unref(GTK_OBJECT(iterator)); -#endif + for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { int i; phone = e_card_iterator_get(iterator); @@ -846,6 +848,18 @@ fill_in_info(EContactEditor *editor) } gtk_object_unref(GTK_OBJECT(iterator)); + for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { + int i; + address = e_card_iterator_get(iterator); + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (editor->address[i] == NULL)) { + editor->address[i] = e_card_address_label_copy(address); + break; + } + } + } + gtk_object_unref(GTK_OBJECT(iterator)); + position = 0; editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); gtk_editable_delete_text(editable, 0, -1); @@ -927,6 +941,7 @@ extract_info(EContactEditor *editor) char *fburl; char *note; const ECardPhone *phone; + const ECardAddrLabel *address; const char *email; ECardDate *bday; GtkEditable *editable; @@ -940,9 +955,9 @@ extract_info(EContactEditor *editor) ECardIterator *iterator; gtk_object_get(GTK_OBJECT(card), - "address", &address_list, - "phone", &phone_list, - "email", &email_list, + "address_label", &address_list, + "phone", &phone_list, + "email", &email_list, NULL); position = 0; @@ -953,29 +968,6 @@ extract_info(EContactEditor *editor) "full_name", fname, NULL); g_free(fname); -#if 0 - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (address) { - address_copy = e_card_delivery_address_copy(address); - if (address_copy->city) - g_free(address_copy->city); - address_copy->city = string; - e_card_iterator_set(iterator, address_copy); - e_card_delivery_address_free(address_copy); - } else { - address_copy = g_new0(ECardDeliveryAddress, 1); - address_copy->city = string; - e_card_list_append(address_list, address_copy); - e_card_delivery_address_free(address_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); -#endif for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) { int i; @@ -1033,20 +1025,37 @@ extract_info(EContactEditor *editor) editor->email[i] = NULL; } } -#if 0 - position = 0; - iterator = e_card_list_get_iterator(email_list); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - email = gtk_editable_get_chars(editable, 0, -1); - if (email && *email) { - if (e_card_iterator_is_valid(iterator)) - e_card_iterator_set(iterator, email); - else - e_card_list_append(email_list, email); - } - g_free(email); + + for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) { + int i; + address = e_card_iterator_get(iterator); + iterator_next = 1; + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) { + if (editor->address[i]) { + if (editor->address[i]->data && *editor->address[i]->data) { + e_card_iterator_set(iterator, editor->address[i]); + } else { + e_card_iterator_delete(iterator); + iterator_next = 0; + } + e_card_address_label_free(editor->address[i]); + editor->address[i] = NULL; + break; + } + } + } + } gtk_object_unref(GTK_OBJECT(iterator)); -#endif + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if (editor->address[i]) { + editor->address[i]->flags = addr_correspondences[i]; + e_card_list_append(address_list, editor->address[i]); + e_card_address_label_free(editor->address[i]); + editor->address[i] = NULL; + } + } + position = 0; editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); url = gtk_editable_get_chars(editable, 0, -1); diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h index fd80dc4c00..394d136eed 100644 --- a/addressbook/contact-editor/e-contact-editor.h +++ b/addressbook/contact-editor/e-contact-editor.h @@ -112,7 +112,7 @@ struct _EContactEditor ECardPhone *phone[E_CONTACT_EDITOR_PHONE_ID_LAST]; char *email[E_CONTACT_EDITOR_EMAIL_ID_LAST]; - ECardDeliveryAddress *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST]; + ECardAddrLabel *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST]; EContactEditorEmailId email_choice; EContactEditorPhoneId phone_choice[4]; diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade index 139e652056..cd17ffd288 100644 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ b/addressbook/gui/contact-editor/contact-editor.glade @@ -47,7 +47,7 @@ GtkTable table-contact-editor-general 7 - 12 + 11 8 False 4 @@ -149,54 +149,6 @@ - - GtkEntry - entry-fullname - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-web - True - True - True - 0 - - - 3 - 4 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - GtkLabel label-phone3 @@ -483,7 +435,7 @@ 0 0 - 8 + 7 10 11 0 @@ -527,81 +479,6 @@ - - GtkHBox - hbox3 - False - 6 - - 0 - 8 - 11 - 12 - 0 - 0 - True - False - False - False - True - True - - - - GtkButton - button-contacts - True - - - 0 - False - False - - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button-categories - True - - - 0 - False - False - - - - - GtkEntry - entry-categories - True - True - True - 0 - - - 0 - False - False - - - - GtkAlignment alignment2 @@ -655,141 +532,6 @@ - - GtkEntry - entry-jobtitle - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-company - True - True - True - 0 - - - 3 - 4 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCombo - combo-fileas - True - False - True - True - True - False - - - 3 - 4 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-fileas - True - True - True - 0 - - - - - - GtkHBox - hbox4 - False - 4 - - 3 - 4 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - entry-email1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button23 - - 0 - False - False - - - - Placeholder - - - - GtkAlignment alignment3 @@ -978,12 +720,12 @@ GtkHSeparator - hseparator6 + hseparator4 - 0 - 4 - 7 - 8 + 4 + 8 + 4 + 5 0 2 True @@ -991,20 +733,153 @@ False False True + False + + + + + GtkAlignment + alignment6 + 1 + 0.5 + 0 + 0 + + 6 + 7 + 2 + 3 + 0 + 0 + False + False + False + False + True True + + + GtkButton + button-phone3 + + + Placeholder + + - GtkHSeparator - hseparator4 + GtkEntry + entry-fullname + True + True + True + 0 + - 4 - 8 - 4 - 5 + 3 + 4 + 0 + 1 0 - 2 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-jobtitle + True + True + True + 0 + + + 3 + 4 + 1 + 2 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-company + True + True + True + 0 + + + 3 + 4 + 2 + 3 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-email1 + True + True + True + 0 + + + 3 + 4 + 5 + 6 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + entry-web + True + True + True + 0 + + + 3 + 4 + 8 + 9 + 0 + 0 True False False @@ -1034,37 +909,60 @@ - GtkAlignment - alignment6 - 1 - 0.5 - 0 - 0 + GtkCombo + combo-fileas + False + True + True + True + False + - 6 - 7 - 2 - 3 + 3 + 4 + 3 + 4 0 0 - False + True False False False True - True + False - GtkButton - button-phone3 - - - Placeholder - + GtkEntry + GtkCombo:entry + combo-entry1 + True + True + True + 0 + + + GtkHSeparator + hseparator6 + + 0 + 4 + 7 + 8 + 0 + 2 + True + False + False + False + True + True + + + GtkCheckButton checkbutton-htmlmail @@ -1081,10 +979,10 @@ 0 True False - False - False + True + True True - False + True diff --git a/addressbook/gui/contact-editor/e-contact-editor-strings.h b/addressbook/gui/contact-editor/e-contact-editor-strings.h index 28fce326e1..7f0a8a83f1 100644 --- a/addressbook/gui/contact-editor/e-contact-editor-strings.h +++ b/addressbook/gui/contact-editor/e-contact-editor-strings.h @@ -15,8 +15,6 @@ gchar *s = N_("Job Title:"); gchar *s = N_("Company:"); gchar *s = N_("File As:"); gchar *s = N_("Web page address:"); -gchar *s = N_("Contacts..."); -gchar *s = N_("Categories..."); gchar *s = N_("This is the mailing address"); gchar *s = N_("A_ddress..."); gchar *s = N_("Business"); diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index f12660be18..91339e9da3 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -76,14 +76,12 @@ ECardPhoneFlags phone_correspondences[] = { 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TTYTTD, */ }; -#if 0 -enum _EContactEditorAddressId { - E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, - E_CONTACT_EDITOR_ADDRESS_ID_HOME, - E_CONTACT_EDITOR_ADDRESS_ID_OTHER, +ECardAddressFlags addr_correspondences[] = { + E_CARD_ADDR_WORK, /* E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, */ + E_CARD_ADDR_HOME, /* E_CONTACT_EDITOR_ADDRESS_ID_HOME, */ + E_CARD_ADDR_POSTAL, /* E_CONTACT_EDITOR_ADDRESS_ID_OTHER, */ E_CONTACT_EDITOR_ADDRESS_ID_LAST }; -#endif GtkType e_contact_editor_get_type (void) @@ -161,8 +159,7 @@ _add_details_images(GtkTable *table) { _add_image(table, DATADIR "/evolution/briefcase.png", 0, 1, 0, 2); _add_image(table, DATADIR "/evolution/head.png", 0, 1, 4, 6); - _add_image(table, DATADIR "/evolution/netmeeting.png", 0, 1, 7, 9); - _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 10, 12); + _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 7, 9); } static void @@ -191,7 +188,7 @@ _replace_buttons(EContactEditor *editor) } static void -phone_label_changed (GtkWidget *widget, EContactEditor *editor) +phone_entry_changed (GtkWidget *widget, EContactEditor *editor) { int which; gchar *string; @@ -208,30 +205,21 @@ phone_label_changed (GtkWidget *widget, EContactEditor *editor) } else return; string = gtk_entry_get_text(entry); - if (string) { - if (editor->phone[editor->phone_choice[which - 1]]) { - if (editor->phone[editor->phone_choice[which - 1]]->number) - g_free(editor->phone[editor->phone_choice[which - 1]]->number); - editor->phone[editor->phone_choice[which - 1]]->number = NULL; - } else { - editor->phone[editor->phone_choice[which - 1]] = g_new(ECardPhone, 1); - editor->phone[editor->phone_choice[which - 1]]->number = NULL; - editor->phone[editor->phone_choice[which - 1]]->flags = 0; - } - editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string); + if (editor->phone[editor->phone_choice[which - 1]]) { + if (editor->phone[editor->phone_choice[which - 1]]->number) + g_free(editor->phone[editor->phone_choice[which - 1]]->number); + editor->phone[editor->phone_choice[which - 1]]->number = NULL; } else { - if (editor->phone[editor->phone_choice[which - 1]]) { - if (editor->phone[editor->phone_choice[which - 1]]->number) { - g_free(editor->phone[editor->phone_choice[which - 1]]->number); - editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(""); - } - } + editor->phone[editor->phone_choice[which - 1]] = g_new(ECardPhone, 1); + editor->phone[editor->phone_choice[which - 1]]->number = NULL; + editor->phone[editor->phone_choice[which - 1]]->flags = 0; } + editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string); set_fields(editor); } static void -email_label_changed (GtkWidget *widget, EContactEditor *editor) +email_entry_changed (GtkWidget *widget, EContactEditor *editor) { gchar *string; GtkEntry *entry = GTK_ENTRY(widget); @@ -244,8 +232,31 @@ email_label_changed (GtkWidget *widget, EContactEditor *editor) string = gtk_entry_get_text(entry); editor->email[editor->email_choice] = g_strdup(string); +} - set_fields(editor); +static void +address_text_changed (GtkWidget *widget, EContactEditor *editor) +{ + gchar *string; + GtkEditable *editable = GTK_EDITABLE(widget); + + if (editor->address[editor->address_choice]) { + g_free(editor->address[editor->address_choice]); + editor->address[editor->address_choice] = NULL; + } + + string = gtk_editable_get_chars(editable, 0, -1); + if (editor->address[editor->address_choice]) { + if (editor->address[editor->address_choice]->data) + g_free(editor->address[editor->address_choice]->data); + editor->address[editor->address_choice]->data = NULL; + } else { + editor->address[editor->address_choice] = g_new(ECardAddrLabel, 1); + editor->address[editor->address_choice]->data = NULL; + editor->address[editor->address_choice]->flags = 0; + } + editor->address[editor->address_choice]->data = g_strdup(string); + g_free(string); } static void @@ -253,7 +264,7 @@ set_entry_changed_signal_phone(EContactEditor *editor, char *id) { GtkWidget *widget = glade_xml_get_widget(editor->gui, id); gtk_signal_connect(GTK_OBJECT(widget), "changed", - phone_label_changed, editor); + phone_entry_changed, editor); } static void @@ -266,7 +277,10 @@ set_entry_changed_signals(EContactEditor *editor) set_entry_changed_signal_phone(editor, "entry-phone4"); widget = glade_xml_get_widget(editor->gui, "entry-email1"); gtk_signal_connect(GTK_OBJECT(widget), "changed", - email_label_changed, editor); + email_entry_changed, editor); + widget = glade_xml_get_widget(editor->gui, "text-address"); + gtk_signal_connect(GTK_OBJECT(widget), "changed", + address_text_changed, editor); } static void @@ -699,8 +713,12 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito editor->address_popup = gnome_popup_menu_new(editor->address_info); } - result = _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type"); - result ++; + result = _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "text-address", "Add new Address type"); + + if (result != -1) { + editor->address_choice = result; + set_fields(editor); + } } static void @@ -715,6 +733,9 @@ static void set_fields(EContactEditor *editor) { GtkEntry *entry; + GtkEditable *editable; + char *string = NULL; + int position; entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone1")); if (editor->phone[editor->phone_choice[0]]) @@ -731,6 +752,7 @@ set_fields(EContactEditor *editor) set_field(entry, editor->phone[editor->phone_choice[2]]->number); else set_field(entry, ""); + entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone4")); if (editor->phone[editor->phone_choice[3]]) set_field(entry, editor->phone[editor->phone_choice[3]]->number); @@ -741,6 +763,17 @@ set_fields(EContactEditor *editor) set_field(entry, editor->email[editor->email_choice]); else set_field(entry, ""); + + if (editor->address[editor->address_choice]) { + string = g_strdup (editor->address[editor->address_choice]->data); + } + position = 0; + editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); + gtk_editable_delete_text(editable, 0, -1); + if (string) { + gtk_editable_insert_text(editable, string, strlen(string), &position); + g_free(string); + } } static void @@ -763,25 +796,26 @@ fill_in_info(EContactEditor *editor) const ECardPhone *phone; const char *email; const ECardDate *bday; + const ECardAddrLabel *address; GtkEditable *editable; int position = 0; ECardIterator *iterator; gtk_object_get(GTK_OBJECT(card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "note", ¬e, - "birth_date", &bday, + "full_name", &fname, + "address_label", &address_list, + "phone", &phone_list, + "email", &email_list, + "url", &url, + "org", &org, + "org_unit", &org_unit, + "title", &title, + "role", &role, + "nickname", &nickname, + "fburl", &fburl, + "note", ¬e, + "birth_date", &bday, NULL); position = 0; @@ -789,39 +823,7 @@ fill_in_info(EContactEditor *editor) gtk_editable_delete_text(editable, 0, -1); if (fname) gtk_editable_insert_text(editable, fname, strlen(fname), &position); -#if 0 - position = 0; - iterator = e_card_list_get_iterator(address_list); - for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - address = e_card_iterator_get(iterator); - if (address->flags & E_CARD_ADDR_WORK) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS] = - e_card_delivery_address_copy(address); - } - if (address->flags & E_CARD_ADDR_HOME) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_HOME] = - e_card_delivery_address_copy(address); - } - if (address->flags & E_CARD_ADDR_PARCEL) { - if (editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER]) { - e_card_delivery_address_free(editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER]); - } - editor->address[E_CONTACT_EDITOR_ADDRESS_ID_OTHER] = - e_card_delivery_address_copy(address); - } - } - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - gtk_editable_delete_text(editable, 0, -1); - if (address) - gtk_editable_insert_text(editable, address->city, strlen(address->city), &position); - gtk_object_unref(GTK_OBJECT(iterator)); -#endif + for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { int i; phone = e_card_iterator_get(iterator); @@ -846,6 +848,18 @@ fill_in_info(EContactEditor *editor) } gtk_object_unref(GTK_OBJECT(iterator)); + for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { + int i; + address = e_card_iterator_get(iterator); + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (editor->address[i] == NULL)) { + editor->address[i] = e_card_address_label_copy(address); + break; + } + } + } + gtk_object_unref(GTK_OBJECT(iterator)); + position = 0; editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); gtk_editable_delete_text(editable, 0, -1); @@ -927,6 +941,7 @@ extract_info(EContactEditor *editor) char *fburl; char *note; const ECardPhone *phone; + const ECardAddrLabel *address; const char *email; ECardDate *bday; GtkEditable *editable; @@ -940,9 +955,9 @@ extract_info(EContactEditor *editor) ECardIterator *iterator; gtk_object_get(GTK_OBJECT(card), - "address", &address_list, - "phone", &phone_list, - "email", &email_list, + "address_label", &address_list, + "phone", &phone_list, + "email", &email_list, NULL); position = 0; @@ -953,29 +968,6 @@ extract_info(EContactEditor *editor) "full_name", fname, NULL); g_free(fname); -#if 0 - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (address) { - address_copy = e_card_delivery_address_copy(address); - if (address_copy->city) - g_free(address_copy->city); - address_copy->city = string; - e_card_iterator_set(iterator, address_copy); - e_card_delivery_address_free(address_copy); - } else { - address_copy = g_new0(ECardDeliveryAddress, 1); - address_copy->city = string; - e_card_list_append(address_list, address_copy); - e_card_delivery_address_free(address_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); -#endif for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) { int i; @@ -1033,20 +1025,37 @@ extract_info(EContactEditor *editor) editor->email[i] = NULL; } } -#if 0 - position = 0; - iterator = e_card_list_get_iterator(email_list); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - email = gtk_editable_get_chars(editable, 0, -1); - if (email && *email) { - if (e_card_iterator_is_valid(iterator)) - e_card_iterator_set(iterator, email); - else - e_card_list_append(email_list, email); - } - g_free(email); + + for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) { + int i; + address = e_card_iterator_get(iterator); + iterator_next = 1; + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) { + if (editor->address[i]) { + if (editor->address[i]->data && *editor->address[i]->data) { + e_card_iterator_set(iterator, editor->address[i]); + } else { + e_card_iterator_delete(iterator); + iterator_next = 0; + } + e_card_address_label_free(editor->address[i]); + editor->address[i] = NULL; + break; + } + } + } + } gtk_object_unref(GTK_OBJECT(iterator)); -#endif + for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) { + if (editor->address[i]) { + editor->address[i]->flags = addr_correspondences[i]; + e_card_list_append(address_list, editor->address[i]); + e_card_address_label_free(editor->address[i]); + editor->address[i] = NULL; + } + } + position = 0; editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); url = gtk_editable_get_chars(editable, 0, -1); diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h index fd80dc4c00..394d136eed 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ b/addressbook/gui/contact-editor/e-contact-editor.h @@ -112,7 +112,7 @@ struct _EContactEditor ECardPhone *phone[E_CONTACT_EDITOR_PHONE_ID_LAST]; char *email[E_CONTACT_EDITOR_EMAIL_ID_LAST]; - ECardDeliveryAddress *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST]; + ECardAddrLabel *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST]; EContactEditorEmailId email_choice; EContactEditorPhoneId phone_choice[4]; -- cgit