changeset 16229:12e2ee612d5f

Fix for using Pango < 1.4, will not have complete RTL support with older Pango though.
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 17 Apr 2007 11:14:50 +0000
parents 66706d858e9a
children d930a82cda63 e8173e12182a
files config.h.mingw configure.ac pidgin/gtkconv.c pidgin/gtkimhtml.c
diffstat 4 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/config.h.mingw	Tue Apr 17 10:15:54 2007 +0000
+++ b/config.h.mingw	Tue Apr 17 11:14:50 2007 +0000
@@ -279,6 +279,9 @@
 /* Define to 1 if you have the <nss.h> header file. */
 /* #undef HAVE_NSS_H */
 
+/* Define if we have Pango 1.4 or newer. */
+#define HAVE_PANGO14 1
+
 /* Define to 1 if you have the <paths.h> header file. */
 /* #define HAVE_PATHS_H 1 */
 
--- a/configure.ac	Tue Apr 17 10:15:54 2007 +0000
+++ b/configure.ac	Tue Apr 17 11:14:50 2007 +0000
@@ -241,6 +241,10 @@
 	AC_SUBST(GTK_CFLAGS)
 	AC_SUBST(GTK_LIBS)
 
+	dnl We only really need Pango >= 1.4 for decent RTL support
+	PKG_CHECK_MODULES(pango, [pango >= 1.4.0],
+			AC_DEFINE(HAVE_PANGO14, 1, [Define if we have Pango 1.4 or newer.]),)
+
 	dnl #######################################################################
 	dnl # Check for XScreenSaver
 	dnl #######################################################################
--- a/pidgin/gtkconv.c	Tue Apr 17 10:15:54 2007 +0000
+++ b/pidgin/gtkconv.c	Tue Apr 17 11:14:50 2007 +0000
@@ -4900,33 +4900,35 @@
 static void
 str_embed_direction_chars(char **str)
 {
+#ifdef HAVE_PANGO14
 	char pre_str[4];
 	char post_str[10];
-	char *ret = g_malloc(strlen(*str)+13);
+	char *ret;
 
 	if (PANGO_DIRECTION_RTL == pango_find_base_dir(*str, -1))
 	{
-		g_sprintf(pre_str, "%c%c%c", 
+		sprintf(pre_str, "%c%c%c",
 				0xE2, 0x80, 0xAB);	/* RLE */
-		g_sprintf(post_str, "%c%c%c%c%c%c%c%c%c", 
+		sprintf(post_str, "%c%c%c%c%c%c%c%c%c",
 				0xE2, 0x80, 0xAC,	/* PDF */
 				0xE2, 0x80, 0x8E,	/* LRM */
 				0xE2, 0x80, 0xAC);	/* PDF */
 	}
 	else
 	{
-		g_sprintf(pre_str, "%c%c%c", 
+		sprintf(pre_str, "%c%c%c",
 				0xE2, 0x80, 0xAA);	/* LRE */
-		g_sprintf(post_str, "%c%c%c%c%c%c%c%c%c", 
+		sprintf(post_str, "%c%c%c%c%c%c%c%c%c",
 				0xE2, 0x80, 0xAC,	/* PDF */
 				0xE2, 0x80, 0x8F,	/* RLM */
 				0xE2, 0x80, 0xAC);	/* PDF */
 	}
 
-	g_sprintf(ret, "%s%s%s", pre_str, *str, post_str);
+	ret = g_strconcat(pre_str, *str, post_str, NULL);
 
 	g_free(*str);
 	*str = ret;
+#endif
 }
 
 /* Returns true if the given HTML contains RTL text */
--- a/pidgin/gtkimhtml.c	Tue Apr 17 10:15:54 2007 +0000
+++ b/pidgin/gtkimhtml.c	Tue Apr 17 11:14:50 2007 +0000
@@ -4573,12 +4573,14 @@
 
 	/* Bi-directional text support */
 	/* Get to the first non-neutral character */
+#ifdef HAVE_PANGO14
 	while ((PANGO_DIRECTION_NEUTRAL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter)))
 		&& gtk_text_iter_forward_char(&non_neutral_iter));
 	if (PANGO_DIRECTION_RTL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) {
 		is_rtl_message = TRUE;
 		g_string_append(str, "<SPAN style=\"direction:rtl;text-align:right;\">");
 	}
+#endif
 
 	/* First add the tags that are already in progress (we don't care about non-printing tags)*/
 	tags = gtk_text_iter_get_tags(start);