diff options
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-tree-model.c | 65 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 26 |
2 files changed, 54 insertions, 37 deletions
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c index d90088624f..ed15f28f8c 100644 --- a/widgets/table/e-tree-model.c +++ b/widgets/table/e-tree-model.c @@ -967,21 +967,21 @@ e_tree_model_node_real_traverse (ETreeModel *model, ETreePath path, ETreePath en child = e_tree_model_node_get_last_child (model, path); while (child) { - ETreePath next_child; ETreePath result; - if (child == end_path || func (model, child, data)) + if (forward_direction && (child == end_path || func (model, child, data))) return child; - if (forward_direction) - next_child = e_tree_model_node_get_next (model, child); - else - next_child = e_tree_model_node_get_prev (model, child); - if ((result = e_tree_model_node_real_traverse (model, child, end_path, forward_direction, func, data))) return result; - child = next_child; + if (!forward_direction && (child == end_path || func (model, child, data))) + return child; + + if (forward_direction) + child = e_tree_model_node_get_next (model, child); + else + child = e_tree_model_node_get_prev (model, child); } return NULL; } @@ -1021,39 +1021,34 @@ e_tree_model_node_find (ETreeModel *model, ETreePath path, ETreePath end_path, g return NULL; } - start: - - if (forward_direction) { - if ((result = e_tree_model_node_real_traverse (model, path, end_path, forward_direction, func, data))) - return result; - next = e_tree_model_node_get_next (model, path); - } else { - next = e_tree_model_node_get_prev (model, path); - if (next && (result = e_tree_model_node_real_traverse (model, next, end_path, forward_direction, func, data))) - return result; - } + while (1) { - if (next) { - if (end_path == next || func (model, next, data)) - return next; + if (forward_direction) { + if ((result = e_tree_model_node_real_traverse (model, path, end_path, forward_direction, func, data))) + return result; + next = e_tree_model_node_get_next (model, path); + } else { + next = e_tree_model_node_get_prev (model, path); + if (next && (result = e_tree_model_node_real_traverse (model, next, end_path, forward_direction, func, data))) + return result; + } - /* return e_tree_model_node_find (model, next, end_path, forward_direction, func, data) */ - path = next; - goto start; - } + while (next == NULL) { + path = e_tree_model_node_get_parent (model, path); - path = e_tree_model_node_get_parent (model, path); + if (path == NULL) + return NULL; - if (path && forward_direction) - path = e_tree_model_node_get_next (model, path); + if (forward_direction) + next = e_tree_model_node_get_next (model, path); + else + next = path; + } - if (path) { - if (end_path == path || func (model, path, data)) - return path; + if (end_path == next || func (model, next, data)) + return next; - /* return e_tree_model_node_find (model, path, end_path, forward_direction, func, data) */ - goto start; + path = next; } - return NULL; } diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 26a6751b75..0796e1bb25 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -1737,16 +1737,38 @@ 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) +{ + FindNextCallback *cb_data = data; + ETree *et = cb_data->et; + + path = e_tree_sorted_view_to_model_path(et->priv->sorted, path); + + return cb_data->func (et->priv->model, path, cb_data->data); +} + 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; cursor = e_tree_get_cursor (et); cursor = e_tree_sorted_model_to_view_path (et->priv->sorted, cursor); - found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), cursor, NULL, params & E_TREE_FIND_NEXT_FORWARD, func, data); + found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), cursor, NULL, params & E_TREE_FIND_NEXT_FORWARD, find_next_callback, &cb_data); if (found) { e_tree_table_adapter_show_node (et->priv->etta, found); @@ -1756,7 +1778,7 @@ e_tree_find_next (ETree *et, ETreeFindNextParams params, ETreePathFunc func, gpo } if (params & E_TREE_FIND_NEXT_WRAP) { - found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), NULL, cursor, params & E_TREE_FIND_NEXT_FORWARD, func, data); + found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), NULL, cursor, params & E_TREE_FIND_NEXT_FORWARD, find_next_callback, &cb_data); if (found && found != cursor) { e_tree_table_adapter_show_node (et->priv->etta, found); |