aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-02-01 04:23:00 +0800
committerChris Lahey <clahey@src.gnome.org>2002-02-01 04:23:00 +0800
commita3bd2634b10cbeaa0dd82cdb37c9007476977050 (patch)
tree5a55e4d3945578c19e5483c9aa9c4cd8a9491d83 /widgets/table
parent81762a26a3409b65c1d7a45e024eaba88242f103 (diff)
downloadgsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.gz
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.bz2
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.lz
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.xz
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.tar.zst
gsoc2013-evolution-a3bd2634b10cbeaa0dd82cdb37c9007476977050.zip
Made this function much more readable. Got rid of all the gotos. Fixed a
2002-01-31 Christopher James Lahey <clahey@ximian.com> * e-tree-model.c (e_tree_model_node_find): Made this function much more readable. Got rid of all the gotos. Fixed a case where going backwards during a root search checked the root node first. (e_tree_model_node_real_traverse): Made backwards traversals be postorder, as they should be, instead of preorder. * e-tree.c (find_next_callback): Use an extra callback function here to go from sorted path to model path. svn path=/trunk/; revision=15543
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-tree-model.c65
-rw-r--r--widgets/table/e-tree.c26
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);