gtkconv: Fix alignment of incoming RTL messages in protocols without rich text release-2.x.y

Mon, 11 Apr 2016 04:22:21 -0300

author
dx <dx@dxzone.com.ar>
date
Mon, 11 Apr 2016 04:22:21 -0300
branch
release-2.x.y
changeset 37639
ac3d0b6d6128
parent 37591
2f4d022d0308
child 37650
f827e56eea34

gtkconv: Fix alignment of incoming RTL messages in protocols without rich text

Which means this probably only worked properly for XMPP, given a pidgin client
on the other side which also sent that span tag with direction:rtl. In the case
of outgoing messages, it worked because that span tag was added by pidgin's own
input box.

ChangeLog file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/ChangeLog	Sun Mar 20 21:42:36 2016 -0700
+++ b/ChangeLog	Mon Apr 11 04:22:21 2016 -0300
@@ -3,6 +3,8 @@
 version 2.10.13 (MM/DD/YY):
 	Pidgin:
 	* Fixed #14962
+	* Fixed alignment of incoming right-to-left messages in protocols that
+	don't support rich text
 
 	Windows-Specific Changes:
 	* Use getaddrinfo for DNS to enable IPv6 (#1075)
--- a/pidgin/gtkconv.c	Sun Mar 20 21:42:36 2016 -0700
+++ b/pidgin/gtkconv.c	Mon Apr 11 04:22:21 2016 -0300
@@ -5914,6 +5914,19 @@
 
 	/* Bi-Directional support - set timestamp direction using unicode characters */
 	is_rtl_message = purple_markup_is_rtl(message);
+
+	/* Handle plaintext messages with RTL text but no direction in the markup */
+	if (!is_rtl_message && pango_find_base_dir(message, -1) == PANGO_DIRECTION_RTL)
+	{
+		char *wrapped = g_strdup_printf("<SPAN style=\"direction:rtl;text-align:right;\">%s</SPAN>", displaying);
+
+		g_free(displaying);
+		displaying = wrapped;
+
+		length = strlen(displaying) + 1;
+		is_rtl_message = TRUE;
+	}
+
 	/* Enforce direction only if message is RTL - doesn't effect LTR users */
 	if (is_rtl_message)
 		str_embed_direction_chars(&mdate);

mercurial