(gtk) tweak the display speed/size units again.
This commit is contained in:
parent
93f69d2b5c
commit
9148c9211f
|
@ -61,13 +61,13 @@ tr_strlsize( char * buf, guint64 size, size_t buflen )
|
|||
N_("PiB"), N_("EiB"), N_("ZiB"), N_("YiB")
|
||||
};
|
||||
unsigned int i;
|
||||
guint64 small = size;
|
||||
for( i=0; i<G_N_ELEMENTS(units) && small>=1024; ++i )
|
||||
small >>= 10;
|
||||
double small = size;
|
||||
for( i=0; i<G_N_ELEMENTS(units) && (small>=1024.0); ++i )
|
||||
small /= 1024.0;
|
||||
if( i < 2 ) /* B & KiB */
|
||||
g_snprintf( buf, buflen, "%d %s", (int)small, _(units[i]) );
|
||||
else
|
||||
g_snprintf( buf, buflen, "%.1f %s", (double)small, _(units[i]) );
|
||||
g_snprintf( buf, buflen, "%.1f %s", small, _(units[i]) );
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -132,17 +132,25 @@ tr_statsClose( tr_handle * handle )
|
|||
handle->sessionStats = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
updateRatio( tr_session_stats * setme )
|
||||
{
|
||||
if( setme->downloadedBytes )
|
||||
setme->ratio = setme->uploadedBytes / (double)setme->downloadedBytes;
|
||||
else if( setme->uploadedBytes )
|
||||
setme->ratio = TR_RATIO_INF;
|
||||
else
|
||||
setme->ratio = TR_RATIO_NA;
|
||||
}
|
||||
|
||||
void
|
||||
tr_getSessionStats( const tr_handle * handle,
|
||||
tr_session_stats * setme )
|
||||
{
|
||||
const struct tr_stats_handle * stats = handle->sessionStats;
|
||||
*setme = stats->single;
|
||||
|
||||
setme->ratio = setme->downloadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes
|
||||
: ( setme->uploadedBytes ? TR_RATIO_INF : TR_RATIO_NA );
|
||||
|
||||
setme->secondsActive += ( time(NULL) - stats->startTime );
|
||||
updateRatio( setme );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -151,8 +159,8 @@ tr_getCumulativeSessionStats( const tr_handle * handle,
|
|||
{
|
||||
const struct tr_stats_handle * stats = handle->sessionStats;
|
||||
*setme = stats->cumulative;
|
||||
setme->ratio = setme->downloadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes : TR_RATIO_NA;
|
||||
setme->secondsActive += ( time(NULL) - stats->startTime );
|
||||
updateRatio( setme );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue