diff options
author | Mike Kestner <mkestner@ximian.com> | 2003-02-11 02:04:25 +0800 |
---|---|---|
committer | Mike Kestner <mkestner@src.gnome.org> | 2003-02-11 02:04:25 +0800 |
commit | 33841eb730d8a62aee6793dd54e624281bf58142 (patch) | |
tree | 3f37e50b84a1c24deb59401c1e0f01382f26ea17 /widgets/table/e-tree.c | |
parent | 24d00dba858a3a5c87092a3ac6c837c456cf4ca8 (diff) | |
download | gsoc2013-evolution-33841eb730d8a62aee6793dd54e624281bf58142.tar.gz gsoc2013-evolution-33841eb730d8a62aee6793dd54e624281bf58142.tar.zst gsoc2013-evolution-33841eb730d8a62aee6793dd54e624281bf58142.zip |
rewrite to use etta (find_next_in_range): helper func to search a range of
2003-02-10 Mike Kestner <mkestner@ximian.com>
* e-tree.c (e_tree_find_next): rewrite to use etta
(find_next_in_range): helper func to search a range of rows
(find_next_callback): kill
svn path=/trunk/; revision=19875
Diffstat (limited to 'widgets/table/e-tree.c')
-rw-r--r-- | widgets/table/e-tree.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 06effbf90a..318564e42b 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -2033,50 +2033,47 @@ e_tree_get_tooltip (ETree *et) return E_CANVAS(et->priv->table_canvas)->tooltip_window; } -typedef struct { - ETreePathFunc func; - gpointer data; - ETree *et; -} FindNextCallback; - -static gboolean -find_next_callback (ETreeModel *model, ETreePath path, gpointer data) +static ETreePath +find_next_in_range (ETree *et, gint start, gint end, ETreePathFunc func, gpointer data) { - FindNextCallback *cb_data = data; - ETree *et = cb_data->et; + ETreePath path; + gint row; + + for (row = start; row <= end; row++) { + path = e_tree_table_adapter_node_at_row (et->priv->etta, row); + if (func (et->priv->model, path, data)) + return path; + } - return cb_data->func (et->priv->model, path, cb_data->data); + return NULL; } gboolean e_tree_find_next (ETree *et, ETreeFindNextParams params, ETreePathFunc func, gpointer data) { - ETreePath cursor; - ETreePath found; - FindNextCallback cb_data; - - cb_data.func = func; - cb_data.data = data; - cb_data.et = et; + ETreePath cursor, found; + gint row, row_count; cursor = e_tree_get_cursor (et); + row = e_tree_table_adapter_row_of_node (et->priv->etta, cursor); + row_count = e_table_model_row_count (E_TABLE_MODEL (et->priv->etta)); + if (row == -1) + row = 0; - found = e_tree_model_node_find (et->priv->model, cursor, NULL, params & E_TREE_FIND_NEXT_FORWARD, find_next_callback, &cb_data); + found = find_next_in_range (et, row + 1, row_count - 1, func, data); if (found) { e_tree_table_adapter_show_node (et->priv->etta, found); - cursor = found; - e_tree_set_cursor (et, cursor); + e_tree_set_cursor (et, found); return TRUE; } - if (params & E_TREE_FIND_NEXT_WRAP) { - found = e_tree_model_node_find (et->priv->model, NULL, cursor, params & E_TREE_FIND_NEXT_FORWARD, find_next_callback, &cb_data); + if ((params & E_TREE_FIND_NEXT_WRAP) && (row > 0)) { + found = find_next_in_range (et, 0, row, func, data); if (found && found != cursor) { e_tree_table_adapter_show_node (et->priv->etta, found); - cursor = found; - e_tree_set_cursor (et, cursor); + e_tree_set_cursor (et, found); return TRUE; } } |