diff gtk/gtkconv.c @ 15359:7c41ecf41614

[gaim-migrate @ 18151] Revert GtkIMHtml hacks that tried to fix gtkimhtml bugs, replace it with heuristic workaround. If you receive a message with more than 100 HTML tags strip all formatting before displaying it. Hopefully nobody has any legitimate uses for 100 HTML tags in a message. I guess we'll see in beta6... which I think we're good for now. I think that post-2.0.0 we'll wind up replacing GtkIMHtml with a legitimate HTML widget and do the Adium/Kopete "chat theme" thing. An HTML widget should be able to handle formatting more efficiently than GtkTextView. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 18 Jan 2007 02:35:14 +0000
parents db11d9e416ac
children
line wrap: on
line diff
--- a/gtk/gtkconv.c	Wed Jan 17 22:44:30 2007 +0000
+++ b/gtk/gtkconv.c	Thu Jan 18 02:35:14 2007 +0000
@@ -4810,7 +4810,9 @@
 	GaimConversationType type;
 	char *displaying;
 	gboolean plugin_return;
-
+	char *bracket;
+	int tag_count = 0;
+	
 	g_return_if_fail(conv != NULL);
 	gtkconv = GAIM_GTK_CONVERSATION(conv);
 	g_return_if_fail(gtkconv != NULL);
@@ -4853,6 +4855,19 @@
 	message = displaying;
 	length = strlen(message) + 1;
 
+	/* Awful hack to work around GtkIMHtml's inefficient rendering of messages with lots of formatting changes.
+	 * If a message has over 100 '<' characters, strip formatting before appending it. Hopefully nobody actually
+	 * needs that much formatting, anyway.
+	 */
+	for (bracket = strchr(message, '<'); bracket && *(bracket + 1); bracket = strchr(bracket + 1, '<'))
+		tag_count++;
+	
+	if (tag_count > 100) {
+		char *tmp = message;
+		message = displaying = gaim_markup_strip_html(message);
+		g_free(tmp);
+	}	
+	
 	win = gtkconv->win;
 	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);