[evolution/webkit] Port EABContactDisplay to JavaScript and CSS



commit 62a3a47744c27cdd2a80ad42ef6395a5e0e32aee
Author: Dan VrÃtil <dvratil redhat com>
Date:   Mon Jul 11 15:39:37 2011 +0200

    Port EABContactDisplay to JavaScript and CSS
    
    - replace table layout by floating <div>s; this makes it possible to use one
      common HTML code for both vertical and horizontal contact preview
    - use JavaScript for collapsing/expanding subcontact lists instead of
      generating whole new HTML code and re-rendering the preview page
    - TODO: the maps widgets are not yet ported, this is blocked by
      WebKit bug #63451

 addressbook/gui/widgets/Makefile.am           |    1 +
 addressbook/gui/widgets/eab-contact-display.c |  623 +++++++------------------
 mail/em-format-html.c                         |    1 -
 modules/addressbook/e-book-shell-content.c    |    9 -
 widgets/misc/e-web-view.c                     |    2 +-
 5 files changed, 183 insertions(+), 453 deletions(-)
---
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 40c5765..73cddb9 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -10,6 +10,7 @@ libeabwidgets_la_CPPFLAGS =				\
 	-DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\"	\
 	-DEVOLUTION_RULEDIR=\"$(ruledir)\"		\
 	-DEVOLUTION_IMAGESDIR=\"${imagesdir}\"		\
+	-DEVOLUTION_DATADIR=\"${datadir}\"		\
 	-I$(top_srcdir)					\
 	-I$(top_srcdir)/filter				\
 	-I$(top_srcdir)/widgets				\
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index 5b54d19..3170e8e 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -50,17 +50,13 @@
 struct _EABContactDisplayPrivate {
 	EContact *contact;
 	EABContactDisplayMode mode;
-	GtkOrientation orientation;
 	gboolean show_maps;
-
-	GHashTable *closed_lists; /* see render_contact_list_* */
 };
 
 enum {
 	PROP_0,
 	PROP_CONTACT,
 	PROP_MODE,
-	PROP_ORIENTATION,
 	PROP_SHOW_MAPS
 };
 
@@ -80,9 +76,6 @@ common_location[] =
 	{ "OTHER", N_ ("Other") }
 };
 
-#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n"  \
-                    "<head>\n<meta name=\"generator\" content=\"Evolution Addressbook Component\">\n</head>\n"
-
 #define HEADER_COLOR      "#7f7f7f"
 #define IMAGE_COL_WIDTH   "20"
 #define CONTACT_LIST_ICON "stock_contact-list"
@@ -92,12 +85,40 @@ common_location[] =
 #define JABBER_ICON       "im-jabber"
 #define MSN_ICON          "im-msn"
 #define YAHOO_ICON        "im-yahoo"
-#define GADUGADU_ICON	    "im-gadugadu"
-#define SKYPE_ICON	    "stock_people"
+#define GADUGADU_ICON	  "im-gadugadu"
+#define SKYPE_ICON	  "stock_people"
 #define VIDEOCONF_ICON    "stock_video-conferencing"
 
 #define MAX_COMPACT_IMAGE_DIMENSION 48
 
+
+#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n"  \
+                    "<head>\n<meta name=\"generator\" content=\"Evolution Addressbook Component\">\n" \
+                    "<style type=\"text/css\" rel=\"Stylesheet\" ref=\"file://" EVOLUTION_DATADIR "/evo_style.css\">" \
+                    "<style type=\"text/css\">\n" \
+		    "  div#header { width:100%; clear: both; }\n" \
+		    "  div#columns { width: 100%; clear: both; }\n" \
+		    "  div#footer { width: 100%; clear: both; }\n" \
+		    "  div.column { width: auto; float: left; margin-right: 15px; }\n" \
+		    "  img#contact-photo { float: left; }\n" \
+		    "  div#contact-name { float: left; margin-left: 20px; }\n" \
+		    "  h2 { color: " HEADER_COLOR "; }\n" \
+		    "  table th { color: " HEADER_COLOR "; text-align: left; }\n" \
+		    "  .type { color: " HEADER_COLOR "; }\n" \
+		    "</style>\n" \
+		    "<script type=\"text/javascript\">\n" \
+		    "function collapse_list (obj, listId) {\n" \
+		    "	var l = document.getElementById (listId);\n" \
+		    "	if (l.style.display == \"none\") {\n" \
+		    "		l.style.display = \"block\"; obj.src = obj.src.substr (0, obj.src.lastIndexOf (\"/\")) + \"/minus.png\";\n" \
+		    "	} else {\n" \
+		    "		l.style.display = \"none\"; obj.src = obj.src.substr (0, obj.src.lastIndexOf (\"/\")) + \"/plus.png\";\n" \
+		    "   }\n" \
+		    "}\n" \
+		    "</script>\n" \
+                    "</head>\n"
+
+
 static const gchar *ui =
 "<ui>"
 "  <popup name='context'>"
@@ -113,6 +134,33 @@ static const gchar *ui =
 static gpointer parent_class;
 static guint signals[LAST_SIGNAL];
 
