changeset 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 544e7f57836c
children 2c85b0f97dd0
files console/gntblist.c console/libgnt/gntmain.c console/libgnt/gnttextview.c console/libgnt/gnttree.c console/libgnt/test/multiwin.c
diffstat 5 files changed, 30 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntblist.c	Tue Aug 15 08:59:11 2006 +0000
+++ b/console/gntblist.c	Tue Aug 15 18:05:14 2006 +0000
@@ -67,6 +67,7 @@
 static gboolean remove_typing_cb(gpointer null);
 static void remove_peripherals(GGBlist *ggblist);
 static const char * get_display_name(GaimBlistNode *node);
+static void savedstatus_changed(GaimSavedStatus *now, GaimSavedStatus *old);
 
 static void
 new_node(GaimBlistNode *node)
@@ -1150,6 +1151,9 @@
 	}
 	else if (now->type == STATUS_SAVED_ALL)
 	{
+		/* Restore the selection to reflect current status. */
+		savedstatus_changed(gaim_savedstatus_get_current(), NULL);
+		gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree);
 		gg_savedstatus_show_all();
 	}
 	else
--- a/console/libgnt/gntmain.c	Tue Aug 15 08:59:11 2006 +0000
+++ b/console/libgnt/gntmain.c	Tue Aug 15 18:05:14 2006 +0000
@@ -16,6 +16,8 @@
 /**
  * Notes: Interesting functions to look at:
  * 	scr_dump, scr_init, scr_restore: for workspaces
+ *
+ * 	Need to wattrset for colors to use with PDCurses.
  */
 
 static int lock_focus_list;
@@ -176,6 +178,7 @@
 	{
 		GntWidget *w = iter->data;
 		int color;
+		const char *title;
 
 		if (w == focus_list->data)
 		{
@@ -194,7 +197,8 @@
 		}
 		wbkgdset(taskbar, '\0' | COLOR_PAIR(color));
 		mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width);
-		mvwprintw(taskbar, 0, width * i, "%s", GNT_BOX(w)->title);
+		title = GNT_BOX(w)->title;
+		mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>");
 
 		update_window_in_list(w);
 	}
--- a/console/libgnt/gnttextview.c	Tue Aug 15 08:59:11 2006 +0000
+++ b/console/libgnt/gnttextview.c	Tue Aug 15 18:05:14 2006 +0000
@@ -26,7 +26,7 @@
 	GntTextView *view = GNT_TEXT_VIEW(widget);
 	int i = 0;
 	GList *lines;
-	int showing, position, rows, scrcol;
+	int rows, scrcol;
 
 	werase(widget->window);
 
@@ -51,11 +51,17 @@
 	rows = widget->priv.height - 2;
 	if (rows > 0)
 	{
+		int total = g_list_length(g_list_first(view->list));
+		int showing, position, up, down;
 
-		showing = rows * rows / g_list_length(g_list_first(view->list)) + 1;
+		showing = rows * rows / total + 1;
 		showing = MIN(rows, showing);
 
-		position = showing * g_list_length(view->list) / rows;
+		total -= rows;
+		up = g_list_length(lines);
+		down = total - up;
+
+		position = (rows - showing) * up / MAX(1, up + down);
 		position = MAX((lines != NULL), position);
 
 		if (showing + position > rows)
--- 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)
--- a/console/libgnt/test/multiwin.c	Tue Aug 15 08:59:11 2006 +0000
+++ b/console/libgnt/test/multiwin.c	Tue Aug 15 18:05:14 2006 +0000
@@ -63,7 +63,7 @@
 	gnt_tree_add_row_after(GNT_TREE(tree), "6", gnt_tree_create_row(GNT_TREE(tree), "6", " long text", "a2"), "4", NULL);
 
 	int i;
-	for (i = 110; i < 130; i++)
+	for (i = 110; i < 430; i++)
 	{
 		char *s;
 		s = g_strdup_printf("%d", i); /* XXX: yes, leaking */