I'm currently porting gnucash to the gtk2, using a couple of things from libegg. I ran into a few problems using the treemodelfilter code when I set a virtual root on the filter. In the order in which the fixes appear in the attached patch, they were: 1) A call to egg_tree_model_filter_add_root has the arguments backwards. Looks like the function calling sequence was updated and this call was missed. 2) egg_tree_model_filter_row_changed didn't check to see if the "changed" row was above the virtual root, and then printed a warning message because it couldn't find the node. 3) egg_tree_model_filter_row_changed needs to build all the tree levels if they don't exist. As is, it ends up printing a warning message for each node that isn't in an already built level. 4) egg_tree_model_filter_convert_iter_to_child_iter needs to pay attention to whether or not a virtual root is present. Otherwise it ends up getting a pointer to the wrong child iter. David
Index: libegg/treeviewutils/eggtreemodelfilter.c =================================================================== RCS file: /cvs/gnome/libegg/libegg/treeviewutils/eggtreemodelfilter.c,v retrieving revision 1.10 diff -u -r1.10 eggtreemodelfilter.c --- libegg/treeviewutils/eggtreemodelfilter.c 27 Jul 2003 13:29:55 -0000 1.10 +++ libegg/treeviewutils/eggtreemodelfilter.c 6 Sep 2003 19:31:36 -0000 @@ -547,9 +547,7 @@ if (root) { - real_path = gtk_tree_path_copy (root); - - egg_tree_model_filter_add_root (real_path, path); + real_path = egg_tree_model_filter_add_root (path, root); gtk_tree_path_free (path); return real_path; } @@ -982,6 +980,16 @@ else gtk_tree_model_get_iter (c_model, &real_c_iter, c_path); + /* is this node above the virtual root? */ + if (filter->virtual_root) + { + if (gtk_tree_path_get_depth (filter->virtual_root) >= + gtk_tree_path_get_depth (c_path)) + { + goto done; + } + } + /* what's the requested state? */ requested_state = egg_tree_model_filter_visible (filter, &real_c_iter); @@ -1059,7 +1067,7 @@ if (!path) path = egg_real_tree_model_filter_convert_child_path_to_path (filter, c_path, - FALSE, + TRUE, TRUE); g_return_if_fail (path != NULL); @@ -2469,7 +2477,7 @@ path = egg_tree_model_filter_elt_get_path (filter_iter->user_data, filter_iter->user_data2, - NULL); + filter->virtual_root); gtk_tree_model_get_iter (filter->child_model, child_iter, path); gtk_tree_path_free (path); }
Attachment:
signature.asc
Description: This is a digitally signed message part