changeset 14030:0e70bb6d32fd

[gaim-migrate @ 16632] Do not auto-scroll when I am reading the backlog. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 05 Aug 2006 02:56:18 +0000
parents d63f59ee6c98
children 942170284c55
files console/gntconv.c console/libgnt/gnttextview.c console/libgnt/gnttextview.h
diffstat 3 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntconv.c	Sat Aug 05 02:19:19 2006 +0000
+++ b/console/gntconv.c	Sat Aug 05 02:56:18 2006 +0000
@@ -221,6 +221,7 @@
 	GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); /* XXX: ggconv = conv->ui_data; should do */
 	char *strip, *newline;
 	GntTextFormatFlags fl = 0;
+	int pos;
 
 	g_return_if_fail(ggconv != NULL);
 
@@ -239,13 +240,16 @@
 	if (flags & GAIM_MESSAGE_NICK)
 		fl |= GNT_TEXT_FLAG_UNDERLINE;
 
+	pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv));
+
 	/* XXX: Remove this workaround when textview can parse messages. */
 	newline = gaim_strdup_withhtml(message);
 	strip = gaim_markup_strip_html(newline);
 	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
 				strip, fl);
 	gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv));
-	gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
+	if (pos <= 1)
+		gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
 
 	g_free(newline);
 	g_free(strip);
--- a/console/libgnt/gnttextview.c	Sat Aug 05 02:19:19 2006 +0000
+++ b/console/libgnt/gnttextview.c	Sat Aug 05 02:56:18 2006 +0000
@@ -93,6 +93,7 @@
 gnt_text_view_destroy(GntWidget *widget)
 {
 	GntTextView *view = GNT_TEXT_VIEW(widget);
+	view->list = g_list_first(view->list);
 	g_list_foreach(view->list, free_text_line, NULL);
 	g_list_free(view->list);
 }
@@ -294,3 +295,24 @@
 		gnt_widget_draw(GNT_WIDGET(view));
 }
 
+int gnt_text_view_get_lines_below(GntTextView *view)
+{
+	int below = 0;
+	GList *list = view->list;
+	while ((list = list->prev))
+		++below;
+	return below;
+}
+
+int gnt_text_view_get_lines_above(GntTextView *view)
+{
+	int above = 0;
+	GList *list = view->list;
+	list = g_list_nth(view->list, GNT_WIDGET(view)->priv.height);
+	if (!list)
+		return 0;
+	while ((list = list->next))
+		++above;
+	return above;
+}
+
--- a/console/libgnt/gnttextview.h	Sat Aug 05 02:19:19 2006 +0000
+++ b/console/libgnt/gnttextview.h	Sat Aug 05 02:56:18 2006 +0000
@@ -69,6 +69,10 @@
 
 void gnt_text_view_clear(GntTextView *view);
 
+int gnt_text_view_get_lines_below(GntTextView *view);
+
+int gnt_text_view_get_lines_above(GntTextView *view);
+
 G_END_DECLS
 
 #endif /* GNT_TEXT_VIEW_H */