# HG changeset patch # User Sadrul Habib Chowdhury # Date 1154746578 0 # Node ID 0e70bb6d32fd85da4e6acff57dd8715b44d2a15e # Parent d63f59ee6c98e3a3731ab25a3e6ce82a96413f8d [gaim-migrate @ 16632] Do not auto-scroll when I am reading the backlog. committer: Tailor Script diff -r d63f59ee6c98 -r 0e70bb6d32fd console/gntconv.c --- 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); diff -r d63f59ee6c98 -r 0e70bb6d32fd console/libgnt/gnttextview.c --- 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; +} + diff -r d63f59ee6c98 -r 0e70bb6d32fd console/libgnt/gnttextview.h --- 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 */