Re: how to tell if to GtkTreeIter's point to the same row, or not?



Gregory Hosler wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have an application, where, to facilitate looks deep inside callbacks, I store the Iter
of a row as and when I gtk_list_store_append() it. This allows me to gtk_list_store_set()
using the saved iter, and it works quite well.

Now, I have a case, where I want to popup a popup-menu when the user clicks on a row.
So I attached a "button-press-event" to the gtk_tree_view. In my callback I do a
gtk_tree_view_get_path_at_pos(), and then I map the path to a row/iter using
gtk_tree_model_get_iter(). This appears to work fine, except that the iter I get returned
is not identical to the iter that was earlier saved when row was first
gtk_list_store_append()'ed (the stamp, and user_data are the same, the other fields differ).

I am using the saved iter to locate a private data structure relating to the row.

I suppose that I could g_object_set_data() a pointer to my private data structure insize
the iter, but that seems otherwise unnecessary. (My list private data structures have the
saved iter in them, so was just comparing the saved iter against the one from the
model_get_iter() returned iter.)

Is there a way to compare iter's, or am i better to store a g_object_set_data() inside the
iter to point to my private data structure ?

You cannot compare iter's directly (they're temporary anyway), but you can convert iter's to GtkTreePath's and compare them with gtk_tree_path_compare(). (Or something similar.)

--
Inspired by a true story.

Eduardo M KALINOWSKI
ekalin gmail com
http://move.to/hpkb




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