Re: How to get Position of GtkTreeIter?



On Mon, 2003-08-18 at 22:12, Matthias Mann wrote:
            
        ***  How to get Position of GtkTreeIter?  ***
 
 Dear People! Need your suggestions/ideas for this situation:
 
 In one loop i added some GtkListIter to a Column:
 
      gtk_list_store_insert(listView->listStore,
                           &listView->listIter, position);
 
 Note: I always used the same iterator (address of listView->
 listIter can not be changed in my code).
 
 Later i have a callback ("changed") that takes action if a
 user of my app selected e.g. the 17'th entry in this list
 fiew that is position 16 (begin of count=0). But callback
 function don't know about this 17'th position. Now, how can i
 get this position?
 
 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]);

If you _really_ want to know the index of the row, take a look at
gtk_tree_path_get_indices() (i've never used that one).

Markus.





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