Mercurial > pidgin
diff console/libgnt/gnttree.c @ 14613:62bb53609a36
[gaim-migrate @ 17341]
Menus and windows. I have added a test-app test/menu.c to show how to use it.
Pressing Ctrl+o brings up the menu for the window (if it has one).
It should now be possible to add menus for account-actions and all that stuff.
Patches are very welcome.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 24 Sep 2006 07:14:26 +0000 |
parents | 3ac156db9cb6 |
children | f1f1dcb26d89 |
line wrap: on
line diff
--- a/console/libgnt/gnttree.c Sat Sep 23 19:04:03 2006 +0000 +++ b/console/libgnt/gnttree.c Sun Sep 24 07:14:26 2006 +0000 @@ -288,8 +288,10 @@ tree_mark_columns(tree, pos, widget->priv.height - pos, ACS_BTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); } - tree_mark_columns(tree, pos, pos + 1, ACS_PLUS | COLOR_PAIR(GNT_COLOR_NORMAL)); - tree_mark_columns(tree, pos, pos, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos + 1, + (tree->show_separator ? ACS_PLUS : ACS_HLINE) | COLOR_PAIR(GNT_COLOR_NORMAL)); + tree_mark_columns(tree, pos, pos, + (tree->show_separator ? ACS_VLINE : ' ') | COLOR_PAIR(GNT_COLOR_NORMAL)); start = 2; } @@ -356,7 +358,8 @@ whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1) - 1); tree->bottom = row; g_free(str); - tree_mark_columns(tree, pos, i, ACS_VLINE | attr); + tree_mark_columns(tree, pos, i, + (tree->show_separator ? ACS_VLINE : ' ') | attr); } wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); @@ -364,7 +367,8 @@ { mvwhline(widget->window, i, pos, ' ', widget->priv.width - pos * 2 - 1); - tree_mark_columns(tree, pos, i, ACS_VLINE); + tree_mark_columns(tree, pos, i, + (tree->show_separator ? ACS_VLINE : ' ')); i++; } @@ -696,6 +700,8 @@ gnt_tree_init(GTypeInstance *instance, gpointer class) { GntWidget *widget = GNT_WIDGET(instance); + GntTree *tree = GNT_TREE(widget); + tree->show_separator = TRUE; GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y); widget->priv.minw = 4; widget->priv.minh = 4; @@ -1125,19 +1131,24 @@ redraw_tree(tree); } -GntWidget *gnt_tree_new_with_columns(int col) +void _gnt_tree_init_internals(GntTree *tree, int col) { - GntWidget *widget = g_object_new(GNT_TYPE_TREE, NULL); - GntTree *tree = GNT_TREE(widget); - + tree->ncol = col; tree->hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_tree_row); - tree->ncol = col; tree->columns = g_new0(struct _GntTreeColInfo, col); while (col--) { tree->columns[col].width = 15; } tree->show_title = FALSE; +} + +GntWidget *gnt_tree_new_with_columns(int col) +{ + GntWidget *widget = g_object_new(GNT_TYPE_TREE, NULL); + GntTree *tree = GNT_TREE(widget); + + _gnt_tree_init_internals(tree, col); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW); gnt_widget_set_take_focus(widget, TRUE); @@ -1224,3 +1235,9 @@ gnt_widget_draw(GNT_WIDGET(tree)); } } + +void gnt_tree_set_show_separator(GntTree *tree, gboolean set) +{ + tree->show_separator = set; +} +