Changeset 10456


Ignore:
Timestamp:
Apr 6, 2010, 4:02:44 AM (12 years ago)
Author:
charles
Message:

(trunk gtk) tweak paused/stopped/finished in the details dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r10390 r10456  
    532532****/
    533533
    534 static const char * activityString( int activity )
     534static const char *
     535activityString( int activity, tr_bool finished )
    535536{
    536537    switch( activity )
    537538    {
    538         case TR_STATUS_CHECK_WAIT: return _( "Waiting to verify local data" ); break;
    539         case TR_STATUS_CHECK:      return _( "Verifying local data" ); break;
    540         case TR_STATUS_DOWNLOAD:   return _( "Downloading" ); break;
    541         case TR_STATUS_SEED:       return _( "Seeding" ); break;
    542         case TR_STATUS_STOPPED:    return _( "Paused" ); break;
     539        case TR_STATUS_CHECK_WAIT: return _( "Waiting to verify local data" );
     540        case TR_STATUS_CHECK:      return _( "Verifying local data" );
     541        case TR_STATUS_DOWNLOAD:   return _( "Downloading" );
     542        case TR_STATUS_SEED:       return _( "Seeding" );
     543        case TR_STATUS_STOPPED:    return finished ? _( "Finished" ) : _( "Paused" );
    543544    }
    544545
     
    584585    const char * none = _( "None" );
    585586    const char * mixed = _( "Mixed" );
     587    const char * stateString;
    586588    char buf[512];
    587589    double available = 0;
     
    672674
    673675    /* state_lb */
    674     if( n <= 0 )
     676    if( n < 1 )
    675677        str = none;
    676678    else {
    677         const int baseline = stats[0]->activity;
    678         for( i=1; i<n; ++i )
    679             if( baseline != (int)stats[i]->activity )
    680                 break;
    681         if( i==n )
    682             str = activityString( baseline );
    683         else
    684             str = mixed;
    685     }
     679        const tr_torrent_activity a = stats[0]->activity;
     680        const tr_bool f = stats[0]->finished;
     681        str = activityString( a, f );
     682        for( i=1; i<n; ++i ) {
     683            if( ( stats[i]->activity != a ) || ( stats[i]->finished != f ) ) {
     684                str = mixed;
     685                break;
     686            }
     687        }
     688    }
     689    stateString = str;
    686690    gtr_label_set_text( GTK_LABEL( di->state_lb ), str );
    687691
    688692
    689693    /* date started */
    690     if( n <= 0 )
     694    if( n < 1 )
    691695        str = none;
    692696    else {
    693         const time_t baseline = stats[0]->startDate;
    694         for( i=1; i<n; ++i )
     697        tr_bool allPaused = TRUE;
     698        time_t baseline = stats[0]->startDate;
     699        for( i=1; i<n; ++i ) {
    695700            if( baseline != stats[i]->startDate )
    696                 break;
    697         if( i!=n )
     701                baseline = 0;
     702            if( stats[i]->activity != TR_STATUS_STOPPED )
     703                allPaused = FALSE;
     704        }
     705        if( allPaused )
     706            str = stateString; // paused || finished
     707        else if( !baseline )
    698708            str = mixed;
    699         else if( ( baseline<=0 ) || ( stats[0]->activity == TR_STATUS_STOPPED ) )
    700             str = activityString( TR_STATUS_STOPPED );
    701709        else
    702710            str = tr_strltime( buf, time(NULL)-baseline, sizeof( buf ) );
Note: See TracChangeset for help on using the changeset viewer.