Removing selected items from a list



I want to remove all the items in a list that the user has highlighted
After discovering that I'm not allowed to use gtk_tree_selection_selected_foreach I am trying it like this

GList* seln=gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(view),&model);
do
{
        GtkTreeIter iter;
        gtk_tree_model_get_iter(model,&iter,(GtkTreePath*)seln->data);
        gtk_list_store_remove(store,&iter);
}
while(seln=seln->next);

The effect of this seems to be to remove only alternate items in continuous selections and do something complicated when the selection is not continuous.

It looks like the GtkTreePaths that gtk_tree_selection_get_selected_rows returns aren't happy about the TreeStore being edited under them. What is the correct way to do this?

Probably relevant to this: why are there paths,iters and references? wouldn't one have done? I guess there are important differences in their behaviour and intended usage that the docs don't make clear.



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