+static gchar*
+get_icon_uri (const gchar *icon_name)
+{
+	GtkIconTheme *icon_theme;
+	GtkIconInfo *icon_info;
+	const gchar *filename;
+	gchar *icon_uri;
+	GError *error = NULL;
+
+	icon_theme = gtk_icon_theme_get_default ();
+	icon_info = gtk_icon_theme_lookup_icon (
+		icon_theme, icon_name, GTK_ICON_SIZE_MENU, 0);
+	g_return_val_if_fail (icon_info != NULL, NULL);
+
+	filename = gtk_icon_info_get_filename (icon_info);
+	icon_uri = g_filename_to_uri (filename, NULL, &error);
+
+	if (error != NULL) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	gtk_icon_info_free (icon_info);
+
+	return icon_uri;
+}
+
 static void
 contact_display_emit_send_message (EABContactDisplay *display,
                                    gint email_num)
@@ -276,48 +324,49 @@ accum_address (GString *buffer,
 }
 
 static void
-accum_name_value (GString *buffer,
+render_table_row (GString *buffer,
                   const gchar *label,
                   const gchar *str,
                   const gchar *icon,
                   guint html_flags)
 {
-	gchar *value = e_text_to_html (str, html_flags);
+	const gchar *icon_html;
+	gchar *value;
+
+	if (html_flags)
+		value = e_text_to_html (str, html_flags);
+	else
+		value = (gchar*)str;
+
+
+	if (icon) {
+		gchar *icon_uri = get_icon_uri (icon);
+		icon_html = g_strdup_printf ("<img src=\"%s\" width=\"16\" height=\"16\" />", icon_uri);
+		g_free (icon_uri);
+	} else {
+		icon_html = "";
+	}
 
 	if (TEXT_IS_RIGHT_TO_LEFT) {
 		g_string_append_printf (
 			buffer, "<tr>"
-			"<td valign=\"top\" align=\"right\">%s</td> "
-			"<td align=\"right\" valign=\"top\" width=\"100\" nowrap>"
-			"<font color=" HEADER_COLOR ">%s:</font></td>",
-			value, label);
-		g_string_append_printf (
-			buffer, "<td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">");
-		if (icon != NULL)
-			g_string_append_printf (
-				buffer,
-				"<object width=\"16\" height=\"16\" "
-				"type=\"image/x-themed-icon\" "
-				"data=\"%s\"/></td></tr>", icon);
-		else
-			g_string_append_printf (buffer, "</td></tr>");
+			"<td valign=\"top\" align=\"right\">%s</td>"
+			"<th align=\"right\" valign=\"top\" width=\"100\" nowrap>:%s</th>"
+			"<td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">%s</td>"
+			"</tr>",
+			value, label, icon_html);
 	} else {
 		g_string_append_printf (
-			buffer, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">");
-		if (icon != NULL)
-			g_string_append_printf (
-				buffer,
-				"<object width=\"16\" height=\"16\" "
-				"type=\"image/x-themed-icon\" "
-				"data=\"%s\"/>", icon);
-		g_string_append_printf (
-			buffer, "</td><td valign=\"top\" width=\"100\" nowrap>"
-			"<font color=" HEADER_COLOR ">%s:</font>"
-			"</td> <td valign=\"top\">%s</td></tr>",
-			label, value);
+			buffer, "<tr>"
+			"<td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">%s</td>"
+			"<th valign=\"top\" width=\"100\" nowrap>%s:</th>"
+			"<td valign=\"top\">%s</td>"
+			"</tr>",
+			icon_html, label, value);
 	}
 
-	g_free (value);
+	if (html_flags)
+		g_free (value);
 }
 
 static void
@@ -333,7 +382,7 @@ accum_attribute (GString *buffer,
 	str = e_contact_get_const (contact, field);
 
 	if (str != NULL && *str != '\0')
-		accum_name_value (buffer, html_label, str, icon, html_flags);
+		render_table_row (buffer, html_label, str, icon, html_flags);
 }
 
 static void
@@ -355,13 +404,13 @@ accum_time_attribute (GString *buffer,
 					 date->year );
 		g_date_strftime (sdate, 100, "%x", gdate);
 		g_date_free (gdate);
-		accum_name_value (buffer, html_label, sdate, icon, html_flags);
+		render_table_row (buffer, html_label, sdate, icon, html_flags);
 		e_contact_date_free (date);
 	}
 }
 
 static void
