Changeset 10253


Ignore:
Timestamp:
Feb 21, 2010, 11:56:01 PM (12 years ago)
Author:
charles
Message:

(trunk gtk) #2950 "In GTK+ client, Select-All + Stop sends a 'stopped' event even for already-stopped torrents" -- fixed in trunk for 1.91

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r10066 r10253  
    13731373
    13741374static void
    1375 startTorrentForeach( GtkTreeModel *      model,
    1376                      GtkTreePath  * path UNUSED,
    1377                      GtkTreeIter *       iter,
    1378                      gpointer       data UNUSED )
     1375appendIdToBencList( GtkTreeModel * m, GtkTreePath * path UNUSED,
     1376                    GtkTreeIter * iter, gpointer list )
    13791377{
    13801378    tr_torrent * tor = NULL;
    1381 
    1382     gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
    1383     tr_torrentStart( tor );
    1384 }
    1385 
    1386 static void
    1387 stopTorrentForeach( GtkTreeModel *      model,
    1388                     GtkTreePath  * path UNUSED,
    1389                     GtkTreeIter *       iter,
    1390                     gpointer       data UNUSED )
    1391 {
    1392     tr_torrent * tor = NULL;
    1393 
    1394     gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
    1395     tr_torrentStop( tor );
    1396 }
    1397 
    1398 static void
    1399 updateTrackerForeach( GtkTreeModel *      model,
    1400                       GtkTreePath  * path UNUSED,
    1401                       GtkTreeIter *       iter,
    1402                       gpointer       data UNUSED )
    1403 {
    1404     tr_torrent * tor = NULL;
    1405 
    1406     gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
    1407     tr_torrentManualUpdate( tor );
     1379    gtk_tree_model_get( m, iter, MC_TORRENT_RAW, &tor, -1 );
     1380    tr_bencListAddInt( list, tr_torrentId( tor ) );
     1381}
     1382
     1383static gboolean
     1384rpcOnSelectedTorrents( struct cbdata * data, const char * method )
     1385{
     1386    tr_benc top, *args, *ids;
     1387    gboolean invoked = FALSE;
     1388    tr_session * session = tr_core_session( data->core );
     1389    GtkTreeSelection * s = tr_window_get_selection( data->wind );
     1390
     1391    tr_bencInitDict( &top, 2 );
     1392    tr_bencDictAddStr( &top, "method", method );
     1393    args = tr_bencDictAddDict( &top, "arguments", 1 );
     1394    ids = tr_bencDictAddList( args, "ids", 0 );
     1395    gtk_tree_selection_selected_foreach( s, appendIdToBencList, ids );
     1396
     1397    if( tr_bencListSize( ids ) != 0 )
     1398    {
     1399        int json_len;
     1400        char * json = tr_bencToStr( &top, TR_FMT_JSON_LEAN, &json_len );
     1401        tr_rpc_request_exec_json( session, json, json_len, NULL, NULL );
     1402        g_free( json );
     1403        invoked = TRUE;
     1404    }
     1405
     1406    tr_bencFree( &top );
     1407    return invoked;
    14081408}
    14091409
     
    14181418    gtk_tree_model_get( model, iter, MC_TORRENT, &gtor, -1 );
    14191419    tr_torrent_open_folder( gtor );
    1420     g_object_unref( G_OBJECT( gtor ) );
    1421 }
    1422 
    1423 static void
    1424 recheckTorrentForeach( GtkTreeModel *      model,
    1425                        GtkTreePath  * path UNUSED,
    1426                        GtkTreeIter *       iter,
    1427                        gpointer       data UNUSED )
    1428 {
    1429     TrTorrent * gtor = NULL;
    1430 
    1431     gtk_tree_model_get( model, iter, MC_TORRENT, &gtor, -1 );
    1432     tr_torrentVerify( tr_torrent_handle( gtor ) );
    14331420    g_object_unref( G_OBJECT( gtor ) );
    14341421}
     
    15641551        gtr_open_file( "http://www.transmissionbt.com/donate.php" );
    15651552    }
    1566     else if( !strcmp( action_name, "start-torrent" ) )
    1567     {
    1568         GtkTreeSelection * s = tr_window_get_selection( data->wind );
    1569         gtk_tree_selection_selected_foreach( s, startTorrentForeach, NULL );
    1570         changed |= gtk_tree_selection_count_selected_rows( s ) != 0;
    1571     }
    15721553    else if( !strcmp( action_name, "pause-all-torrents" ) )
    15731554    {
     
    15961577        }
    15971578    }
     1579    else if( !strcmp( action_name, "start-torrent" ) )
     1580    {
     1581        changed |= rpcOnSelectedTorrents( data, "torrent-start" );
     1582    }
    15981583    else if( !strcmp( action_name, "pause-torrent" ) )
    15991584    {
    1600         GtkTreeSelection * s = tr_window_get_selection( data->wind );
    1601         gtk_tree_selection_selected_foreach( s, stopTorrentForeach, NULL );
    1602         changed |= gtk_tree_selection_count_selected_rows( s ) != 0;
     1585        changed |= rpcOnSelectedTorrents( data, "torrent-stop" );
    16031586    }
    16041587    else if( !strcmp( action_name, "verify-torrent" ) )
    16051588    {
    1606         GtkTreeSelection * s = tr_window_get_selection( data->wind );
    1607         gtk_tree_selection_selected_foreach( s, recheckTorrentForeach, NULL );
    1608         changed |= gtk_tree_selection_count_selected_rows( s ) != 0;
     1589        changed |= rpcOnSelectedTorrents( data, "torrent-verify" );
     1590    }
     1591    else if( !strcmp( action_name, "update-tracker" ) )
     1592    {
     1593        changed |= rpcOnSelectedTorrents( data, "torrent-reannounce" );
    16091594    }
    16101595    else if( !strcmp( action_name, "open-torrent-folder" ) )
     
    16311616        g_slist_free( ids );
    16321617    }
    1633     else if( !strcmp( action_name, "update-tracker" ) )
    1634     {
    1635         GtkTreeSelection * s = tr_window_get_selection( data->wind );
    1636         gtk_tree_selection_selected_foreach( s, updateTrackerForeach,
    1637                                              data->wind );
    1638     }
    16391618    else if( !strcmp( action_name, "new-torrent" ) )
    16401619    {
Note: See TracChangeset for help on using the changeset viewer.