changeset 18563:dba4edbde4a7

Patch from Javeed Shaikh to make the search function non-braindamaged.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 19 Jul 2007 21:11:37 +0000
parents 4de7e6c4e5be
children 36257cac2b11
files COPYRIGHT finch/libgnt/gnttree.c finch/libgnt/gnttree.h
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Jul 19 08:25:57 2007 +0000
+++ b/COPYRIGHT	Thu Jul 19 21:11:37 2007 +0000
@@ -322,6 +322,7 @@
 Don Seiler
 Leonardo Serra
 Jim Seymour
+Javeed Shaikh
 Joe Shaw
 Scott Shedden
 Dossy Shiobara
--- a/finch/libgnt/gnttree.c	Thu Jul 19 08:25:57 2007 +0000
+++ b/finch/libgnt/gnttree.c	Thu Jul 19 21:11:37 2007 +0000
@@ -55,7 +55,7 @@
 	GString *search;
 	int search_timeout;
 	int search_column;
-	gboolean (*search_func)(GntTree *tree, gpointer key, const char *current);
+	gboolean (*search_func)(GntTree *tree, gpointer key, const char *search, const char *current);
 
 	GCompareFunc compare;
 	int lastvisible;
@@ -162,7 +162,7 @@
 		GntTreeCol *col = (col = g_list_nth_data(row->columns, t->priv->search_column)) ? col : row->columns->data;
 		char *one, *two, *z;
 		if (t->priv->search_func)
-			return t->priv->search_func(t, row->key, col->text);
+			return t->priv->search_func(t, row->key, t->priv->search->str, col->text);
 		one = g_utf8_casefold(col->text, -1);
 		two = g_utf8_casefold(t->priv->search->str, -1);
 		z = strstr(one, two);
@@ -1808,7 +1808,7 @@
 }
 
 void gnt_tree_set_search_function(GntTree *tree,
-		gboolean (*func)(GntTree *tree, gpointer key, const char *current))
+		gboolean (*func)(GntTree *tree, gpointer key, const char *search, const char *current))
 {
 	tree->priv->search_func = func;
 }
--- a/finch/libgnt/gnttree.h	Thu Jul 19 08:25:57 2007 +0000
+++ b/finch/libgnt/gnttree.h	Thu Jul 19 21:11:37 2007 +0000
@@ -520,10 +520,14 @@
  * Set a custom search function.
  *
  * @param tree  The tree
- * @param func  The custom search function
+ * @param func  The custom search function. The search function is
+ *              sent the tree itself, the key of a row, the search
+ *              string and the content of row in the search column.
+ *              If the function returns @c TRUE, the row is dislayed,
+ *              otherwise it's not.
  */
 void gnt_tree_set_search_function(GntTree *tree,
-		gboolean (*func)(GntTree *tree, gpointer key, const char *current));
+		gboolean (*func)(GntTree *tree, gpointer key, const char *search, const char *current));
 
 G_END_DECLS