comparison 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
comparison
equal deleted inserted replaced
14130:544e7f57836c 14131:db2311999862
248 { 248 {
249 int start, i; 249 int start, i;
250 GntWidget *widget = GNT_WIDGET(tree); 250 GntWidget *widget = GNT_WIDGET(tree);
251 GntTreeRow *row; 251 GntTreeRow *row;
252 int pos, up, down; 252 int pos, up, down;
253 int showing, position, rows, scrcol; 253 int rows, scrcol;
254 254
255 if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) 255 if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED))
256 return; 256 return;
257 257
258 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) 258 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
369 369
370 scrcol = widget->priv.width - pos - 1; 370 scrcol = widget->priv.width - pos - 1;
371 rows--; 371 rows--;
372 if (rows > 0) 372 if (rows > 0)
373 { 373 {
374 get_next_n_opt(tree->root, g_list_length(tree->list), &i); 374 int total;
375 showing = rows * rows / MAX(i, 1) + 1; 375 int showing, position;
376
377 get_next_n_opt(tree->root, g_list_length(tree->list), &total);
378 showing = rows * rows / MAX(total, 1) + 1;
376 showing = MIN(rows, showing); 379 showing = MIN(rows, showing);
377 380
378 position = showing * get_distance(tree->root, tree->top) / rows; 381 total -= rows;
382 up = get_distance(tree->root, tree->top);
383 down = total - up;
384
385 position = (rows - showing) * up / MAX(1, up + down);
379 position = MAX((tree->top != tree->root), position); 386 position = MAX((tree->top != tree->root), position);
380 387
381 if (showing + position > rows) 388 if (showing + position > rows)
382 position = rows - showing; 389 position = rows - showing;
383 390