Mercurial > pidgin.yaz
diff finch/libgnt/gnttree.c @ 18449:ed17f5530300
Allow showing right-aligned text trees. Right-align the size in the file
selector tree.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 06 Jul 2007 21:42:25 +0000 |
parents | be10fc22d649 |
children | da550279d390 |
line wrap: on
line diff
--- a/finch/libgnt/gnttree.c Fri Jul 06 06:14:31 2007 +0000 +++ b/finch/libgnt/gnttree.c Fri Jul 06 21:42:25 2007 +0000 @@ -33,6 +33,7 @@ #define COLUMN_INVISIBLE(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_INVISIBLE) #define BINARY_DATA(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_BINARY_DATA) +#define RIGHT_ALIGNED(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_RIGHT_ALIGNED) enum { @@ -306,10 +307,7 @@ len = gnt_util_onscreen_width(display, NULL); - if (i == tree->lastvisible) - width = GNT_WIDGET(tree)->priv.width - gnt_util_onscreen_width(string->str, NULL); - else - width = tree->columns[i].width; + width = tree->columns[i].width; if (i == 0) { @@ -348,6 +346,11 @@ len = width - 1; cut = TRUE; } + + if (RIGHT_ALIGNED(tree, i) && len < tree->columns[i].width) { + g_string_append_printf(string, "%*s", width - len, ""); + } + text = gnt_util_onscreen_width_to_pointer(display, len - fl, NULL); string = g_string_append_len(string, display, text - display); if (cut) { /* ellipsis */ @@ -358,7 +361,7 @@ len++; } - if (len < tree->columns[i].width && iter->next) + if (!RIGHT_ALIGNED(tree, i) && len < tree->columns[i].width && iter->next) g_string_append_printf(string, "%*s", width - len, ""); } return g_string_free(string, FALSE); @@ -1709,6 +1712,12 @@ set_column_flag(tree, col, GNT_TREE_COLUMN_FIXED_SIZE, bin); } +void gnt_tree_set_column_is_right_aligned(GntTree *tree, int col, gboolean right) +{ + g_return_if_fail(col < tree->ncol); + set_column_flag(tree, col, GNT_TREE_COLUMN_RIGHT_ALIGNED, right); +} + void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]) { int i;