changeset 21825:9bdfeeea9145

Another tweak to the auto-resizing so it shows new empty lines correctly, and deals with wrapped lines a bit better.
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 12 Dec 2007 20:37:29 +0000
parents 189abce087ab
children c85d1e9d9d27
files pidgin/gtkconv.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Wed Dec 12 19:15:01 2007 +0000
+++ b/pidgin/gtkconv.c	Wed Dec 12 20:37:29 2007 +0000
@@ -4341,16 +4341,17 @@
 
 	lines = gtk_text_buffer_get_line_count(buffer);
 
-	/* Show a maximum of 4 lines */
-	lines = MIN(lines, 4);
-	wrapped_lines = MIN(wrapped_lines, 4);
+	/* Show a maximum of 4 lines, minimum of 2 */
+	lines = MIN(MAX(lines, 2), 4);
+	wrapped_lines = MIN(MAX(wrapped_lines, 2), 4);
 
 	pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry));
 	pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry));
 	pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry));
 
-	height = (oneline.height + pad_top + pad_bottom) * MAX(lines, 2);
-	height += (oneline.height + pad_inside) * (wrapped_lines - lines);
+	height = (oneline.height + pad_top + pad_bottom) * lines;
+	if (wrapped_lines > lines)
+		height += (oneline.height + pad_inside) * (wrapped_lines - lines);
 
 	gtkconv->auto_resize = TRUE;
 	g_idle_add(reset_auto_resize_cb, gtkconv);