comparison finch/libgnt/gnttree.c @ 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 212c2bec5c97
children 36257cac2b11
comparison
equal deleted inserted replaced
18561:4de7e6c4e5be 18563:dba4edbde4a7
53 struct _GntTreePriv 53 struct _GntTreePriv
54 { 54 {
55 GString *search; 55 GString *search;
56 int search_timeout; 56 int search_timeout;
57 int search_column; 57 int search_column;
58 gboolean (*search_func)(GntTree *tree, gpointer key, const char *current); 58 gboolean (*search_func)(GntTree *tree, gpointer key, const char *search, const char *current);
59 59
60 GCompareFunc compare; 60 GCompareFunc compare;
61 int lastvisible; 61 int lastvisible;
62 }; 62 };
63 63
160 GntTree *t = row->tree; 160 GntTree *t = row->tree;
161 if (t->priv->search && t->priv->search->len > 0) { 161 if (t->priv->search && t->priv->search->len > 0) {
162 GntTreeCol *col = (col = g_list_nth_data(row->columns, t->priv->search_column)) ? col : row->columns->data; 162 GntTreeCol *col = (col = g_list_nth_data(row->columns, t->priv->search_column)) ? col : row->columns->data;
163 char *one, *two, *z; 163 char *one, *two, *z;
164 if (t->priv->search_func) 164 if (t->priv->search_func)
165 return t->priv->search_func(t, row->key, col->text); 165 return t->priv->search_func(t, row->key, t->priv->search->str, col->text);
166 one = g_utf8_casefold(col->text, -1); 166 one = g_utf8_casefold(col->text, -1);
167 two = g_utf8_casefold(t->priv->search->str, -1); 167 two = g_utf8_casefold(t->priv->search->str, -1);
168 z = strstr(one, two); 168 z = strstr(one, two);
169 g_free(one); 169 g_free(one);
170 g_free(two); 170 g_free(two);
1806 { 1806 {
1807 return (tree->priv->search != NULL); 1807 return (tree->priv->search != NULL);
1808 } 1808 }
1809 1809
1810 void gnt_tree_set_search_function(GntTree *tree, 1810 void gnt_tree_set_search_function(GntTree *tree,
1811 gboolean (*func)(GntTree *tree, gpointer key, const char *current)) 1811 gboolean (*func)(GntTree *tree, gpointer key, const char *search, const char *current))
1812 { 1812 {
1813 tree->priv->search_func = func; 1813 tree->priv->search_func = func;
1814 } 1814 }
1815 1815