RE: How to get Position of GtkTreeIter?



 I'm searchig for a function like "gtk_list_view_get_position()"
 in cooperation with gtk tree selection mode (value that we'll
 get by calling gtk_tree_view_get_selection(); ). Is anybody
 here who knows about such possibility?

If you want to know the index only to lookup your object in an array,
then i suggest to simply add an additional data field of to your
ListStore (just increase the first argument of 
gtk_list_store_new() and
add a G_TYPE_POINTER).
When adding new rows you also need to pass the pointer to your object:
gtk_list_store_set(model, &iter, [<some_fields>],
                   x, &your_array[position]);


The problem with using this, is that if the item position changes (say the
one above is removed) then all below it would need updating in the
store/model.  This is HIGHLY inefficient and if there is a lot of data in
the store/model, then you descrease the speed at which you can do operations
unnecessarily (note: you need a LOT of data for this to be the case).

Regards,
Martyn



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