0

I am trying to implement own TreeModel for use in TreeView.

I have subclassed Gtk::TreeModel and currently trying to override virtual methods with my own implementation.

But i have a problem with very basics of it. Say, we have

virtual bool iter_next_vfunc(const iterator &iter, iterator &iter_next) const;

function where i am supposed to read iter variable, somehow understand where it points to and based on this, fill iter_next with point next to the current.

But i do not understand how to do this.

What is 'index', 'pointer' or whatever based on what i could understand where iter is pointing to?

gpoo
  • 8,408
  • 3
  • 38
  • 53
Alexander Tumin
  • 1,561
  • 4
  • 22
  • 33
  • Hmm, how about you just get the plain C GtkTreeIter from the "gobj()" function, and then treat it as that? In C, GtkTreeIter has one "stamp" member (which is to identify which TreeModel it belongs to) and three general purpose gpointers to be used by the implementor (ie. you). See [C docs](http://developer.gnome.org/gtk/2.24/GtkTreeModel.html#GtkTreeIter-struct) – Ancurio Oct 17 '12 at 04:16
  • Could be the quick'n'dirty way, yes, thank you. But in general it is not very cool; not the best way to solve things. – Alexander Tumin Oct 17 '12 at 06:46
  • So you're saying you're positive this is definitely not the way to go? – Ancurio Oct 17 '12 at 06:47
  • Well, it could be the way if there is no high-level options, using only gtkmm tools and not involdving direct gobj* poking, but otherwise it is no go. – Alexander Tumin Oct 17 '12 at 06:55
  • Hmm, if it was a real GObject you were manipulating here, I would agree. But it's just a plain C struct, so.. – Ancurio Oct 17 '12 at 06:57
  • You were right, Ancurio. Apparently there is no higher level abstraction for this as far as i researched. Despite how unfortunate this is, it is the answer. Please, create one so i can accept it. – Alexander Tumin Oct 17 '12 at 09:29
  • Well, what were you expecting, accessor functions for every struct member? =P – Ancurio Oct 18 '12 at 15:45

1 Answers1

1

Directly access the underlying GtkTreeIter struct through gobj(), and fill it with the relevant data ('stamp' should be the same across all iters of the same model). (Reference)

Ancurio
  • 1,698
  • 1
  • 17
  • 32