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 --- .../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 +- 4 files changed, 318 insertions(+), 413 deletions(-) (limited to 'addressbook/gui') 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