GtkTreeIter comparison



Hi,

in order to wrap GtkTreeIter as C++ STL-like iterator in gtkmm, we have
to be able to compare Gtk::TreeIters for equality.  Unfortunately, GTK+
doesn't provide an API to do this.

Currently, we solved the problem by comparing the
user_data/user_data2/user_data3 pointers in struct GtkTreeIter.  This is
obviously a hack and means relying on GTK+ internals.  Unfortunately, it
breaks because GtkListStore and GtkTreeStore don't zero-initialize the
unused user_data[23] pointers.

We definitely need a solution to this problem.
I see two possible ways to go:

1) Adding a GtkTreeModel::iter_equal vfunc.  One for GTK+-2.2.

2) Declare in the API docs, that when implementing a custom
GtkTreeModel, the GtkTreeIter must be comparable by testing the pointers
for equality.  Also, define a policy that unused GtkTreeIter fields
always have to be zero-initialized, and fix GTK+ to do so.  (I would
provide a patch.)

I'd prefer 1), either in combination with 2) for GTK+-2.0, or with the
promise that GtkTreeStore and GtkListStore will never use user_data2 and
user_data3.

Comments?

--Daniel




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