Re: signals versus vfuncs



[I cc gtk-devel again, since this might be of public interest]

muppet schrieb:
a common question on gtk-perl-list in regards to tree models is related to trying to get good performance on huge database queries with DBI. most people want to load rows on demand, requiring that the model not always have all the data in it. it falls on me to provide the ability to implement these custom models, but i barely know how any of that works. so, i'm interested in how and what you did here -- could you explain a bit?

I refer to
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/*checkout*/manuproc/Komponenten/examples/owntreemodel.cc?rev=HEAD&content-type=text/plain
as an example:

Iterators usually contain pointers to internal data structures, Paths are just an ordinal representation of a (potential) node position. Prepare to accept zero'd iterators (I sometimes get some from GtkTreeView after changing between models).

In your from GObject and TreeModel derived type override the vfuncs:

get_flags_vfunc: do you have stable iterators (which do never change on addition/removal of other nodes)?
get_n_columns_vfunc: how many columns do you store?
get_value_vfunc: get value for a specific iterator+column

iter_next_vfunc: next node
iter_children_vfunc: down
iter_nth_child_vfunc: down and n times next
iter_parent_vfunc: up

get_path_vfunc: iter->path
get_iter_vfunc: path->iter

iter_has_child_vfunc: does it have children?
iter_n_children_vfunc: how many?

at least on C++: And remmeber to create a GObject instance for your object (a TreeModel is not an instance but an abstract interface).

If your model is about to change (not in my simplistic example) you should send the signals:

row_changed, row_inserted, row_has_child_toggled, row_deleted, rows_reordered

Feel free to ask further questions.
   Christof




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