gtktree iterators



Hello.

I use GtkTreeIters to keep track of my objects in TreeModels.
Whenever an object changes it sets itself dirty and this triggers
callback functions (subject/observer mechanism). The gui observer
function updates the according entry in the TreeModel. Now i have the
following two situations (and suggestions for new function in gtk):

1) An object is removed from a tree node an is inserted into another. So
the callback function should do the following:

  if (!gtk_tree_iter_is_child(object->parent->ITER, object->ITER) {
    // remove and re-insert into model
  }

Unfortunately there is no gtk_tree_iter_is_child()/parent() so i have to
convert to GtkTreePaths first.
Also, a gtk_tree_iter_compare() function would be useful (in conjunction
with gtk_tree_model_iter_parent()

2) An object is remove from a TreeModel and inserted into another, the
callback function does to following:

  tree_model = object_preferres_to_be_in_model(object);
  if (!gtk_tree_iter_is_in_model(tree_model, object->ITER))
    // remove from current model and insert into preferred model
  }

Unfortunately there is no gtk_tree_iter_is_in_model(), so i use
  if (tree_model->stamp != object->ITER->stamp) { ... }

Markus.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]