--- pidgin/gtkconv.c	2007-05-02 00:35:21.000000000 +0900
+++ /home/compile/pidgin-2.0.0beta7-yaz/pidgin/gtkconv.c	2007-05-02 00:34:42.000000000 +0900
@@ -6047,10 +6047,11 @@
 	if ((fields & PIDGIN_CONV_COLORIZE_TITLE) ||
 			(fields & PIDGIN_CONV_SET_TITLE))
 	{
-		char *title;
+		char *title, *title_tmp;
 		PurpleConvIm *im = NULL;
 		PurpleAccount *account = purple_conversation_get_account(conv);
 		AtkObject *accessibility_obj;
+		gboolean ellipsis = FALSE;
 		/* I think this is a little longer than it needs to be but I'm lazy. */
 		char style[51];
 
@@ -6099,11 +6100,21 @@
 			strncpy(style, "color=\"#888a85\" style=\"italic\"", sizeof(style));
 		}
 
+		if (purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_LEFT|8)
+		|| purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side") == (GTK_POS_RIGHT|8))
+			ellipsis = TRUE;
+
+		if (ellipsis)
+			title_tmp = pidgin_gtk_ellipsis_text(gtkconv->tab_label, title, 60, "...");
+		else
+			title_tmp = title;
+		
+
 		if (*style != '\0')
 		{
 			char *html_title,*label;
 
-			html_title = g_markup_escape_text(title, -1);
+			html_title = g_markup_escape_text(title_tmp, -1);
 
 			label = g_strdup_printf("<span %s>%s</span>",
 			                        style, html_title);
@@ -6112,7 +6123,7 @@
 			g_free(label);
 		}
 		else
-			gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title);
+			gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title_tmp);
 
 		if (pidgin_conv_window_is_active_conversation(conv))
 			update_typing_icon(gtkconv);
@@ -8133,7 +8144,16 @@
 	update_tab_icon(conv);
 
 	/* Tab label. */
-	gtkconv->tab_label = gtk_label_new(tmp_lab = purple_conversation_get_title(conv));
+	gtkconv->tab_label = gtk_label_new("");
+	if (angle)
+		tmp_lab = pidgin_gtk_ellipsis_text(gtkconv->tab_label,
+						purple_conversation_get_title(conv),
+						60, "...");
+	else
+		tmp_lab = purple_conversation_get_title(conv);
+
+	gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), tmp_lab);
+
 
 #if GTK_CHECK_VERSION(2,6,0)
 	if (!angle)
--- pidgin/gtkutils.h	2007-04-27 17:33:43.000000000 +0900
+++ /home/compile/pidgin-2.0.0beta7-yaz/pidgin/gtkutils.h	2007-05-01 23:57:31.000000000 +0900
@@ -541,5 +541,7 @@
 GtkTreePath *gtk_tree_path_new_from_indices (gint first_index, ...);
 #endif
 
+gchar *pidgin_gtk_ellipsis_text(GtkWidget *widget, const char *text, gint min_width, gchar *ellipsis);
+
 #endif /* _PIDGINUTILS_H_ */
 
--- pidgin/gtkutils.c	2007-04-30 10:26:53.000000000 +0900
+++ /home/compile/pidgin-2.0.0beta7-yaz/pidgin/gtkutils.c	2007-05-02 00:34:52.000000000 +0900
@@ -3107,3 +3107,77 @@
 	return path;
 }
 #endif
+
+gchar *
+pidgin_gtk_ellipsis_text(GtkWidget *widget, const char *text, gint min_width, gchar *ellipsis)
+{
+	PangoLayout *layout;
+	gint width, height;
+	glong len0, len1, len2;
+	static gchar buf[1024], buf_tmp[1024];
+	gint ewidth;
+	gboolean with_ellipsis = FALSE;
+
+	g_strlcpy(buf_tmp, text, sizeof(buf_tmp));
+
+	if (strlen(text) >= sizeof(buf)) {
+		/* cutting off */
+		if (! g_utf8_validate(buf_tmp, -1, NULL)) {
+			buf_tmp[sizeof(buf_tmp) - 1] = '\0';
+			if (! g_utf8_validate(buf_tmp, -1, NULL)) {
+				buf_tmp[sizeof(buf_tmp) - 2] = '\0';
+				if (! g_utf8_validate(buf_tmp, -1, NULL)) {
+					return NULL; /* failed */
+				}
+			}
+		}
+	}
+
+	buf[0] = '\0';
+
+#define ELLIPSIS "..."
+
+	layout = gtk_widget_create_pango_layout(widget, 
+						ellipsis ? ellipsis : ELLIPSIS);
+
+	pango_layout_get_pixel_size(layout, &width, &height);
+	ewidth = width;
+
+	len0 = 0;
+	len1 = g_utf8_strlen(buf_tmp, -1);
+	len2 = len1;
+
+	while (1) {
+
+		if (len2 == len0)
+			break;
+
+		g_utf8_strncpy (buf, buf_tmp, len2);
+		pango_layout_set_text(layout, buf, -1);
+		pango_layout_get_pixel_size(layout, &width, &height);
+
+		if (! with_ellipsis && width <= min_width)
+			break;
+		else
+			with_ellipsis = TRUE;
+
+		if (width + ewidth > min_width)
+			len1 = len2;
+		else
+			len0 = len2;
+
+		len2 = (len0 + len1) / 2;
+	}
+
+	g_utf8_strncpy (buf, buf_tmp, len2);
+	g_object_unref(layout);
+
+
+	if (with_ellipsis) 
+		g_strlcat (buf, ellipsis ? ellipsis : ELLIPSIS, sizeof(buf));
+
+#undef ELLIPSIS
+
+	return buf;
+}
+
