diff finch/libgnt/gnttree.c @ 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 6843c06f5c6a
children 55f4261e1358
line wrap: on
line diff
--- 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)