im.pidgin.pidgin: 50e7240a3bbd8a2e7d2d39a93f26d35baf168805

nosnilmot at pidgin.im nosnilmot at pidgin.im
Sat Dec 1 11:45:40 EST 2007


-----------------------------------------------------------------
Revision: 50e7240a3bbd8a2e7d2d39a93f26d35baf168805
Ancestor: ae553a7b1f48faebd22d107832f5827460d5d656
Author: nosnilmot at pidgin.im
Date: 2007-12-01T16:43:04
Branch: im.pidgin.pidgin

Modified files:
        pidgin/gtkconv.c

ChangeLog: 

Truncate the topic to an arbitrary 72 characters in the infopane when using
GTK < 2.6 which has no ellipsization support. Fixes #4196

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	1c5dc9c065cf4817484adc94884ba523056a867d
+++ pidgin/gtkconv.c	fc64e427432ddc59b58692a981c3829139d159f4
@@ -6477,7 +6477,28 @@ pidgin_conv_update_fields(PurpleConversa
 			}
 		} else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
 			const char *topic = gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text));
-			char *esc = topic ? g_markup_escape_text(topic, -1) : NULL;
+			char *esc = NULL;
+#if GTK_CHECK_VERSION(2,6,0)
+			esc = topic ? g_markup_escape_text(topic, -1) : NULL;
+#else
+			/* GTK < 2.6 doesn't have auto ellipsization, so we do a crude
+			 * trucation to prevent forcing the window to be as wide as the topic */
+			int len = 0;
+			char *c, *tmp = g_strdup(topic);
+			c = tmp;
+			while(*c && len < 72) {
+				c = g_utf8_next_char(c);
+				len++;
+			}
+			if (len == 72) {
+				*c = '\0';
+				c = g_strdup_printf("%s...", tmp);
+				g_free(tmp);
+				tmp = c;
+			}
+			esc = tmp ? g_markup_escape_text(tmp, -1) : NULL;
+			g_free(tmp);
+#endif
 			markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>",
 						purple_conversation_get_title(conv),
 						esc  && *esc ? "\n" : "",


More information about the Commits mailing list