-accum_multival_attribute (GString *buffer,
+accum_attribute_multival (GString *buffer,
                           EContact *contact,
                           const gchar *html_label,
                           EContactField field,
@@ -369,30 +418,23 @@ accum_multival_attribute (GString *buffer,
                           guint html_flags)
 {
 	GList *val_list, *l;
+	GString *val = g_string_new ("");
 
 	val_list = e_contact_get (contact, field);
+
 	for (l = val_list; l; l = l->next) {
-		const gchar *str = (const gchar *) l->data;
-		accum_name_value (buffer, html_label, str, icon, html_flags);
+		if (l != val_list)
+			g_string_append (val, "<br>");
+
+		g_string_append (val, l->data);
 	}
-	g_list_foreach (val_list, (GFunc) g_free, NULL);
-	g_list_free (val_list);
-}
 
-static void
-start_block (GString *buffer,
-             const gchar *label)
-{
-	g_string_append_printf (
-		buffer, "<tr><td height=\"20\" colspan=\"3\">"
-		"<font color=" HEADER_COLOR "><b>%s</b>"
-		"</font></td></tr>", label);
-}
+	if (val->str && *val->str)
+		render_table_row (buffer, html_label, val->str, icon, html_flags);
 
-static void
-end_block (GString *buffer)
-{
-	g_string_append (buffer, "<tr><td height=\"20\">&nbsp;</td></tr>");
+	g_string_free (val, TRUE);
+	g_list_foreach (val_list, (GFunc) g_free, NULL);
+	g_list_free (val_list);
 }
 
 static const gchar *
@@ -424,13 +466,20 @@ render_title_block (GString *buffer, EContact *contact)
 		photo = e_contact_get (contact, E_CONTACT_LOGO);
 	/* Only handle inlined photos for now */
 	if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
-		g_string_append (buffer, "<img border=\"1\" src=\"internal-contact-photo:\">");
+		gchar *photo_data = g_base64_encode (photo->data.inlined.data, photo->data.inlined.length);
+		g_string_append_printf (buffer, "<img border=\"1\" src=\"data:%s;base64,%s\">",
+			photo->data.inlined.mime_type,
+			photo_data);
+		g_free (photo_data);
 	}
 	if (photo)
 		e_contact_photo_free (photo);
 
-	if (e_contact_get (contact, E_CONTACT_IS_LIST))
-		g_string_append (buffer, "<img src=\"evo-icon:" CONTACT_LIST_ICON "\">");
+	if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
+		gchar *icon = get_icon_uri (CONTACT_LIST_ICON);
+		g_string_append_printf (buffer, "<img src=\"%s\">", icon);
+		g_free (icon);
+	}
 
 	g_string_append_printf (
 		buffer, "</td><td width=\"20\"></td><td %s valign=\"top\">\n",
@@ -460,12 +509,9 @@ render_contact_list_row (GString *buffer,
  {
 	gchar *evolution_imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL);
 	gboolean list_collapsed = FALSE;
-	const gchar *listId = e_destination_get_contact_uid (destination), *textrep;
+	const gchar *textrep;
 	gchar *name = NULL, *email_addr = NULL;
 
-	if (listId)
-		list_collapsed = GPOINTER_TO_INT (g_hash_table_lookup (display->priv->closed_lists, listId));
-
 	textrep = e_destination_get_textrep (destination, TRUE);
 	if (!eab_parse_qp_email (textrep, &name, &email_addr))
 		email_addr = g_strdup (textrep);
@@ -473,15 +519,15 @@ render_contact_list_row (GString *buffer,
 	g_string_append (buffer, "<tr>");
 	if (e_destination_is_evolution_list (destination)) {
 		g_string_append_printf (buffer,
-			"<td width=" IMAGE_COL_WIDTH " valign=\"top\"><a href=\"##%s##\"><img src=\"%s/%s.png\"></a></td><td width=\"100%%\">%s",
-			e_destination_get_contact_uid (destination),
+			"<td width=" IMAGE_COL_WIDTH " valign=\"top\"><img src=\"%s/minus.png\" onClick=\"collapse_list(this, %s);\"></td><td width=\"100%%\">%s",
 			evolution_imagesdir,
-			(list_collapsed ? "plus" : "minus"),
+			e_destination_get_contact_uid (destination),
 			name ? name : email_addr);
 
 		if (!list_collapsed) {
 			const GList *dest, *dests;
-			g_string_append (buffer, "<br><table cellspacing=\"1\">");
+			g_string_append_printf (buffer, "<br><table cellspacing=\"1\" id=\"%s\">",
+				e_destination_get_contact_uid (destination));
 
 			dests = e_destination_list_get_root_dests (destination);
 			for (dest = dests; dest; dest = dest->next) {
@@ -509,37 +555,9 @@ render_contact_list_row (GString *buffer,
 }
 
 static void
-render_contact_list_vertical (GString *buffer,
-		              EContact *contact,
-        		      EABContactDisplay *display)
-{
-	EDestination *destination;
-	const GList *dest, *dests;
-
-	destination = e_destination_new ();
-	e_destination_set_contact (destination, contact, 0);
-	dests = e_destination_list_get_root_dests (destination);
-
-	render_title_block (buffer, contact);
-
-	g_string_append_printf (buffer, "<table border=\"0\"><tr><td valign=\"top\"><font color=" HEADER_COLOR ">%s</font></td><td>",
-		_("List Members:"));
-	g_string_append (buffer, "<table border=\"0\" cellspacing=\"1\">");
-
-	for (dest = dests; dest; dest = dest->next) {
-		render_contact_list_row (buffer, dest->data, display);
- 	}
-
-	g_string_append (buffer, "</table>");
-	g_string_append (buffer, "</td></tr></table>");
-
-	g_object_unref (destination);
-}
-
-static void
-render_contact_list_horizontal (GString *buffer,
-		                EContact *contact,
-        		        EABContactDisplay *display)
+render_contact_list (GString *buffer,
+		     EContact *contact,
+                     EABContactDisplay *display)
 {
 	EDestination *destination;
 	const GList *dest, *dests;
@@ -565,31 +583,16 @@ render_contact_list_horizontal (GString *buffer,
 }
 
 static void
-render_contact_list (GString *buffer,
-                     EContact *contact,
-		     EABContactDisplay *display)
-
-{
-	if (display->priv->orientation == GTK_ORIENTATION_VERTICAL)
-		render_contact_list_vertical (buffer, contact, display);
-	else
-		render_contact_list_horizontal (buffer, contact, display);
-}
-
-static void
-render_contact_block (GString *buffer, EContact *contact)
+render_contact_column (GString *buffer, EContact *contact)
 {
-	GString *accum;
+	GString *accum, *email;
 	GList *email_list, *l, *email_attr_list, *al;
 	gint email_num = 0;
 	const gchar *nl;
-	gchar *nick=NULL;
 
-	accum = g_string_new ("");
+	email = g_string_new ("");
 	nl = "";
 
-	start_block (buffer, "");
-
 	email_list = e_contact_get (contact, E_CONTACT_EMAIL);
 	email_attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL);
 
@@ -600,7 +603,7 @@ render_contact_block (GString *buffer, EContact *contact)
 		if (!eab_parse_qp_email (l->data, &name, &mail))
 			mail = e_text_to_html (l->data, 0);
 
-		g_string_append_printf (accum, "%s%s%s<a href=\"internal-mailto:%d\";>%s</a>%s <font color=" HEADER_COLOR ">(%s)</font>",
+		g_string_append_printf (email, "%s%s%s<a href=\"internal-mailto:%d\";>%s</a>%s <span class=\"type\">(%s)</span>",
 						nl,
 						name ? name : "",
 						name ? " &lt;" : "",
@@ -619,58 +622,33 @@ render_contact_block (GString *buffer, EContact *contact)
 	g_list_free (email_list);
 	g_list_free (email_attr_list);
 
-	if (accum->len) {
-
-		if (TEXT_IS_RIGHT_TO_LEFT) {
-			g_string_append_printf (
-				buffer, "<tr>"
-				"<td valign=\"top\" align=\"right\">%s</td> "
-				"<td valign=\"top\" align=\"right\" width=\"100\" nowrap>"
-				"<font color=" HEADER_COLOR ">%s:</font>"
-				"</td><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">"
-				"</td></tr>", accum->str, _("Email"));
-		} else {
-			g_string_append (
-				buffer, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">");
-			g_string_append_printf (
-				buffer, "</td><td valign=\"top\" width=\"100\" nowrap>"
-				"<font color=" HEADER_COLOR ">%s:</font></td> "
-				"<td valign=\"top\" nowrap>%s</td></tr>",
-				_("Email"), accum->str);
-		}
-	}
-
-	g_string_assign (accum, "");
-	nick = e_contact_get (contact, E_CONTACT_NICKNAME);
-	if (nick && *nick) {
-		accum_name_value (accum, _("Nickname"), nick, NULL, 0);
-		if (accum->len > 0)
-			g_string_append_printf (
-				buffer, "%s", accum->str);
-	}
+	accum = g_string_new ("");
 
-	g_string_assign (accum, "");
-	accum_multival_attribute (accum, contact, _("AIM"), E_CONTACT_IM_AIM, AIM_ICON, 0);
-	accum_multival_attribute (accum, contact, _("GroupWise"), E_CONTACT_IM_GROUPWISE, GROUPWISE_ICON, 0);
-	accum_multival_attribute (accum, contact, _("ICQ"), E_CONTACT_IM_ICQ, ICQ_ICON, 0);
-	accum_multival_attribute (accum, contact, _("Jabber"), E_CONTACT_IM_JABBER, JABBER_ICON, 0);
-	accum_multival_attribute (accum, contact, _("MSN"), E_CONTACT_IM_MSN, MSN_ICON, 0);
-	accum_multival_attribute (accum, contact, _("Yahoo"), E_CONTACT_IM_YAHOO, YAHOO_ICON, 0);
-	accum_multival_attribute (accum, contact, _("Gadu-Gadu"), E_CONTACT_IM_GADUGADU, GADUGADU_ICON, 0);
-	accum_multival_attribute (accum, contact, _("Skype"), E_CONTACT_IM_SKYPE, SKYPE_ICON, 0);
+	if (email->len)
+		render_table_row (accum, _("Email"), email->str, NULL, 0);
 
-	if (accum->len > 0)
-		g_string_append_printf (buffer, "%s", accum->str);
+	accum_attribute (accum, contact, _("Nickname"), E_CONTACT_NICKNAME, NULL, 0);
+	accum_attribute_multival (accum, contact, _("AIM"), E_CONTACT_IM_AIM, AIM_ICON, 0);
+	accum_attribute_multival (accum, contact, _("GroupWise"), E_CONTACT_IM_GROUPWISE, GROUPWISE_ICON, 0);
+	accum_attribute_multival (accum, contact, _("ICQ"), E_CONTACT_IM_ICQ, ICQ_ICON, 0);
+	accum_attribute_multival (accum, contact, _("Jabber"), E_CONTACT_IM_JABBER, JABBER_ICON, 0);
+	accum_attribute_multival (accum, contact, _("MSN"), E_CONTACT_IM_MSN, MSN_ICON, 0);
+	accum_attribute_multival (accum, contact, _("Yahoo"), E_CONTACT_IM_YAHOO, YAHOO_ICON, 0);
+	accum_attribute_multival (accum, contact, _("Gadu-Gadu"), E_CONTACT_IM_GADUGADU, GADUGADU_ICON, 0);
+	accum_attribute_multival (accum, contact, _("Skype"), E_CONTACT_IM_SKYPE, SKYPE_ICON, 0);
 
-	end_block (buffer);
+	if (accum->len)
+		g_string_append_printf (buffer,
+			"<div class=\"column\" id=\"contact-internet\">"
+			"<table border=\"0\" cellspacing=\"5\">%s</table>"
+			"</div>", accum->str);
 
 	g_string_free (accum, TRUE);
-	g_free (nick);
-
+	g_string_free (email, TRUE);
 }
 
 static void
-render_work_block (GString *buffer, EContact *contact)
+render_work_column (GString *buffer, EContact *contact)
 {
 	GString *accum = g_string_new ("");
 
@@ -688,16 +666,18 @@ render_work_block (GString *buffer, EContact *contact)
 	accum_address   (accum, contact, _("Address"), E_CONTACT_ADDRESS_WORK, E_CONTACT_ADDRESS_LABEL_WORK);
 
 	if (accum->len > 0) {
-		start_block (buffer, _("Work"));
-		g_string_append_printf (buffer, "%s", accum->str);
-		end_block (buffer);
+		g_string_append_printf (buffer,
+			"<div class=\"column\" id=\"contact-work\">"
+			"<h2>%s</h2>"
+			"<table border=\"0\" cellspacing=\"5\">%s</table>"
+			"</div>", _("Work"), accum->str);
 	}
 
 	g_string_free (accum, TRUE);
 }
 
 static void
-render_personal_block (GString *buffer, EContact *contact)
+render_personal_column (GString *buffer, EContact *contact)
 {
 	GString *accum = g_string_new ("");
 
@@ -710,32 +690,33 @@ render_personal_block (GString *buffer, EContact *contact)
 	accum_time_attribute (accum, contact, _("Birthday"), E_CONTACT_BIRTH_DATE, NULL, 0);
 	accum_time_attribute (accum, contact, _("Anniversary"), E_CONTACT_ANNIVERSARY, NULL, 0);
 	accum_attribute (accum, contact, _("Spouse"), E_CONTACT_SPOUSE, NULL, 0);
+
 	if (accum->len > 0) {
-		start_block (buffer, _("Personal"));
-		g_string_append_printf (buffer, "%s", accum->str);
-		end_block (buffer);
+		g_string_append_printf (buffer,
+			"<div class=\"column\" id=\"contact-personal\">"
+			"<h2>%s</h2>"
+			"<table border=\"0\" cellspacing=\"5\">%s</table>"
+			"</div>", _("Personal"), accum->str);
 	}
 
 	g_string_free (accum, TRUE);
 }
 
 static void
-render_note_block (GString *buffer, EContact *contact)
+render_footer (GString *buffer, EContact *contact)
 {
 	const gchar *str;
-	gchar *html;
 
 	str = e_contact_get_const (contact, E_CONTACT_NOTE);
 	if (!str || !*str)
 		return;
 
-	html = e_text_to_html (str,  E_TEXT_TO_HTML_CONVERT_ADDRESSES | E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_NL);
-
-	start_block (buffer, _("Note"));
-	g_string_append_printf (buffer, "<tr><td>%s</td></tr>", html);
-	end_block (buffer);
-
-	g_free (html);
+	g_string_append (buffer, "<div id=\"footer\">"
+		"<table border=\"0\" cellspacing=\"5\">");
+	render_table_row (buffer, _("Note"),
+		e_contact_get_const (contact, E_CONTACT_NOTE),
+		NULL, E_TEXT_TO_HTML_CONVERT_ADDRESSES | E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_NL);
+	g_string_append (buffer, "</table></div>");
 }
 
 static void
@@ -743,87 +724,25 @@ render_address_map (GString *buffer, EContact *contact, gint map_type)
 {
 #ifdef WITH_CONTACT_MAPS
 	if (map_type == E_CONTACT_ADDRESS_WORK) {
-		g_string_append (buffer, "<object classid=\"address-map-work\"></object>");
+		g_string_append (buffer, "<object type=\"application/x-map-widget\" data=\"work\"></object>");
 	 } else {
- 		g_string_append (buffer, "<object classid=\"address-map-home\"></object>");
+ 		g_string_append (buffer, "<object type=\"application/x-map-widget\" data=\"home\"></object>");
 	 }
 #endif
 }
 
 static void
-render_contact_horizontal (GString *buffer, EContact *contact, gboolean show_maps)
+render_contact (GString *buffer, EContact *contact, EABContactDisplay *display)
 {
-	g_string_append (buffer, "<table border=\"0\">");
 	render_title_block (buffer, contact);
-	g_string_append (buffer, "</table>");
 
-	g_string_append (buffer, "<table border=\"0\">");
-	render_contact_block (buffer, contact);
-	render_work_block (buffer, contact);
-	g_string_append (buffer, "<tr><td></td><td colspan=\"2\">");
-	if (show_maps)
-		render_address_map (buffer, contact, E_CONTACT_ADDRESS_WORK);
-	g_string_append (buffer, "<br></td></tr>");
-	render_personal_block (buffer, contact);
-	g_string_append (buffer, "<tr><td></td><td colspan=\"2\">");
-	if (show_maps)
-		render_address_map (buffer, contact, E_CONTACT_ADDRESS_HOME);
-	g_string_append (buffer, "<br></td></tr>");
-	g_string_append (buffer, "</table>");
+	g_string_append (buffer, "<div id=\"columns\">");
+	render_contact_column (buffer, contact);
+	render_work_column (buffer, contact);
+	render_personal_column (buffer, contact);
+	g_string_append (buffer, "</div>");
 
-	g_string_append (buffer, "<table border=\"0\">");
-	render_note_block (buffer, contact);
-	g_string_append (buffer, "</table>");
-}
-
-static void
-render_contact_vertical (GString *buffer, EContact *contact, gboolean show_maps)
-{
-	/* First row: photo & name */
-	g_string_append (buffer, "<tr><td colspan=\"3\">");
-	render_title_block (buffer, contact);
-	g_string_append (buffer, "</td></tr>");
-
-	/* Second row: addresses etc. */
-	g_string_append (buffer, "<tr>");
-
-	/* First column: email, IM */
-	g_string_append (buffer, "<td valign=\"top\">");
-	g_string_append (buffer, "<table border=\"0\">");
-	render_contact_block (buffer, contact);
-	g_string_append (buffer, "</table></td>");
-
-	/* Second column: Work */
-	g_string_append (buffer, "<td width=\"30\"></td><td valign=\"top\"><table border=\"0\">");
-	render_work_block (buffer, contact);
-	g_string_append (buffer, "</table>");
-	if (show_maps)
-		render_address_map (buffer, contact, E_CONTACT_ADDRESS_WORK);
-	g_string_append (buffer, "</td>");
-
-	/* Third column: Personal */
-	g_string_append (buffer, "<td width=\"30\"></td><td valign=\"top\"><table border=\"0\">");
-	render_personal_block (buffer, contact);
-	g_string_append (buffer, "</table>");
-	if (show_maps)
-		render_address_map (buffer, contact, E_CONTACT_ADDRESS_HOME);
-	g_string_append (buffer, "</td>");
-
-	/* Third row: note */
-	g_string_append (buffer, "<tr><td colspan=\"3\"><table border=\"0\"");
-	render_note_block (buffer, contact);
-	g_string_append (buffer, "</table></td></tr>");
-
-	g_string_append (buffer, "</table>\n");
-}
-
-static void
-render_contact (GString *buffer, EContact *contact, GtkOrientation orientation, gboolean show_maps)
-{
-	if (orientation == GTK_ORIENTATION_VERTICAL)
-		render_contact_vertical (buffer, contact, show_maps);
-	else
-		render_contact_horizontal (buffer, contact, show_maps);
+	render_footer (buffer, contact);
 }
 
 static void
@@ -836,22 +755,16 @@ eab_contact_display_render_normal (EABContactDisplay *display,
 
 	buffer = g_string_sized_new (4096);
 	g_string_append (buffer, HTML_HEADER);
-	g_string_append_printf (
-		buffer, "<body><table><tr>"
-		"<td %s>\n", TEXT_IS_RIGHT_TO_LEFT ? "align=\"right\"" : "");
+	g_string_append (buffer, "<body>");
 
 	if (contact) {
-		GtkOrientation orientation;
-		orientation = display->priv->orientation;
-
 		if (e_contact_get (contact, E_CONTACT_IS_LIST))
 			render_contact_list (buffer, contact, display);
 		else
-			render_contact (buffer, contact, orientation, display->priv->show_maps);
-
+			render_contact (buffer, contact, display);
 	}
 
-	g_string_append (buffer, "</td></tr></table></body></html>\n");
+	g_string_append (buffer, "</body></html>\n");
 
 	e_web_view_load_string (E_WEB_VIEW (display), buffer->str);
 
@@ -862,8 +775,11 @@ static void
 eab_contact_display_render_compact (EABContactDisplay *display,
                                     EContact *contact)
 {
+#warning FIXME: eab_contact_display_render_compact is not WebKit-ready
+
 	GString *buffer;
 
+
 	/* XXX The initial buffer size is arbitrary.  Tune it. */
 
 	buffer = g_string_sized_new (4096);
@@ -1067,12 +983,6 @@ contact_display_set_property (GObject *object,
 				g_value_get_int (value));
 			return;
 
-		case PROP_ORIENTATION:
-			eab_contact_display_set_orientation (
-				EAB_CONTACT_DISPLAY (object),
-				g_value_get_int (value));
-			return;
-
 		case PROP_SHOW_MAPS:
 			eab_contact_display_set_show_maps (
 				EAB_CONTACT_DISPLAY (object),
@@ -1102,12 +1012,6 @@ contact_display_get_property (GObject *object,
 				EAB_CONTACT_DISPLAY (object)));
 			return;
 
-		case PROP_ORIENTATION:
-			g_value_set_int (
-				value, eab_contact_display_get_orientation (
-				EAB_CONTACT_DISPLAY (object)));
-			return;
-
 		case PROP_SHOW_MAPS:
 			g_value_set_boolean (
 				value, eab_contact_display_get_show_maps (
@@ -1130,85 +1034,10 @@ contact_display_dispose (GObject *object)
 		priv->contact = NULL;
 	}
 
-	if (priv->closed_lists != NULL) {
-		g_hash_table_unref (priv->closed_lists);
-		priv->closed_lists = NULL;
-	}
-
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
-#if 0  /* WEBKIT */
-static void
-contact_display_url_requested (GtkHTML *html,
-                               const gchar *uri,
-                               GtkHTMLStream *handle)
-{
-	EABContactDisplay *display;
-	GtkHTMLClass *class;
-	gsize length;
-
-	display = EAB_CONTACT_DISPLAY (html);
-	class = GTK_HTML_CLASS (parent_class);
-
-	/* internal-contact-photo: */
-	if (strcmp (uri, "internal-contact-photo:") == 0) {
-		EContactPhoto *photo;
-		EContact *contact;
-
-		contact = eab_contact_display_get_contact (display);
-		photo = e_contact_get (contact, E_CONTACT_PHOTO);
-		if (photo == NULL)
-			photo = e_contact_get (contact, E_CONTACT_LOGO);
-
-		gtk_html_stream_write (
-			handle, (gchar *) photo->data.inlined.data,
-			photo->data.inlined.length);
-
-		gtk_html_end (html, handle, GTK_HTML_STREAM_OK);
-
-		e_contact_photo_free (photo);
-
-		return;
-	}
-
-	/* evo-icon:<<themed-icon-name>> */
-	length = strlen ("evo-icon:");
-	if (g_ascii_strncasecmp (uri, "evo-icon:", length) == 0) {
-		GtkIconTheme *icon_theme;
-		GtkIconInfo *icon_info;
-		const gchar *filename;
-		gchar *icon_uri;
-		GError *error = NULL;
-
-		icon_theme = gtk_icon_theme_get_default ();
-		icon_info = gtk_icon_theme_lookup_icon (
-			icon_theme, uri + length, GTK_ICON_SIZE_MENU, 0);
-		g_return_if_fail (icon_info != NULL);
-
-		filename = gtk_icon_info_get_filename (icon_info);
-		icon_uri = g_filename_to_uri (filename, NULL, &error);
-
-		if (error != NULL) {
-			g_warning ("%s", error->message);
-			g_error_free (error);
-		}
-
-		/* Chain up with the URI for the icon file. */
-		class->url_requested (html, icon_uri, handle);
-
-		gtk_icon_info_free (icon_info);
-		g_free (icon_uri);
-
-		return;
-	}
-
-	/* Chain up to parent's uri_requested() method. */
-	class->url_requested (html, uri, handle);
-}
-#endif
-
 static GtkWidget *
 contact_display_create_plugin_widget (EWebView *web_view,
                                       const gchar *mime_type,
@@ -1216,34 +1045,9 @@ contact_display_create_plugin_widget (EWebView *web_view,
                                       GHashTable *param)
 {
 	EWebViewClass *web_view_class;
-	EABContactDisplay *display;
-
-	display = EAB_CONTACT_DISPLAY (web_view);
-
-	if (g_strcmp0 (mime_type, "image/x-contact-photo") == 0) {
-		EContactPhoto *photo;
-		EContact *contact;
-		GdkPixbuf *pixbuf;
-		GdkPixbufLoader *loader;
-		GtkWidget *widget = NULL;
 
-		contact = eab_contact_display_get_contact (display);
-		photo = e_contact_get (contact, E_CONTACT_PHOTO);
-		if (photo == NULL)
-			photo = e_contact_get (contact, E_CONTACT_LOGO);
+#warning FIXME: contact_display_create_plugin_widget is not WebKit-ready
 
-		loader = gdk_pixbuf_loader_new ();
-		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 != NULL)
-			widget = gtk_image_new_from_pixbuf (pixbuf);
-		g_object_unref (loader);
-
-		return widget;
-	}
 
 	/* Chain up to parent's create_plugin_widget() method. */
 	web_view_class = E_WEB_VIEW_CLASS (parent_class);
@@ -1303,19 +1107,6 @@ contact_display_link_clicked (EWebView *web_view,
 		index = atoi (uri + length);
 		contact_display_emit_send_message (display, index);
 		return;
-	} else if (g_str_has_prefix (uri, "##") && g_str_has_suffix (uri, "##")) {
-		gchar *list_id = g_strndup (uri+2, strlen (uri) - 4);
-
-		if (g_hash_table_lookup (display->priv->closed_lists, list_id)) {
-			g_hash_table_remove (display->priv->closed_lists, list_id);
-			g_free (list_id);
-		} else {
-			g_hash_table_insert (display->priv->closed_lists, list_id, GINT_TO_POINTER (TRUE));
-		}
-
-		eab_contact_display_render_normal (display, display->priv->contact);
-
-		return;
 	}
 
 	/* Chain up to parent's link_clicked() method. */
@@ -1334,6 +1125,7 @@ handle_map_scroll_event (GtkWidget *widget, GdkEvent *event)
 	return TRUE;
 }
 
+#if 0
 static void
 contact_display_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, EABContactDisplay *display)
 {
@@ -1370,6 +1162,7 @@ contact_display_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, EABContact
 	e_contact_address_free (address);
 }
 #endif
+#endif
 
 static void
 contact_display_update_actions (EWebView *web_view)
@@ -1405,9 +1198,6 @@ static void
 eab_contact_display_class_init (EABContactDisplayClass *class)
 {
 	GObjectClass *object_class;
-#if 0  /* WEBKIT */
-	GtkHTMLClass *html_class;
-#endif
 	EWebViewClass *web_view_class;
 
 	parent_class = g_type_class_peek_parent (class);
@@ -1418,11 +1208,6 @@ eab_contact_display_class_init (EABContactDisplayClass *class)
 	object_class->get_property = contact_display_get_property;
 	object_class->dispose = contact_display_dispose;
 
-#if 0  /* WEBKIT */
-	html_class = GTK_HTML_CLASS (class);
-	html_class->url_requested = contact_display_url_requested;
-#endif
-
 	web_view_class = E_WEB_VIEW_CLASS (class);
 	web_view_class->create_plugin_widget = contact_display_create_plugin_widget;
 	web_view_class->hovering_over_link = contact_display_hovering_over_link;
@@ -1452,18 +1237,6 @@ eab_contact_display_class_init (EABContactDisplayClass *class)
 			EAB_CONTACT_DISPLAY_RENDER_NORMAL,
 			G_PARAM_READWRITE));
 
-	g_object_class_install_property (
-		object_class,
-		PROP_ORIENTATION,
-		g_param_spec_int (
-			"orientation",
-			NULL,
-			NULL,
-			GTK_ORIENTATION_HORIZONTAL,
-			GTK_ORIENTATION_VERTICAL,
-			GTK_ORIENTATION_HORIZONTAL,
-			G_PARAM_READWRITE));
-
 	g_object_class_install_property	(
 		object_class,
 		PROP_SHOW_MAPS,
@@ -1497,18 +1270,17 @@ eab_contact_display_init (EABContactDisplay *display)
 	display->priv = G_TYPE_INSTANCE_GET_PRIVATE (
 		display, EAB_TYPE_CONTACT_DISPLAY, EABContactDisplayPrivate);
 	display->priv->mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL;
-	display->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
 	display->priv->show_maps = FALSE;
-	display->priv->closed_lists = g_hash_table_new_full (g_str_hash, g_str_equal,
-					(GDestroyNotify) g_free, NULL);
 
 	web_view = E_WEB_VIEW (display);
 	ui_manager = e_web_view_get_ui_manager (web_view);
 
 #ifdef WITH_CONTACT_MAPS
+#if 0
 	g_signal_connect (web_view, "object-requested",
 	G_CALLBACK (contact_display_object_requested), display);
 #endif
+#endif
 
 	action_group = gtk_action_group_new ("internal-mailto");
 	gtk_action_group_set_translation_domain (action_group, domain);
@@ -1628,39 +1400,6 @@ eab_contact_display_set_mode (EABContactDisplay *display,
 	g_object_notify (G_OBJECT (display), "mode");
 }
 
-GtkOrientation
-eab_contact_display_get_orientation (EABContactDisplay *display)
-{
-	g_return_val_if_fail (EAB_IS_CONTACT_DISPLAY (display), 0);
-
-	return display->priv->orientation;
-}
-
-void
-eab_contact_display_set_orientation (EABContactDisplay *display, GtkOrientation orientation)
-{
-	EABContactDisplayMode mode;
-	EContact *contact;
-
-	g_return_if_fail (EAB_IS_CONTACT_DISPLAY (display));
-
-	display->priv->orientation = orientation;
-	contact = eab_contact_display_get_contact (display);
-	mode = eab_contact_display_get_mode (display);
-
-	switch (mode) {
-		case EAB_CONTACT_DISPLAY_RENDER_NORMAL:
-			eab_contact_display_render_normal (display, contact);
-			break;
-
-		case EAB_CONTACT_DISPLAY_RENDER_COMPACT:
-			eab_contact_display_render_compact (display, contact);
-			break;
-	}
-
-	g_object_notify (G_OBJECT (display), "orientation");
-}
-
 gboolean
 eab_contact_display_get_show_maps (EABContactDisplay *display)
 {
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 569411e..6c33a15 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1662,7 +1662,6 @@ efh_url_requested (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, EMFor
 	g_signal_stop_emission_by_name (html, "url-requested");
 }
 
-#if 0  /* WEBKIT */
 static gboolean
 efh_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh)
 {
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index e8f2afd..f5f019e 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -276,20 +276,11 @@ book_shell_content_constructed (GObject *object)
 		EAB_CONTACT_DISPLAY (widget),
 		EAB_CONTACT_DISPLAY_RENDER_NORMAL);
 
-	eab_contact_display_set_orientation (
-		EAB_CONTACT_DISPLAY (widget),
-		priv->orientation);
-
 	eab_contact_display_set_show_maps (
 		EAB_CONTACT_DISPLAY (widget),
 		priv->preview_show_maps);
 
 	g_object_bind_property (
-		object, "orientation",
-		widget, "orientation",
-		G_BINDING_SYNC_CREATE);
-
-	g_object_bind_property (
 		object, "preview-show-maps",
 		widget, "show-maps",
 		G_BINDING_SYNC_CREATE);
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 45b6327..4591c5a 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -1088,7 +1088,7 @@ web_view_load_string (EWebView *web_view,
 
 	webkit_web_view_load_string (
 		WEBKIT_WEB_VIEW (web_view),
-		string, "text/html", "UTF-8", NULL);
+		string, "text/html", "UTF-8", "file://");
 }
 
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]