Index: em-format-html.c
===================================================================
--- em-format-html.c	(revision 34757)
+++ em-format-html.c	(working copy)
@@ -670,7 +670,11 @@
 		const char *icon;
 		CamelMimePart *iconpart;
 
-		camel_stream_printf (stream, "<table border=0 width=\"100%%\" cellpadding=3 cellspacing=0%s><tr>",
+		if(gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
+			camel_stream_printf (stream, "<table align=\"right\" border=0 width=\"100%%\" cellpadding=3 cellspacing=0%s><tr>",
+ 				     smime_sign_colour[valid->sign.status]);
+		else	
+			camel_stream_printf (stream, "<table border=0 width=\"100%%\" cellpadding=3 cellspacing=0%s><tr>",
 				     smime_sign_colour[valid->sign.status]);
 
 		classid = g_strdup_printf("smime:///em-format-html/%s/icon/signed", emf->part_id->str);
@@ -1484,25 +1488,44 @@
 	else
 		html = mhtml = camel_text_to_html (value, emfh->text_html_flags, 0);
 
-	if (emfh->simple_headers) {
-		fmt = "<b>%s</b>: %s<br>";
-	} else {
-		if (flags & EM_FORMAT_HTML_HEADER_NOCOLUMNS) {
-			if (flags & EM_FORMAT_HEADER_BOLD)
-				fmt = "<tr><td><b>%s:</b> %s</td></tr>";
+	gboolean is_rtl = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL;
+ 	if (emfh->simple_headers) {
+ 		fmt = "<b>%s</b>: %s<br>";
+ 	} else {
+ 		if (flags & EM_FORMAT_HTML_HEADER_NOCOLUMNS) {
+ 			if (flags & EM_FORMAT_HEADER_BOLD){
+				if(is_rtl)
+					fmt = "<tr><td align=\"right\">%s: %s</td></tr>";
+				else
+					fmt = "<tr><td><b>%s:</b> %s</td></tr>";
+			}
+ 			else{
+				if(is_rtl)
+					fmt = "<tr><td align=\"right\">%s: %s</td></tr>";
+				else
+					fmt = "<tr><td>%s: %s</td></tr>";
+			}
+ 		} else if (flags & EM_FORMAT_HTML_HEADER_NODEC) {
+			if(is_rtl)
+				fmt = "<tr><td align=\"left\" valign=\"top\">%s</td><th valign=top alight=\"left\" nowrap>%s:<b>&nbsp;</b></th></tr>";
 			else
-				fmt = "<tr><td>%s: %s</td></tr>";
-		} else if (flags & EM_FORMAT_HTML_HEADER_NODEC) {
-			fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s<b>&nbsp;</b></th><td valign=top>%s</td></tr>";
-		} else {
+				fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s<b>&nbsp;</b></th><td valign=top>%s</td></tr>";
+ 		} else {
+ 			if (flags & EM_FORMAT_HEADER_BOLD) {
+				if(is_rtl)
+					fmt = "<tr><td align=\"left\" valign=\"top\">%s</td><th align=\"left\" nowrap>%s:<b>&nbsp;</b></th></tr>";
+				else
+					fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></th><td>%s</td></tr>";
+			}
+ 			else{
+				if(is_rtl)
+					fmt = "<tr><td align=\"left\" valign=\"top\">%s</td><td nowrap>%s:<b>&nbsp;</b></td></tr>";
+				else
+					fmt = "<tr><td align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></td><td>%s</td></tr>";
+			}
+ 		}
+ 	}
 
-			if (flags & EM_FORMAT_HEADER_BOLD)
-				fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></th><td>%s</td></tr>";
-			else
-				fmt = "<tr><td align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></td><td>%s</td></tr>";
-		}
-	}
-
 	camel_stream_printf(stream, fmt, label, html);
 	g_free(mhtml);
 }
@@ -1643,6 +1666,7 @@
 		}
 	}
 
+	gboolean is_rtl = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL;
 	if (addrspec) {
 		struct _camel_header_address *addrs;
 		GString *html;
@@ -1761,7 +1785,10 @@
 		label = header->name;
 	}
 
-	efh_format_text_header(efh, stream, label, txt, flags);
+	if(is_rtl)
+		efh_format_text_header(efh, stream, txt, label, flags);
+	else
+		efh_format_text_header(efh, stream, label, txt, flags);
 
 	g_free(value);
 	g_free (str_field);
@@ -1838,7 +1865,10 @@
 
 		if (header_sender && header_from && mail_from_delegate) {
 			camel_stream_printf(stream, "<tr><td><table border=1 width=\"100%%\" cellspacing=2 cellpadding=2><tr>");
-			camel_stream_printf(stream, "<td align=\"left\" width=\"100%%\">");
+			if(is_rtl)
+				camel_stream_printf(stream, "<td align=\"right\" width=\"100%%\">");
+			else
+				camel_stream_printf(stream, "<td align=\"left\" width=\"100%%\">");
 			/* To translators: This message suggests to the receipients that the sender of the mail is
 			   different from the one listed in From field.
 			*/
@@ -1852,8 +1882,11 @@
 
 	g_free (header_sender);
 	g_free (header_from);
+	if(is_rtl)
+		camel_stream_printf(stream, "<tr><td align=\"right\"><table style=\"dir: rtl\" border=0 cellpadding=\"0\">\n");
+	else 
+		camel_stream_printf(stream, "<tr><td><table border=0 cellpadding=\"0\">\n");
 
-	camel_stream_printf(stream, "<tr><td><table border=0 cellpadding=\"0\">\n");
 
 	/* dump selected headers */
 	h = (EMFormatHeader *)emf->header_list.head;
@@ -2036,7 +2069,16 @@
 	/* we display all inlined attachments only */
 
 	/* this could probably be cleaned up ... */
-	camel_stream_write_string(stream,
+	if(gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
+		camel_stream_write_string(stream,
+				  "<table align=\"right\" border=1 cellspacing=0 cellpadding=0><tr><td align=\"right\">"
+				  "<table align=\"right\" width=10 cellspacing=0 cellpadding=0>"
+				  "<tr><td></td></tr></table></td>"
+				  "<td align=\"right\"><table align=\"right\" width=3 cellspacing=0 cellpadding=0>"
+				  "<tr><td></td></tr></table></td><td align=\"right\"><font size=-1>\n");
+
+	else
+		camel_stream_write_string(stream,
 				  "<table border=1 cellspacing=0 cellpadding=0><tr><td>"
 				  "<table width=10 cellspacing=0 cellpadding=0>"
 				  "<tr><td></td></tr></table></td>"
