Mercurial > pidgin.yaz
changeset 16250:50e1b269598e
merge of '2bafabcca7d12b1fb39369f54333c5309a7cead1'
and '2bc4c67a691dc5b511af8298e1da45e14de48c0d'
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 18 Apr 2007 22:57:03 +0000 |
parents | ff2cd3f29f9b (current diff) f02e611bdb6b (diff) |
children | 017405933589 |
files | |
diffstat | 1 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/gnttree.c Wed Apr 18 22:00:41 2007 +0000 +++ b/finch/libgnt/gnttree.c Wed Apr 18 22:57:03 2007 +0000 @@ -7,6 +7,7 @@ #include <ctype.h> #define SEARCH_TIMEOUT 4000 /* 4 secs */ +#define SEARCHING(tree) (tree->search && tree->search->len > 0) enum { @@ -503,6 +504,14 @@ mvwaddch(widget->window, widget->priv.height - pos - 1, scrcol, (row ? ACS_DARROW : ' ') | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); + /* If there's a search-text, show it in the bottom of the tree */ + if (tree->search && tree->search->len > 0) { + const char *str = gnt_util_onscreen_width_to_pointer(tree->search->str, scrcol - 1, NULL); + wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); + mvwaddnstr(widget->window, widget->priv.height - pos - 1, pos, + tree->search->str, str - tree->search->str); + } + gnt_widget_queue_update(widget); } @@ -576,15 +585,17 @@ { GntTree *tree = GNT_TREE(bind); GntTreeRow *row = tree->current; - if (row->parent) { - int dist; - tree->current = row->parent; - if ((dist = get_distance(tree->current, tree->top)) > 0) - gnt_tree_scroll(tree, -dist); - else - redraw_tree(tree); - tree_selection_changed(tree, row, tree->current); - } + int dist; + + if (!row->parent || SEARCHING(tree)) + return FALSE; + + tree->current = row->parent; + if ((dist = get_distance(tree->current, tree->top)) > 0) + gnt_tree_scroll(tree, -dist); + else + redraw_tree(tree); + tree_selection_changed(tree, row, tree->current); return TRUE; } @@ -693,8 +704,15 @@ end_search(tree); gnt_widget_activate(widget); } else if (tree->search) { + gboolean changed = TRUE; if (isalnum(*text)) { tree->search = g_string_append_c(tree->search, *text); + } else if (g_utf8_collate(text, GNT_KEY_BACKSPACE) == 0) { + if (tree->search->len) + tree->search->str[--tree->search->len] = '\0'; + } else + changed = FALSE; + if (changed) { redraw_tree(tree); g_source_remove(tree->search_timeout); tree->search_timeout = g_timeout_add(SEARCH_TIMEOUT, search_timeout, tree);