From afe6fc18fc95f00efdbd3ea7f5ebd6c7fd64330d Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 8 Mar 2001 23:15:20 +0000 Subject: Switched to use e_contact_quick_add_free_form. Removed debugging code, 2001-03-08 Jon Trowbridge * gui/component/select-names/e-select-names-popup.c (quick_add_cb): Switched to use e_contact_quick_add_free_form. Removed debugging code, hopefully without introducing any bugs in the process. * gui/component/select-names/e-select-names-text-model.c (e_select_names_text_model_insert_length): Fix bug with commas inside of name/address combos. As long as the comma is inside of quotes, it will be treated as part of the name rather than as a break between addresses. * gui/component/select-names/e-select-names-completion.c (match_nickname): Use e_card_name_to_string for nickname match strings. (match_email): Use e_card_name_to_string for email match strings. (e_select_names_completion_begin): Strip quotes out of query text, so we don't produce malformed sexps. Added William Blake quote easter egg. * contact-editor/e-contact-quick-add.c: Further attempts to fix... mostly unsuccessful. (e_contact_quick_add_free_form): Added. Takes a single string and tries to parse out (using some simple, loose rules) the name and e-mail -- then calls e_contact_quick_add. An attempt to get the computer to automatically Do The Right Thing. * backend/ebook/e-book.c: Fixed some broken indentation. Yes, I'm anal. * gui/component/GNOME_Evolution_Addressbook.oafinfo: Added oaf_server info for EAddressWidget. * gui/component/GNOME_Evolution_Addressbook.oaf.in: Added oaf_server info for EAddressWidget. * gui/component/addressbook-factory.c (main): Add call to e_address_widget_factory_init. * gui/component/e-address-widget.h: * gui/component/e-address-widget.c: Added. A little widget (and a Bonobo control, BTW) for displaying addresses, with a left-click menu. Used to display addresses in the mail viewer (as embedded GtkHTML objects, replacing the text previously used). Still quite incomplete. 2001-03-08 Jon Trowbridge * mail-format.c (write_field_row_begin): Added. Table row HTML broken out into its own function. (write_subject): Added. Emits the proper HTML for the subject line. (write_field_to_stream): #ifdef-ed out of existence. (write_address): Take a CamelInternetAddress and spit out an tag with the appropriate s. * mail-display.c (on_object_requested): Check for an "address" object. If found, call... (handle_embedded_address_object): ...this function, which creates an AddressWidget bonobo control and passes in the necessary info. I never really realized just quite how much GtkHTML kicks ass until I figured out how to make this work. svn path=/trunk/; revision=8607 --- mail/mail-format.c | 74 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 12 deletions(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index 27849d54b7..7c8fed1ff7 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -574,10 +574,43 @@ enum { WRITE_BOLD=1, }; +static void +write_field_row_begin (const char *description, gint flags, GtkHTML *html, GtkHTMLStream *stream) +{ + char *encoded_desc; + int bold = (flags & WRITE_BOLD) == WRITE_BOLD; + + encoded_desc = e_utf8_from_gtk_string (GTK_WIDGET (html), description); + + mail_html_write (html, stream, "<%s align=right> %s ", + bold ? "th" : "td", encoded_desc, bold ? "th" : "td"); + + g_free (encoded_desc); +} + +static void +write_subject (const char *subject, int flags, GtkHTML *html, GtkHTMLStream *stream) +{ + char *encoded_subj; + + if (subject) + encoded_subj = e_text_to_html (subject, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); + else + encoded_subj = ""; + + write_field_row_begin (_("Subject:"), flags, html, stream); + + mail_html_write (html, stream, " %s ", encoded_subj); + + if (subject) + g_free (encoded_subj); +} + +#ifdef USE_OBSOLETE_UNUSED_STUFF_AND_GET_COMPILER_WARNINGS static void write_field_to_stream(const char *description, const char *value, int flags, GtkHTML *html, GtkHTMLStream *stream) { - char *encoded_desc, *encoded_value; + char *encoded_desc, *encoded_value, *embedded_object; int bold = (flags&WRITE_BOLD) == WRITE_BOLD; /* The description comes from gettext... */ @@ -590,26 +623,45 @@ write_field_to_stream(const char *description, const char *value, int flags, Gtk mail_html_write(html, stream, "<%s align=right>%s" - "%s", bold ? "th" : "td", + " %s ", bold ? "th" : "td", encoded_desc, bold ? "th" : "td", encoded_value); g_free (encoded_desc); + g_free (embedded_object); if (value) g_free(encoded_value); } +#endif static void -write_address(MailDisplay *md, const CamelInternetAddress *addr, const char *name, int flags) +write_address(MailDisplay *md, const CamelInternetAddress *addr, const char *field_name, int flags) { - char *string; + const char *name, *email; + gint i; - if (addr == NULL) + if (addr == NULL || !camel_internet_address_get (addr, 0, NULL, NULL)) return; - string = camel_address_format((CamelAddress *)addr); - if (string && string[0]) { - write_field_to_stream(name, string, flags, md->html, md->stream); + write_field_row_begin (field_name, flags, md->html, md->stream); + + i = 0; + while (camel_internet_address_get (addr, i, &name, &email)) { + + if ((name && *name) || (email && *email)) { + + mail_html_write (md->html, md->stream, i ? ", " : ""); + + mail_html_write (md->html, md->stream, ""); + if (name && *name) + mail_html_write (md->html, md->stream, "", name); + if (email && *email) + mail_html_write (md->html, md->stream, "", email); + mail_html_write (md->html, md->stream, ""); + } + + ++i; } - g_free(string); + + mail_html_write (md->html, md->stream, ""); /* Finish up the table row */ } @@ -632,9 +684,7 @@ write_headers (CamelMimeMessage *message, MailDisplay *md) write_address(md, camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_CC), _("Cc:"), WRITE_BOLD); - write_field_to_stream (_("Subject:"), - camel_mime_message_get_subject (message), - TRUE, md->html, md->stream); + write_subject (camel_mime_message_get_subject (message), WRITE_BOLD, md->html, md->stream); mail_html_write (md->html, md->stream, ""); -- cgit v1.2.3