Changeset 3470


Ignore:
Timestamp:
Oct 19, 2007, 11:44:01 PM (14 years ago)
Author:
charles
Message:

have gtk+ use the batch form of setFilePriorities(). remove saveFastResumeSoon().

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-inspector.c

    r3469 r3470  
    11991199
    12001200static void
    1201 set_subtree_dnd( GtkTreeStore * store,
    1202                  GtkTreeIter * iter,
    1203                  tr_torrent  * tor,
    1204                  gboolean enabled )
     1201set_subtree_dnd( GtkTreeStore   * store,
     1202                 GtkTreeIter    * iter,
     1203                 tr_torrent     * tor,
     1204                 gboolean         enabled )
    12051205{
    12061206    GArray * indices = g_array_new( FALSE, FALSE, sizeof(int) );
     
    12111211
    12121212static void
    1213 set_priority (GtkTreeSelection * selection,
    1214               GtkTreeStore * store,
    1215               GtkTreeIter * iter,
    1216               tr_torrent * tor,
    1217               int priority_val,
    1218               const char * priority_str)
     1213subtree_walk_priority( GtkTreeStore   * store,
     1214                       GtkTreeIter    * iter,
     1215                       tr_torrent     * tor,
     1216                       int              priority,
     1217                       GArray         * indices )
    12191218{
    12201219    int index;
    12211220    GtkTreeIter child;
    12221221
     1222    /* update this node */
    12231223    gtk_tree_model_get( GTK_TREE_MODEL(store), iter, FC_INDEX, &index, -1  );
    1224     if (index >= 0)
    1225       tr_torrentSetFilePriority( tor, index, priority_val );
    1226     gtk_tree_store_set( store, iter, FC_PRIORITY, priority_str, -1 );
    1227 
     1224    if( index >= 0 )
     1225        g_array_append_val( indices, index );
     1226    gtk_tree_store_set( store, iter, FC_PRIORITY, priorityToString(priority), -1 );
     1227
     1228    /* visit the children */
    12281229    if( gtk_tree_model_iter_children( GTK_TREE_MODEL(store), &child, iter ) ) do
    1229       set_priority( selection, store, &child, tor, priority_val, priority_str );
     1230        subtree_walk_priority( store, &child, tor, priority, indices );
    12301231    while( gtk_tree_model_iter_next( GTK_TREE_MODEL(store), &child ) );
     1232
     1233}
     1234
     1235static void
     1236set_subtree_priority( GtkTreeStore * store,
     1237                      GtkTreeIter * iter,
     1238                      tr_torrent * tor,
     1239                      int priority,
     1240                      GtkTreeSelection * selection )
     1241{
     1242    GArray * indices = g_array_new( FALSE, FALSE, sizeof(int) );
     1243    subtree_walk_priority( store, iter, tor, priority, indices );
     1244    tr_torrentSetFilePriorities( tor, (int*)indices->data, (int)indices->len, priority );
     1245    g_array_free( indices, TRUE );
    12311246
    12321247    refreshPriorityActions( selection );
     
    12391254                     void                * file_data)
    12401255{
    1241   GtkTreeIter iter;
    1242   FileData * d = (FileData*) file_data;
    1243   if (gtk_tree_model_get_iter_from_string (d->model, &iter, path))
    1244   {
    1245     tr_torrent  * tor = tr_torrent_handle( d->gtor );
    1246     const tr_priority_t priority = stringToPriority( value );
    1247     set_priority( d->selection, d->store, &iter, tor, priority, value );
    1248   }
     1256    GtkTreeIter iter;
     1257    FileData * d = (FileData*) file_data;
     1258    if (gtk_tree_model_get_iter_from_string (d->model, &iter, path))
     1259    {
     1260        tr_torrent  * tor = tr_torrent_handle( d->gtor );
     1261        const tr_priority_t priority = stringToPriority( value );
     1262        set_subtree_priority( d->store, &iter, tor, priority, d->selection );
     1263    }
    12491264}
    12501265
     
    12751290        GtkTreeView * view = GTK_TREE_VIEW( popupView );
    12761291        tr_torrent * tor = g_object_get_data (G_OBJECT(view), "torrent-handle");
    1277         const char * priority_str = priorityToString( priority_val );
    12781292        GtkTreeModel * model;
    12791293        GtkTreeIter iter;
     
    12811295        gtk_tree_selection_get_selected( sel, &model, &iter );
    12821296
    1283         set_priority( sel, GTK_TREE_STORE(model), &iter,
    1284                       tor, priority_val, priority_str );
     1297        set_subtree_priority( GTK_TREE_STORE(model), &iter,
     1298                              tor, priority_val, sel );
    12851299    }
    12861300}
  • trunk/libtransmission/internal.h

    r3469 r3470  
    114114    struct tr_ratecontrol     * swarmspeed;
    115115
    116     struct tr_timer           * saveTimer;
    117 
    118116    int                        error;
    119117    char                       errorString[128];
  • trunk/libtransmission/torrent.c

    r3469 r3470  
    590590***/
    591591
    592 static int
    593 saveFastResumeNow( void * vtor )
    594 {
    595     tr_torrent * tor = (tr_torrent *) vtor;
     592static void
     593saveFastResumeNow( tr_torrent * tor )
     594{
    596595    tr_fastResumeSave( tor );
    597     tor->saveTimer = NULL;
    598     return FALSE;
    599 }
    600 
    601 static void
    602 saveFastResumeSoon( void * vtor )
    603 {
    604     tr_torrent * tor = (tr_torrent *) vtor;
    605 
    606     if( tor->saveTimer == NULL )
    607         tor->saveTimer = tr_timerNew( tor->handle, saveFastResumeNow, tor, 100 );
    608596}
    609597
     
    617605    tr_free( tor->destination );
    618606    tor->destination = tr_strdup( path );
    619     saveFastResumeSoon( tor );
     607    saveFastResumeNow( tor );
    620608}
    621609
     
    995983    tr_torrentResetTransferStats( tor );
    996984    tor->cpStatus = tr_cpGetStatus( tor->completion );
    997     saveFastResumeSoon( tor );
     985    saveFastResumeNow( tor );
    998986    tor->startDate = tr_date( );
    999987    tr_trackerStart( tor->tracker );
     
    11201108        }
    11211109        tr_ioClose( tor );
    1122         saveFastResumeSoon( tor );
     1110        saveFastResumeNow( tor );
    11231111    }
    11241112    tr_torrentUnlock( tor );
     
    11351123**/
    11361124
    1137 void
    1138 tr_torrentSetFilePriority( tr_torrent   * tor,
    1139                            int            fileIndex,
    1140                            tr_priority_t  priority )
     1125static void
     1126setFilePriority( tr_torrent   * tor,
     1127                 int            fileIndex,
     1128                 tr_priority_t  priority )
    11411129{
    11421130    int i;
    11431131    tr_file * file;
    1144 
    1145     tr_torrentLock( tor );
    11461132
    11471133    assert( tor != NULL );
     
    11571143             fileIndex, file->firstPiece, file->lastPiece,
    11581144             priority, tor->info.files[fileIndex].name );
    1159 
    1160     saveFastResumeSoon( tor );
    1161 
    1162     tr_torrentUnlock( tor );
    11631145}
    11641146
     
    11701152{
    11711153    int i;
     1154    tr_torrentLock( tor );
     1155
    11721156    for( i=0; i<fileCount; ++i )
    1173         tr_torrentSetFilePriority( tor, files[i], priority );
     1157        setFilePriority( tor, files[i], priority );
     1158
     1159    saveFastResumeNow( tor );
     1160    tr_torrentUnlock( tor );
    11741161}
    11751162
  • trunk/libtransmission/transmission.h

    r3469 r3470  
    261261typedef int8_t tr_priority_t;
    262262
    263 /* set a batch of files to a particular priority. */
     263/* set a batch of files to a particular priority.
     264 * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
    264265void tr_torrentSetFilePriorities( tr_torrent        * tor,
    265266                                  int               * files,
    266267                                  int                 fileCount,
    267268                                  tr_priority_t       priority );
    268 
    269 
    270 /* single-file form of tr_torrentPrioritizeFiles.
    271  * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
    272 void tr_torrentSetFilePriority( tr_torrent *, int file, tr_priority_t priority );
    273269
    274270/* returns a malloc()ed array of tor->info.fileCount items,
Note: See TracChangeset for help on using the changeset viewer.