changeset 23344:6d4e4a5963f3

Fix an off-by-one bug in calculating column widths in trees.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 09 Jun 2008 19:32:20 +0000
parents 3cc64898bdbd
children 9a7520e489f8
files finch/gntblist.c finch/libgnt/gnttree.c
diffstat 2 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntblist.c	Mon Jun 09 19:31:43 2008 +0000
+++ b/finch/gntblist.c	Mon Jun 09 19:32:20 2008 +0000
@@ -3033,9 +3033,6 @@
 	gnt_widget_set_position(ggblist->window, purple_prefs_get_int(PREF_ROOT "/position/x"),
 			purple_prefs_get_int(PREF_ROOT "/position/y"));
 
-	gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0,
-			purple_prefs_get_int(PREF_ROOT "/size/width") - 1);
-
 	gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree);
 
 	ggblist->status = gnt_combo_box_new();
--- a/finch/libgnt/gnttree.c	Mon Jun 09 19:31:43 2008 +0000
+++ b/finch/libgnt/gnttree.c	Mon Jun 09 19:32:20 2008 +0000
@@ -110,13 +110,14 @@
 	gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL);
 	if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER))
 		width -= 2;
+	width -= 1;  /* Exclude the scrollbar from the calculation */
 	for (i = 0, total = 0; i < tree->ncol ; i++) {
 		if (tree->columns[i].flags & GNT_TREE_COLUMN_INVISIBLE)
 			continue;
 		if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE)
-			width -= WIDTH(i) + 1;
+			width -= WIDTH(i) + (tree->priv->lastvisible != i);
 		else
-			total += WIDTH(i) + 1;
+			total += WIDTH(i) + (tree->priv->lastvisible != i);
 	}
 
 	if (total == 0)