Changeset 3587 for trunk/gtk/main.c


Ignore:
Timestamp:
Oct 26, 2007, 11:29:19 PM (15 years ago)
Author:
charles
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r3486 r3587  
    165165fatalsig(int sig);
    166166
     167struct counts_data
     168{
     169    int totalCount;
     170    int activeCount;
     171    int inactiveCount;
     172};
     173
    167174static void
    168175accumulateStatusForeach (GtkTreeModel * model,
    169176                         GtkTreePath  * path UNUSED,
    170177                         GtkTreeIter  * iter,
    171                          gpointer       accumulated_status)
     178                         gpointer       user_data )
    172179{
    173180    int status = 0;
     181    struct counts_data * counts = user_data;
     182
     183    ++counts->totalCount;
     184
    174185    gtk_tree_model_get( model, iter, MC_STAT, &status, -1 );
    175     *(int*)accumulated_status |= status;
     186    if( TR_STATUS_IS_ACTIVE( status ) )
     187        ++counts->activeCount;
     188    else
     189        ++counts->inactiveCount;
    176190}
    177191
     
    192206refreshTorrentActions( GtkTreeSelection * s )
    193207{
    194     int status = 0;
    195     gtk_tree_selection_selected_foreach( s, accumulateStatusForeach, &status );
    196     action_sensitize( "pause-torrent", TR_STATUS_IS_ACTIVE(status) );
    197     action_sensitize( "start-torrent", !TR_STATUS_IS_ACTIVE(status) );
    198     action_sensitize( "remove-torrent", status != 0);
    199     action_sensitize( "verify-torrent", status != 0);
    200     action_sensitize( "show-torrent-details", status != 0);
    201 
    202     status = 0;
    203     gtk_tree_selection_selected_foreach( s, accumulateCanUpdateForeach, &status );
    204     action_sensitize( "update-tracker", status != 0);
     208    int canUpdate;
     209    struct counts_data counts;
     210
     211    counts.activeCount = 0;
     212    counts.inactiveCount = 0;
     213    counts.totalCount = 0;
     214    gtk_tree_selection_selected_foreach( s, accumulateStatusForeach, &counts );
     215    action_sensitize( "pause-torrent", counts.activeCount!=0 );
     216    action_sensitize( "start-torrent", counts.inactiveCount!=0 );
     217    action_sensitize( "remove-torrent", counts.totalCount!=0 );
     218    action_sensitize( "verify-torrent", counts.totalCount!=0 );
     219    action_sensitize( "show-torrent-details", counts.totalCount!=0 );
     220
     221    canUpdate = 0;
     222    gtk_tree_selection_selected_foreach( s, accumulateCanUpdateForeach, &canUpdate );
     223    action_sensitize( "update-tracker", canUpdate!=0 );
    205224}
    206225
Note: See TracChangeset for help on using the changeset viewer.