(gtk) fix bug when removing torrents from a filtered view

This commit is contained in:
Charles Kerr 2007-12-28 00:52:54 +00:00
parent 83e2b3d547
commit e781dfb03d
1 changed files with 14 additions and 10 deletions

View File

@ -393,7 +393,6 @@ winsetup( struct cbdata * cbdata, TrWindow * wind )
g_signal_connect( sel, "changed", G_CALLBACK(selectionChangedCB), NULL ); g_signal_connect( sel, "changed", G_CALLBACK(selectionChangedCB), NULL );
selectionChangedCB( sel, NULL ); selectionChangedCB( sel, NULL );
model = tr_core_model( cbdata->core ); model = tr_core_model( cbdata->core );
//gtk_tree_view_set_model ( gtk_tree_selection_get_tree_view(sel), model );
g_signal_connect( model, "row-changed", G_CALLBACK(rowChangedCB), sel ); g_signal_connect( model, "row-changed", G_CALLBACK(rowChangedCB), sel );
g_signal_connect( wind, "delete-event", G_CALLBACK( winclose ), cbdata ); g_signal_connect( wind, "delete-event", G_CALLBACK( winclose ), cbdata );
refreshTorrentActions( sel ); refreshTorrentActions( sel );
@ -752,16 +751,21 @@ getselection( struct cbdata * cbdata )
if( NULL != cbdata->wind ) if( NULL != cbdata->wind )
{ {
GList * ii; GList * l;
GtkTreeSelection *s = tr_window_get_selection(cbdata->wind); GtkTreeSelection *s = tr_window_get_selection(cbdata->wind);
GtkTreeModel * model = tr_core_model( cbdata->core ); GtkTreeModel * filter_model;
rows = gtk_tree_selection_get_selected_rows( s, NULL ); GtkTreeModel * store_model;
for( ii = rows; NULL != ii; ii = ii->next ) rows = gtk_tree_selection_get_selected_rows( s, &filter_model );
store_model = gtk_tree_model_filter_get_model(
GTK_TREE_MODEL_FILTER( filter_model ) );
for( l=rows; l!=NULL; l=l->next )
{ {
GtkTreeRowReference * ref = gtk_tree_row_reference_new( GtkTreePath * path = gtk_tree_model_filter_convert_path_to_child_path(
model, ii->data ); GTK_TREE_MODEL_FILTER( filter_model ), l->data );
gtk_tree_path_free( ii->data ); GtkTreeRowReference * ref = gtk_tree_row_reference_new( store_model, path );
ii->data = ref; gtk_tree_path_free( path );
gtk_tree_path_free( l->data );
l->data = ref;
} }
} }
@ -922,7 +926,7 @@ doAction ( const char * action_name, gpointer user_data )
for( l=sel; l!=NULL; l=l->next ) for( l=sel; l!=NULL; l=l->next )
{ {
GtkTreeIter iter; GtkTreeIter iter;
GtkTreeRowReference * reference = (GtkTreeRowReference *) l->data; GtkTreeRowReference * reference = l->data;
GtkTreePath * path = gtk_tree_row_reference_get_path( reference ); GtkTreePath * path = gtk_tree_row_reference_get_path( reference );
gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_model_get_iter( model, &iter, path );
tr_core_delete_torrent( data->core, &iter ); tr_core_delete_torrent( data->core, &iter );