aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/mail-display.c33
-rw-r--r--mail/mail-format.c74
3 files changed, 112 insertions, 12 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f6a3ef6da5..48757cd6f8 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,20 @@
+2001-03-08 Jon Trowbridge <trow@ximian.com>
+
+ * 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
+ <object> tag with the appropriate <param>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.
+
2001-03-08 Jeffrey Stedfast <fejj@ximian.com>
* mail-vtrash.[c,h]: Removed from cvs
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 9f599bc797..8304cbc595 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -603,6 +603,33 @@ get_embedded_for_component (const char *iid, MailDisplay *md)
return embedded;
}
+static void
+handle_embedded_address_object (GtkHTMLEmbedded *eb)
+{
+ const gchar *name, *email;
+ GtkWidget *w;
+
+ w = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressWidget",
+ CORBA_OBJECT_NIL);
+
+ name = gtk_html_embedded_get_parameter (eb, "name");
+ email = gtk_html_embedded_get_parameter (eb, "email");
+
+ bonobo_widget_set_property (BONOBO_WIDGET (w),
+ "name", name,
+ "email", email,
+ /* Hackish: this is the bg color defined for the HTML table
+ in mail-format.c. If you change it there, you'd better
+ change it here as well. */
+ "background_rgb", 0xeeeeee,
+ NULL);
+
+ gtk_widget_show (w);
+ gtk_container_add (GTK_CONTAINER (eb), w);
+
+ gtk_html_embedded_set_descent (eb, 0);
+}
+
static gboolean
on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
{
@@ -621,6 +648,12 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
char *cid;
cid = eb->classid;
+
+ if (!strcmp (cid, "address")) {
+ handle_embedded_address_object (eb);
+ return TRUE;
+ }
+
if (!strncmp (cid, "popup:", 6))
cid += 6;
if (strncmp (cid, "cid:", 4) != 0)
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
@@ -575,9 +575,42 @@ enum {
};
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, "<tr><%s align=right> %s </%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, "<td> %s </td> </tr>", 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,
"<tr valign=top><%s align=right>%s</%s>"
- "<td>%s</td></tr>", bold ? "th" : "td",
+ "<td> %s </td></tr>", 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 ? ", " : "<td>");
+
+ mail_html_write (md->html, md->stream, "<object classid=\"address\">");
+ if (name && *name)
+ mail_html_write (md->html, md->stream, "<param name=\"name\" value=\"%s\"/>", name);
+ if (email && *email)
+ mail_html_write (md->html, md->stream, "<param name=\"email\" value=\"%s\"/>", email);
+ mail_html_write (md->html, md->stream, "</object>");
+ }
+
+ ++i;
}
- g_free(string);
+
+ mail_html_write (md->html, md->stream, "</td></tr>"); /* 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,
"</table></td></tr></table></td></tr></table></font>");