# HG changeset patch # User Sadrul Habib Chowdhury # Date 1184833526 0 # Node ID 212c2bec5c97584a59e5752de89c674e7c76fa58 # Parent 5e1412f4e67aa87a0f58f5530fa3b66bdbac4d36 Allow using custom search functions. diff -r 5e1412f4e67a -r 212c2bec5c97 ChangeLog.API --- a/ChangeLog.API Tue Jul 17 11:09:03 2007 +0000 +++ b/ChangeLog.API Thu Jul 19 08:25:26 2007 +0000 @@ -106,6 +106,8 @@ * gnt_tree_set_column_width_ratio * gnt_tree_set_column_resizable * gnt_tree_set_column_is_right_aligned + * gnt_tree_set_search_function, gnt_tree_set_search_column, + gnt_tree_is_searching * 'file-selected' signal is emited for GntFileSel * gnt_style_parse_bool * gnt_util_set_trigger_widget diff -r 5e1412f4e67a -r 212c2bec5c97 finch/libgnt/gnttree.c --- a/finch/libgnt/gnttree.c Tue Jul 17 11:09:03 2007 +0000 +++ b/finch/libgnt/gnttree.c Thu Jul 19 08:25:26 2007 +0000 @@ -55,6 +55,7 @@ GString *search; int search_timeout; int search_column; + gboolean (*search_func)(GntTree *tree, gpointer key, const char *current); GCompareFunc compare; int lastvisible; @@ -159,9 +160,12 @@ GntTree *t = row->tree; if (t->priv->search && t->priv->search->len > 0) { GntTreeCol *col = (col = g_list_nth_data(row->columns, t->priv->search_column)) ? col : row->columns->data; - char *one = g_utf8_casefold(col->text, -1); - char *two = g_utf8_casefold(t->priv->search->str, -1); - char *z = strstr(one, two); + char *one, *two, *z; + if (t->priv->search_func) + return t->priv->search_func(t, row->key, col->text); + one = g_utf8_casefold(col->text, -1); + two = g_utf8_casefold(t->priv->search->str, -1); + z = strstr(one, two); g_free(one); g_free(two); if (z == NULL) @@ -1803,3 +1807,9 @@ return (tree->priv->search != NULL); } +void gnt_tree_set_search_function(GntTree *tree, + gboolean (*func)(GntTree *tree, gpointer key, const char *current)) +{ + tree->priv->search_func = func; +} + diff -r 5e1412f4e67a -r 212c2bec5c97 finch/libgnt/gnttree.h --- a/finch/libgnt/gnttree.h Tue Jul 17 11:09:03 2007 +0000 +++ b/finch/libgnt/gnttree.h Thu Jul 19 08:25:26 2007 +0000 @@ -516,6 +516,15 @@ */ gboolean gnt_tree_is_searching(GntTree *tree); +/** + * Set a custom search function. + * + * @param tree The tree + * @param func The custom search function + */ +void gnt_tree_set_search_function(GntTree *tree, + gboolean (*func)(GntTree *tree, gpointer key, const char *current)); + G_END_DECLS #endif /* GNT_TREE_H */