Ignore:
Timestamp:
Mar 1, 2009, 4:00:41 PM (13 years ago)
Author:
charles
Message:

(trunk gtk) #1824: Display ETA when seeding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-cell-renderer.c

    r7658 r7982  
    3636
    3737static char*
    38 getProgressString( const tr_info * info,
    39                    const tr_stat * torStat )
     38getProgressString( const tr_torrent * tor,
     39                   const tr_info    * info,
     40                   const tr_stat    * torStat )
    4041{
    4142    const int      isDone = torStat->leftUntilDone == 0;
     
    4445    char           buf1[32], buf2[32], buf3[32], buf4[32];
    4546    char *         str;
     47    double         seedRatio;
     48    gboolean       hasSeedRatio;
    4649
    4750    if( !isDone )
     51    {
    4852        str = g_strdup_printf(
    4953            /* %1$s is how much we've got,
     
    5458            tr_strlsize( buf2, torStat->sizeWhenDone, sizeof( buf2 ) ),
    5559            torStat->percentDone * 100.0 );
     60    }
    5661    else if( !isSeed )
     62    {
    5763        str = g_strdup_printf(
    5864            /* %1$s is how much we've got,
     
    6773            tr_strlsize( buf3, torStat->uploadedEver, sizeof( buf3 ) ),
    6874            tr_strlratio( buf4, torStat->ratio, sizeof( buf4 ) ) );
    69     else
     75    }
     76    else if(( hasSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio )))
     77    {
     78        str = g_strdup_printf(
     79            /* %1$s is the torrent's total size,
     80               %2$s is how much we've uploaded,
     81               %3$s is our upload-to-download ratio,
     82               $4$s is the ratio we want to reach before we stop uploading */
     83            _( "%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)" ),
     84            tr_strlsize( buf1, info->totalSize, sizeof( buf1 ) ),
     85            tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
     86            tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ),
     87            tr_strlratio( buf4, seedRatio, sizeof( buf4 ) ) );
     88    }
     89    else /* seeding w/o a ratio */
     90    {
    7091        str = g_strdup_printf(
    7192            /* %1$s is the torrent's total size,
     
    7697            tr_strlsize( buf2, torStat->uploadedEver, sizeof( buf2 ) ),
    7798            tr_strlratio( buf3, torStat->ratio, sizeof( buf3 ) ) );
     99    }
    78100
    79101    /* add time when downloading */
    80     if( torStat->activity == TR_STATUS_DOWNLOAD )
     102    if( hasSeedRatio || ( torStat->activity == TR_STATUS_DOWNLOAD ) )
    81103    {
    82104        const int eta = torStat->eta;
     
    299321        {
    300322            int    w1, h1;
    301             char * progressString = getProgressString( info, torStat );
     323            char * progressString = getProgressString( tor, info, torStat );
    302324            str = g_markup_printf_escaped( "<b>%s</b>\n<small>%s</small>",
    303325                                           name, progressString );
     
    392414        if( !p->minimal )
    393415        {
    394             char * progressString = getProgressString( info, torStat );
     416            char * progressString = getProgressString( tor, info, torStat );
    395417            char * str = g_markup_printf_escaped(
    396418                "<b>%s</b>\n<small>%s</small>",
Note: See TracChangeset for help on using the changeset viewer.