From e50f205a57976550dca90a19b1b2759264ff137c Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Fri, 20 Aug 2004 23:37:02 +0000 Subject: Fixes bug #62715. 2004-08-20 Hans Petter Jansson Fixes bug #62715. * gui/contact-editor/e-contact-editor.c (fill_in_address_label_textview): Implement. (fill_in_address_field): If structured address information is not available, try putting the "label" blob in the free-form field. svn path=/trunk/; revision=26980 --- addressbook/gui/contact-editor/e-contact-editor.c | 48 ++++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'addressbook/gui/contact-editor') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 180db61d24..80983691c3 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1649,6 +1649,21 @@ fill_in_address_textview (EContactEditor *editor, gint record, EContactAddress * gtk_text_buffer_insert (text_buffer, &iter, address->ext ? address->ext : "", -1); } +static void +fill_in_address_label_textview (EContactEditor *editor, gint record, const gchar *label) +{ + gchar *textview_name; + GtkWidget *textview; + GtkTextBuffer *text_buffer; + + textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); + textview = glade_xml_get_widget (editor->gui, textview_name); + g_free (textview_name); + + text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); + gtk_text_buffer_set_text (text_buffer, label ? label : "", -1); +} + static void fill_in_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, const gchar *string) @@ -1667,19 +1682,32 @@ static void fill_in_address_record (EContactEditor *editor, gint record) { EContactAddress *address; + gchar *address_label; address = e_contact_get (editor->contact, addresses [record]); - if (!address) - return; - - fill_in_address_textview (editor, record, address); - fill_in_address_field (editor, record, "city", address->locality); - fill_in_address_field (editor, record, "state", address->region); - fill_in_address_field (editor, record, "zip", address->code); - fill_in_address_field (editor, record, "country", address->country); - fill_in_address_field (editor, record, "pobox", address->po); + address_label = e_contact_get (editor->contact, address_labels [record]); + + if (address && + (!STRING_IS_EMPTY (address->street) || + !STRING_IS_EMPTY (address->ext) || + !STRING_IS_EMPTY (address->locality) || + !STRING_IS_EMPTY (address->region) || + !STRING_IS_EMPTY (address->code) || + !STRING_IS_EMPTY (address->po) || + !STRING_IS_EMPTY (address->country))) { + fill_in_address_textview (editor, record, address); + fill_in_address_field (editor, record, "city", address->locality); + fill_in_address_field (editor, record, "state", address->region); + fill_in_address_field (editor, record, "zip", address->code); + fill_in_address_field (editor, record, "country", address->country); + fill_in_address_field (editor, record, "pobox", address->po); + } else if (!STRING_IS_EMPTY (address_label)) { + fill_in_address_label_textview (editor, record, address_label); + } - g_boxed_free (e_contact_address_get_type (), address); + g_free (address_label); + if (address) + g_boxed_free (e_contact_address_get_type (), address); } static void -- cgit v1.2.3