diff finch/libgnt/gnttree.c @ 18557:212c2bec5c97

Allow using custom search functions.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 19 Jul 2007 08:25:26 +0000
parents 5e1412f4e67a
children dba4edbde4a7
line wrap: on
line diff
--- 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;
+}
+