From ffdf0418892ce8051b35113b05f62047823ba363 Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Wed, 5 May 2004 06:24:11 +0000 Subject: Implement. (init_address_record): Init textview. 2004-05-05 Hans Petter Jansson * gui/contact-editor/e-contact-editor.c (init_address_textview): Implement. (init_address_record): Init textview. (fill_in_address_textview): Implement. (fill_in_address_record): Fill in textview. (extract_address_textview): Implement. (extract_address_record): Extract from textview. * gui/contact-editor/contact-editor.glade: Combine address-[12] fields into one multiline text view, as per Anna's new design. svn path=/trunk/; revision=25800 --- addressbook/ChangeLog | 13 + .../gui/contact-editor/contact-editor.glade | 452 +++++++++------------ addressbook/gui/contact-editor/e-contact-editor.c | 82 +++- 3 files changed, 270 insertions(+), 277 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index e44af7f69f..49675d5460 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2004-05-05 Hans Petter Jansson + + * gui/contact-editor/e-contact-editor.c (init_address_textview): + Implement. + (init_address_record): Init textview. + (fill_in_address_textview): Implement. + (fill_in_address_record): Fill in textview. + (extract_address_textview): Implement. + (extract_address_record): Extract from textview. + + * gui/contact-editor/contact-editor.glade: Combine address-[12] fields + into one multiline text view, as per Anna's new design. + 2004-05-04 Larry Ewing * gui/component/addressbook-config.c (query_for_supported_bases): diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade index 4e0fa61c6c..a25ae8fb9b 100644 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ b/addressbook/gui/contact-editor/contact-editor.glade @@ -2324,9 +2324,9 @@ 6 - + True - Address: + City: False False GTK_JUSTIFY_LEFT @@ -2338,8 +2338,8 @@ 0 - 0 - 1 + 2 + 3 0 1 fill @@ -2348,7 +2348,7 @@ - + True True True @@ -2360,7 +2360,7 @@ False - 1 + 3 4 0 1 @@ -2369,22 +2369,22 @@ - + True - Address 2: + Zip/Postal Code: False False GTK_JUSTIFY_LEFT False False - 1 + 0 0.5 0 0 - 0 - 1 + 2 + 3 1 2 fill @@ -2393,7 +2393,7 @@ - + True True True @@ -2405,7 +2405,7 @@ False - 1 + 3 4 1 2 @@ -2414,9 +2414,9 @@ - + True - City: + State/Province: False False GTK_JUSTIFY_LEFT @@ -2428,8 +2428,8 @@ 0 - 0 - 1 + 2 + 3 2 3 fill @@ -2438,31 +2438,7 @@ - - True - State/Province: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - + True True True @@ -2474,8 +2450,8 @@ False - 1 - 2 + 3 + 4 2 3 @@ -2483,15 +2459,15 @@ - + True - Zip/Postal Code: + Country: False False GTK_JUSTIFY_LEFT False False - 0 + 1 0.5 0 0 @@ -2499,15 +2475,15 @@ 2 3 - 2 - 3 + 3 + 4 fill - + True True True @@ -2521,27 +2497,6 @@ 3 4 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 3 4 @@ -2549,9 +2504,9 @@ - + True - Country: + Address: False False GTK_JUSTIFY_LEFT @@ -2563,33 +2518,48 @@ 0 - 2 - 3 - 3 - 4 + 0 + 1 + 0 + 1 fill - + fill - + True True - True - True - 0 - - True - * - False + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + - 3 - 4 - 3 + 1 + 2 + 0 4 - + fill @@ -2639,9 +2609,9 @@ 6 - + True - Address: + City: False False GTK_JUSTIFY_LEFT @@ -2653,8 +2623,8 @@ 0 - 0 - 1 + 2 + 3 0 1 fill @@ -2663,7 +2633,7 @@ - + True True True @@ -2675,7 +2645,7 @@ False - 1 + 3 4 0 1 @@ -2684,9 +2654,9 @@ - + True - Address 2: + State/Province: False False GTK_JUSTIFY_LEFT @@ -2698,17 +2668,17 @@ 0 - 0 - 1 - 1 - 2 + 2 + 3 + 2 + 3 fill - + True True True @@ -2720,42 +2690,18 @@ False - 1 + 3 4 - 1 - 2 - - - - - - - True - City: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 2 3 - fill - + True - State/Province: + Zip/Postal Code: False False GTK_JUSTIFY_LEFT @@ -2767,17 +2713,17 @@ 0 - 0 - 1 - 3 - 4 + 2 + 3 + 1 + 2 fill - + True True True @@ -2789,24 +2735,24 @@ False - 1 - 2 - 2 - 3 + 3 + 4 + 1 + 2 - + True - Zip/Postal Code: + Country: False False GTK_JUSTIFY_LEFT False False - 0 + 1 0.5 0 0 @@ -2814,15 +2760,15 @@ 2 3 - 2 - 3 + 3 + 4 fill - + True True True @@ -2836,37 +2782,52 @@ 3 4 - 2 - 3 + 3 + 4 - + True True - True - True - 0 - - True - * - False + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + 1 2 - 3 + 0 4 - + fill - + True - Country: + Address: False False GTK_JUSTIFY_LEFT @@ -2878,33 +2839,12 @@ 0 - 2 - 3 - 3 - 4 + 0 + 1 + 0 + 1 fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 3 - 4 - 3 - 4 - + fill @@ -2954,9 +2894,9 @@ 6 - + True - Address: + City: False False GTK_JUSTIFY_LEFT @@ -2968,8 +2908,8 @@ 0 - 0 - 1 + 2 + 3 0 1 fill @@ -2978,7 +2918,7 @@ - + True True True @@ -2990,7 +2930,7 @@ False - 1 + 3 4 0 1 @@ -2999,9 +2939,9 @@ - + True - Address 2: + Address: False False GTK_JUSTIFY_LEFT @@ -3015,15 +2955,15 @@ 0 1 - 1 - 2 + 0 + 1 fill - + True True True @@ -3035,34 +2975,10 @@ False - 1 + 3 4 - 1 - 2 - - - - - - - True - City: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 2 3 - fill @@ -3076,38 +2992,17 @@ GTK_JUSTIFY_LEFT False False - 0 + 1 0.5 0 0 - 0 - 1 - 3 - 4 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 + 2 + 3 2 3 + fill @@ -3129,8 +3024,8 @@ 2 3 - 2 - 3 + 1 + 2 fill @@ -3151,29 +3046,8 @@ 3 4 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 3 - 4 + 1 + 2 @@ -3222,6 +3096,42 @@ + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 0 + 4 + fill + + diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index b5f85fe1fc..b9278529fc 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1078,6 +1078,21 @@ extract_im (EContactEditor *editor) g_free (service_attr_list); } +static void +init_address_textview (EContactEditor *editor, gint record) +{ + 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)); + g_signal_connect (text_buffer, "changed", G_CALLBACK (widget_changed), editor); +} + static void init_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) { @@ -1095,8 +1110,7 @@ init_address_field (EContactEditor *editor, gint record, const gchar *widget_fie static void init_address_record (EContactEditor *editor, gint record) { - init_address_field (editor, record, "address-1"); - init_address_field (editor, record, "address-2"); + init_address_textview (editor, record); init_address_field (editor, record, "city"); init_address_field (editor, record, "state"); init_address_field (editor, record, "zip"); @@ -1112,6 +1126,25 @@ init_address (EContactEditor *editor) init_address_record (editor, i); } +static void +fill_in_address_textview (EContactEditor *editor, gint record, EContactAddress *address) +{ + gchar *textview_name; + GtkWidget *textview; + GtkTextBuffer *text_buffer; + GtkTextIter iter; + + 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, address->street ? address->street : "", -1); + + gtk_text_buffer_get_end_iter (text_buffer, &iter); + gtk_text_buffer_insert (text_buffer, &iter, address->ext ? address->ext : "", -1); +} + static void fill_in_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, const gchar *string) @@ -1135,8 +1168,7 @@ fill_in_address_record (EContactEditor *editor, gint record) if (!address) return; - fill_in_address_field (editor, record, "address-1", address->street); - fill_in_address_field (editor, record, "address-2", address->ext); + 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); @@ -1154,6 +1186,45 @@ fill_in_address (EContactEditor *editor) fill_in_address_record (editor, i); } +static void +extract_address_textview (EContactEditor *editor, gint record, EContactAddress *address) +{ + gchar *textview_name; + GtkWidget *textview; + GtkTextBuffer *text_buffer; + GtkTextIter iter_1, iter_2; + + 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_get_start_iter (text_buffer, &iter_1); + + /* Skip blank lines */ + while (gtk_text_iter_get_chars_in_line (&iter_1) < 1 && + !gtk_text_iter_is_end (&iter_1)) + gtk_text_iter_forward_line (&iter_1); + + if (gtk_text_iter_is_end (&iter_1)) + return; + + iter_2 = iter_1; + gtk_text_iter_forward_line (&iter_2); + + /* Extract street (first line of text) */ + address->street = gtk_text_iter_get_text (&iter_1, &iter_2); + + iter_1 = iter_2; + if (gtk_text_iter_is_end (&iter_1)) + return; + + gtk_text_iter_forward_to_end (&iter_2); + + /* Extract extended address (remaining lines of text) */ + address->ext = gtk_text_iter_get_text (&iter_1, &iter_2); +} + static gchar * extract_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) { @@ -1174,8 +1245,7 @@ extract_address_record (EContactEditor *editor, gint record) address = g_new0 (EContactAddress, 1); - address->street = extract_address_field (editor, record, "address-1"); - address->ext = extract_address_field (editor, record, "address-2"); + extract_address_textview (editor, record, address); address->locality = extract_address_field (editor, record, "city"); address->region = extract_address_field (editor, record, "state"); address->code = extract_address_field (editor, record, "zip"); -- cgit v1.2.3