diff console/libgnt/gnttree.c @ 14131:db2311999862

[gaim-migrate @ 16773] Some adjustment to the scrollbars. Deal with dialogs with NULL title. Status-selector in the buddylist should always show the active status. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 15 Aug 2006 18:05:14 +0000
parents b71bfeaaed58
children 7d708210e317
line wrap: on
line diff
--- a/console/libgnt/gnttree.c	Tue Aug 15 08:59:11 2006 +0000
+++ b/console/libgnt/gnttree.c	Tue Aug 15 18:05:14 2006 +0000
@@ -250,7 +250,7 @@
 	GntWidget *widget = GNT_WIDGET(tree);
 	GntTreeRow *row;
 	int pos, up, down;
-	int showing, position, rows, scrcol;
+	int rows, scrcol;
 
 	if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED))
 		return;
@@ -371,11 +371,18 @@
 	rows--;
 	if (rows > 0)
 	{
-		get_next_n_opt(tree->root, g_list_length(tree->list), &i);
-		showing = rows * rows / MAX(i, 1) + 1;
+		int total;
+		int showing, position;
+
+		get_next_n_opt(tree->root, g_list_length(tree->list), &total);
+		showing = rows * rows / MAX(total, 1) + 1;
 		showing = MIN(rows, showing);
 
-		position = showing * get_distance(tree->root, tree->top) / rows;
+		total -= rows;
+		up = get_distance(tree->root, tree->top);
+		down = total - up;
+
+		position = (rows - showing) * up / MAX(1, up + down);
 		position = MAX((tree->top != tree->root), position);
 
 		if (showing + position > rows)