mirror of
https://github.com/transmission/transmission
synced 2025-03-05 11:08:04 +00:00
have gtk+ use the batch form of setFilePriorities(). remove saveFastResumeSoon().
This commit is contained in:
parent
25fa56d294
commit
4acfe5e1b5
4 changed files with 56 additions and 61 deletions
|
@ -1210,25 +1210,40 @@ set_subtree_dnd( GtkTreeStore * store,
|
|||
}
|
||||
|
||||
static void
|
||||
set_priority (GtkTreeSelection * selection,
|
||||
GtkTreeStore * store,
|
||||
subtree_walk_priority( GtkTreeStore * store,
|
||||
GtkTreeIter * iter,
|
||||
tr_torrent * tor,
|
||||
int priority_val,
|
||||
const char * priority_str)
|
||||
int priority,
|
||||
GArray * indices )
|
||||
{
|
||||
int index;
|
||||
GtkTreeIter child;
|
||||
|
||||
/* update this node */
|
||||
gtk_tree_model_get( GTK_TREE_MODEL(store), iter, FC_INDEX, &index, -1 );
|
||||
if (index >= 0)
|
||||
tr_torrentSetFilePriority( tor, index, priority_val );
|
||||
gtk_tree_store_set( store, iter, FC_PRIORITY, priority_str, -1 );
|
||||
if( index >= 0 )
|
||||
g_array_append_val( indices, index );
|
||||
gtk_tree_store_set( store, iter, FC_PRIORITY, priorityToString(priority), -1 );
|
||||
|
||||
/* visit the children */
|
||||
if( gtk_tree_model_iter_children( GTK_TREE_MODEL(store), &child, iter ) ) do
|
||||
set_priority( selection, store, &child, tor, priority_val, priority_str );
|
||||
subtree_walk_priority( store, &child, tor, priority, indices );
|
||||
while( gtk_tree_model_iter_next( GTK_TREE_MODEL(store), &child ) );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
set_subtree_priority( GtkTreeStore * store,
|
||||
GtkTreeIter * iter,
|
||||
tr_torrent * tor,
|
||||
int priority,
|
||||
GtkTreeSelection * selection )
|
||||
{
|
||||
GArray * indices = g_array_new( FALSE, FALSE, sizeof(int) );
|
||||
subtree_walk_priority( store, iter, tor, priority, indices );
|
||||
tr_torrentSetFilePriorities( tor, (int*)indices->data, (int)indices->len, priority );
|
||||
g_array_free( indices, TRUE );
|
||||
|
||||
refreshPriorityActions( selection );
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1259,7 @@ priority_changed_cb (GtkCellRendererText * cell UNUSED,
|
|||
{
|
||||
tr_torrent * tor = tr_torrent_handle( d->gtor );
|
||||
const tr_priority_t priority = stringToPriority( value );
|
||||
set_priority( d->selection, d->store, &iter, tor, priority, value );
|
||||
set_subtree_priority( d->store, &iter, tor, priority, d->selection );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1274,14 +1289,13 @@ set_selected_file_priority ( tr_priority_t priority_val )
|
|||
{
|
||||
GtkTreeView * view = GTK_TREE_VIEW( popupView );
|
||||
tr_torrent * tor = g_object_get_data (G_OBJECT(view), "torrent-handle");
|
||||
const char * priority_str = priorityToString( priority_val );
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection * sel = gtk_tree_view_get_selection (view);
|
||||
gtk_tree_selection_get_selected( sel, &model, &iter );
|
||||
|
||||
set_priority( sel, GTK_TREE_STORE(model), &iter,
|
||||
tor, priority_val, priority_str );
|
||||
set_subtree_priority( GTK_TREE_STORE(model), &iter,
|
||||
tor, priority_val, sel );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,6 @@ struct tr_torrent
|
|||
struct tr_ratecontrol * download;
|
||||
struct tr_ratecontrol * swarmspeed;
|
||||
|
||||
struct tr_timer * saveTimer;
|
||||
|
||||
int error;
|
||||
char errorString[128];
|
||||
|
||||
|
|
|
@ -589,22 +589,10 @@ tr_torrentInfo( const tr_torrent * tor )
|
|||
****
|
||||
***/
|
||||
|
||||
static int
|
||||
saveFastResumeNow( void * vtor )
|
||||
{
|
||||
tr_torrent * tor = (tr_torrent *) vtor;
|
||||
tr_fastResumeSave( tor );
|
||||
tor->saveTimer = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
saveFastResumeSoon( void * vtor )
|
||||
saveFastResumeNow( tr_torrent * tor )
|
||||
{
|
||||
tr_torrent * tor = (tr_torrent *) vtor;
|
||||
|
||||
if( tor->saveTimer == NULL )
|
||||
tor->saveTimer = tr_timerNew( tor->handle, saveFastResumeNow, tor, 100 );
|
||||
tr_fastResumeSave( tor );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -616,7 +604,7 @@ tr_torrentSetFolder( tr_torrent * tor, const char * path )
|
|||
{
|
||||
tr_free( tor->destination );
|
||||
tor->destination = tr_strdup( path );
|
||||
saveFastResumeSoon( tor );
|
||||
saveFastResumeNow( tor );
|
||||
}
|
||||
|
||||
const char*
|
||||
|
@ -994,7 +982,7 @@ checkAndStartCB( tr_torrent * tor )
|
|||
*tor->errorString = '\0';
|
||||
tr_torrentResetTransferStats( tor );
|
||||
tor->cpStatus = tr_cpGetStatus( tor->completion );
|
||||
saveFastResumeSoon( tor );
|
||||
saveFastResumeNow( tor );
|
||||
tor->startDate = tr_date( );
|
||||
tr_trackerStart( tor->tracker );
|
||||
tr_peerMgrStartTorrent( tor->handle->peerMgr, tor->info.hash );
|
||||
|
@ -1119,7 +1107,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
|
|||
tr_trackerCompleted( tor->tracker ); /* tell the tracker */
|
||||
}
|
||||
tr_ioClose( tor );
|
||||
saveFastResumeSoon( tor );
|
||||
saveFastResumeNow( tor );
|
||||
}
|
||||
tr_torrentUnlock( tor );
|
||||
}
|
||||
|
@ -1134,16 +1122,14 @@ tr_torrentIsSeed( const tr_torrent * tor )
|
|||
*** File priorities
|
||||
**/
|
||||
|
||||
void
|
||||
tr_torrentSetFilePriority( tr_torrent * tor,
|
||||
static void
|
||||
setFilePriority( tr_torrent * tor,
|
||||
int fileIndex,
|
||||
tr_priority_t priority )
|
||||
{
|
||||
int i;
|
||||
tr_file * file;
|
||||
|
||||
tr_torrentLock( tor );
|
||||
|
||||
assert( tor != NULL );
|
||||
assert( 0<=fileIndex && fileIndex<tor->info.fileCount );
|
||||
assert( priority==TR_PRI_LOW || priority==TR_PRI_NORMAL || priority==TR_PRI_HIGH );
|
||||
|
@ -1156,10 +1142,6 @@ tr_torrentSetFilePriority( tr_torrent * tor,
|
|||
tr_dbg ( "Setting file #%d (pieces %d-%d) priority to %d (%s)",
|
||||
fileIndex, file->firstPiece, file->lastPiece,
|
||||
priority, tor->info.files[fileIndex].name );
|
||||
|
||||
saveFastResumeSoon( tor );
|
||||
|
||||
tr_torrentUnlock( tor );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1169,8 +1151,13 @@ tr_torrentSetFilePriorities( tr_torrent * tor,
|
|||
tr_priority_t priority )
|
||||
{
|
||||
int i;
|
||||
tr_torrentLock( tor );
|
||||
|
||||
for( i=0; i<fileCount; ++i )
|
||||
tr_torrentSetFilePriority( tor, files[i], priority );
|
||||
setFilePriority( tor, files[i], priority );
|
||||
|
||||
saveFastResumeNow( tor );
|
||||
tr_torrentUnlock( tor );
|
||||
}
|
||||
|
||||
tr_priority_t
|
||||
|
|
|
@ -260,17 +260,13 @@ enum
|
|||
|
||||
typedef int8_t tr_priority_t;
|
||||
|
||||
/* set a batch of files to a particular priority. */
|
||||
/* set a batch of files to a particular priority.
|
||||
* priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
|
||||
void tr_torrentSetFilePriorities( tr_torrent * tor,
|
||||
int * files,
|
||||
int fileCount,
|
||||
tr_priority_t priority );
|
||||
|
||||
|
||||
/* single-file form of tr_torrentPrioritizeFiles.
|
||||
* priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
|
||||
void tr_torrentSetFilePriority( tr_torrent *, int file, tr_priority_t priority );
|
||||
|
||||
/* returns a malloc()ed array of tor->info.fileCount items,
|
||||
* each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
|
||||
free the array when done. */
|
||||
|
|
Loading…
Add table
Reference in a new issue