1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(gtk) if two torrents are selected -- one running, one paused -- both "pause" and "resume" buttons should be enabled. reported by glyphobet.

This commit is contained in:
Charles Kerr 2007-10-26 23:29:19 +00:00
parent f909b97e20
commit 747cd0b396
2 changed files with 31 additions and 13 deletions

View file

@ -164,15 +164,29 @@ setupsighandlers(void);
static void static void
fatalsig(int sig); fatalsig(int sig);
struct counts_data
{
int totalCount;
int activeCount;
int inactiveCount;
};
static void static void
accumulateStatusForeach (GtkTreeModel * model, accumulateStatusForeach (GtkTreeModel * model,
GtkTreePath * path UNUSED, GtkTreePath * path UNUSED,
GtkTreeIter * iter, GtkTreeIter * iter,
gpointer accumulated_status) gpointer user_data )
{ {
int status = 0; int status = 0;
struct counts_data * counts = user_data;
++counts->totalCount;
gtk_tree_model_get( model, iter, MC_STAT, &status, -1 ); gtk_tree_model_get( model, iter, MC_STAT, &status, -1 );
*(int*)accumulated_status |= status; if( TR_STATUS_IS_ACTIVE( status ) )
++counts->activeCount;
else
++counts->inactiveCount;
} }
static void static void
@ -191,17 +205,22 @@ accumulateCanUpdateForeach (GtkTreeModel * model,
static void static void
refreshTorrentActions( GtkTreeSelection * s ) refreshTorrentActions( GtkTreeSelection * s )
{ {
int status = 0; int canUpdate;
gtk_tree_selection_selected_foreach( s, accumulateStatusForeach, &status ); struct counts_data counts;
action_sensitize( "pause-torrent", TR_STATUS_IS_ACTIVE(status) );
action_sensitize( "start-torrent", !TR_STATUS_IS_ACTIVE(status) );
action_sensitize( "remove-torrent", status != 0);
action_sensitize( "verify-torrent", status != 0);
action_sensitize( "show-torrent-details", status != 0);
status = 0; counts.activeCount = 0;
gtk_tree_selection_selected_foreach( s, accumulateCanUpdateForeach, &status ); counts.inactiveCount = 0;
action_sensitize( "update-tracker", status != 0); counts.totalCount = 0;
gtk_tree_selection_selected_foreach( s, accumulateStatusForeach, &counts );
action_sensitize( "pause-torrent", counts.activeCount!=0 );
action_sensitize( "start-torrent", counts.inactiveCount!=0 );
action_sensitize( "remove-torrent", counts.totalCount!=0 );
action_sensitize( "verify-torrent", counts.totalCount!=0 );
action_sensitize( "show-torrent-details", counts.totalCount!=0 );
canUpdate = 0;
gtk_tree_selection_selected_foreach( s, accumulateCanUpdateForeach, &canUpdate );
action_sensitize( "update-tracker", canUpdate!=0 );
} }
static void static void

View file

@ -322,7 +322,6 @@ tr_close( tr_handle * h )
tr_lockFree( h->lock ); tr_lockFree( h->lock );
free( h->tag ); free( h->tag );
free( h ); free( h );
fprintf( stderr, "libtransmission closed cleanly.\n" );
} }
tr_torrent ** tr_torrent **