| %s: | ", html_label);
if (adr->po && *adr->po) g_string_append_printf (buffer, "%s ", adr->po);
if (adr->ext && *adr->ext) g_string_append_printf (buffer, "%s ", adr->ext);
if (adr->street && *adr->street) g_string_append_printf (buffer, "%s ", adr->street);
if (adr->locality && *adr->locality) g_string_append_printf (buffer, "%s ", adr->locality);
if (adr->region && *adr->region) g_string_append_printf (buffer, "%s ", adr->region);
if (adr->code && *adr->code) g_string_append_printf (buffer, "%s ", adr->code);
if (adr->country && *adr->country) g_string_append_printf (buffer, "%s ", adr->country);
if (TEXT_IS_RIGHT_TO_LEFT)
g_string_append_printf (buffer, " | %s: | |
", html_label);
else
g_string_append_printf (buffer, "");
}
if (adr)
e_contact_address_free (adr);
}
static void
accum_name_value (GString *buffer,
const gchar *label,
const gchar *str,
const gchar *icon,
guint html_flags)
{
gchar *value = e_text_to_html (str, html_flags);
if (TEXT_IS_RIGHT_TO_LEFT) {
g_string_append_printf (
buffer, "");
/* First column: email, IM */
g_string_append (buffer, "");
g_string_append (buffer, "");
render_contact_block (buffer, contact);
g_string_append (buffer, " | ");
/* Second column: Work */
g_string_append (buffer, " | ");
render_work_block (buffer, contact);
g_string_append (buffer, " ");
g_string_append (buffer, " | ");
/* Third column: Personal */
g_string_append (buffer, " | ");
render_personal_block (buffer, contact);
g_string_append (buffer, " ");
g_string_append (buffer, " | ");
/* Third row: note */
g_string_append (buffer, "
");
g_string_append (buffer, " \n");
}
static void
render_contact (GString *buffer, EContact *contact, GtkOrientation orientation)
{
if (orientation == GTK_ORIENTATION_VERTICAL)
render_contact_vertical (buffer, contact);
else
render_contact_horizontal (buffer, contact);
}
static void
eab_contact_display_render_normal (EABContactDisplay *display,
EContact *contact)
{
GString *buffer;
/* XXX The initial buffer size is arbitrary. Tune it. */
buffer = g_string_sized_new (4096);
g_string_append (buffer, HTML_HEADER);
g_string_append_printf (
buffer, ""
"\n", TEXT_IS_RIGHT_TO_LEFT ? "align=\"right\"" : "");
if (contact) {
GtkOrientation orientation;
orientation = display->priv->orientation;
if (e_contact_get (contact, E_CONTACT_IS_LIST))
render_contact_list (buffer, contact);
else
render_contact (buffer, contact, orientation);
}
g_string_append (buffer, " | \n");
e_web_view_load_string (E_WEB_VIEW (display), buffer->str);
g_string_free (buffer, TRUE);
}
static void
eab_contact_display_render_compact (EABContactDisplay *display,
EContact *contact)
{
GString *buffer;
/* XXX The initial buffer size is arbitrary. Tune it. */
buffer = g_string_sized_new (4096);
g_string_append (buffer, HTML_HEADER);
g_string_append (buffer, "\n");
if (contact) {
const gchar *str;
gchar *html;
EContactPhoto *photo;
guint bg_frame = 0x000000, bg_body = 0xEEEEEE;
GtkStyle *style;
style = gtk_widget_get_style (GTK_WIDGET (display));
if (style) {
gushort r, g, b;
r = style->black.red >> 8;
g = style->black.green >> 8;
b = style->black.blue >> 8;
bg_frame = ((r << 16) | (g << 8) | b) & 0xffffff;
#define DARKER(a) (((a) >= 0x22) ? ((a) - 0x22) : 0)
r = DARKER (style->bg[GTK_STATE_NORMAL].red >> 8);
g = DARKER (style->bg[GTK_STATE_NORMAL].green >> 8);
b = DARKER (style->bg[GTK_STATE_NORMAL].blue >> 8);
bg_body = ((r << 16) | (g << 8) | b) & 0xffffff;
#undef DARKER
}
g_string_append_printf (
buffer,
""
""
""
""
""
"", bg_frame, bg_body);
photo = e_contact_get (contact, E_CONTACT_PHOTO);
if (!photo)
photo = e_contact_get (contact, E_CONTACT_LOGO);
if (photo) {
gint calced_width = MAX_COMPACT_IMAGE_DIMENSION, calced_height = MAX_COMPACT_IMAGE_DIMENSION;
GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
GdkPixbuf *pixbuf;
/* figure out if we need to downscale the
image here. we don't scale the pixbuf
itself, just insert width/height tags in
the html */
gdk_pixbuf_loader_write (loader, photo->data.inlined.data, photo->data.inlined.length, NULL);
gdk_pixbuf_loader_close (loader, NULL);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (pixbuf)
g_object_ref (pixbuf);
g_object_unref (loader);
if (pixbuf) {
gint max_dimension;
calced_width = gdk_pixbuf_get_width (pixbuf);
calced_height = gdk_pixbuf_get_height (pixbuf);
max_dimension = calced_width;
if (max_dimension < calced_height)
max_dimension = calced_height;
if (max_dimension > MAX_COMPACT_IMAGE_DIMENSION) {
calced_width *= ((gfloat)MAX_COMPACT_IMAGE_DIMENSION / max_dimension);
calced_height *= ((gfloat)MAX_COMPACT_IMAGE_DIMENSION / max_dimension);
}
}
g_object_unref (pixbuf);
g_string_append_printf (
buffer,
"",
calced_width, calced_height);
e_contact_photo_free (photo);
}
g_string_append (buffer, " | \n");
str = e_contact_get_const (contact, E_CONTACT_FILE_AS);
if (str) {
html = e_text_to_html (str, 0);
g_string_append_printf (buffer, "%s", html);
g_free (html);
}
else {
str = e_contact_get_const (contact, E_CONTACT_FULL_NAME);
if (str) {
html = e_text_to_html (str, 0);
g_string_append_printf (buffer, "%s", html);
g_free (html);
}
}
g_string_append (buffer, " ");
if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
GList *email_list;
GList *l;
g_string_append (buffer, "");
g_string_append_printf (buffer, "%s: | ", _("List Members"));
email_list = e_contact_get (contact, E_CONTACT_EMAIL);
for (l = email_list; l; l = l->next) {
if (l->data) {
html = e_text_to_html (l->data, 0);
g_string_append_printf (buffer, "%s, ", html);
g_free (html);
}
}
g_string_append (buffer, " | ");
}
else {
gboolean comma = FALSE;
str = e_contact_get_const (contact, E_CONTACT_TITLE);
if (str) {
html = e_text_to_html (str, 0);
g_string_append_printf (buffer, "%s: %s ", _("Job Title"), str);
g_free (html);
}
#define print_email() { \
html = eab_parse_qp_email_to_html (str); \
\
if (!html) \
html = e_text_to_html (str, 0); \
\
g_string_append_printf (buffer, "%s%s", comma ? ", " : "", html); \
g_free (html); \
comma = TRUE; \
}
g_string_append_printf (buffer, "%s: ", _("Email"));
str = e_contact_get_const (contact, E_CONTACT_EMAIL_1);
if (str)
print_email ();
str = e_contact_get_const (contact, E_CONTACT_EMAIL_2);
if (str)
print_email ();
str = e_contact_get_const (contact, E_CONTACT_EMAIL_3);
if (str)
print_email ();
g_string_append (buffer, " ");
#undef print_email
str = e_contact_get_const (contact, E_CONTACT_HOMEPAGE_URL);
if (str) {
html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS);
g_string_append_printf (
buffer, "%s: %s ",
_("Home page"), html);
g_free (html);
}
str = e_contact_get_const (contact, E_CONTACT_BLOG_URL);
if (str) {
html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS);
g_string_append_printf (
buffer, "%s: %s ",
_("Blog"), html);
}
}
g_string_append (buffer, " | | | \n");
}
g_string_append (buffer, " |