(trunk) #3549 "torrent properties window does not fit netbook screen" -- fixed

This commit is contained in:
Charles Kerr 2010-09-17 05:43:06 +00:00
parent efd71c05ab
commit bf0e84f266
3 changed files with 34 additions and 32 deletions

View File

@ -62,7 +62,6 @@ struct DetailsImpl
GtkWidget * size_lb;
GtkWidget * state_lb;
GtkWidget * have_lb;
GtkWidget * availability_lb;
GtkWidget * dl_lb;
GtkWidget * ul_lb;
GtkWidget * ratio_lb;
@ -621,7 +620,6 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
const char * no_torrent = _( "No Torrents Selected" );
const char * stateString;
char buf[512];
uint64_t available = 0;
uint64_t sizeWhenDone = 0;
const tr_stat ** stats = g_new( const tr_stat*, n );
const tr_info ** infos = g_new( const tr_info*, n );
@ -807,6 +805,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
uint64_t haveUnchecked = 0;
uint64_t haveValid = 0;
uint32_t verifiedPieces = 0;
uint64_t available = 0;
for( i=0; i<n; ++i ) {
const tr_stat * st = stats[i];
const tr_info * inf = infos[i];
@ -817,35 +816,25 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
leftUntilDone += st->leftUntilDone;
available += st->sizeWhenDone - st->leftUntilDone + st->desiredAvailable;
}
if( !haveValid && !haveUnchecked )
str = "";
else {
char buf2[32], unver[64], total[64];
{
char buf2[32], unver[64], total[64], avail[32];
const double d = ( 100.0 * available ) / sizeWhenDone;
const double ratio = 100.0 * ( leftUntilDone ? ( haveValid + haveUnchecked ) / (double)sizeWhenDone : 1 );
tr_strlpercent( avail, d, sizeof( avail ) );
tr_strlpercent( buf2, ratio, sizeof( buf2 ) );
tr_strlsize( total, haveUnchecked + haveValid, sizeof( total ) );
tr_strlsize( unver, haveUnchecked, sizeof( unver ) );
if( haveUnchecked )
g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%%); %3$s Unverified" ), total, buf2, unver );
else
if( !haveUnchecked && !leftUntilDone )
g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%%)" ), total, buf2 );
else if( !haveUnchecked )
g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%% of %3$s%% Available)" ), total, buf2, avail );
else
g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%% of %3$s%% Available) + %4$s Unverified" ), total, buf2, avail, unver );
str = buf;
}
}
gtr_label_set_text( GTK_LABEL( di->have_lb ), str );
/* availability_lb */
if( !sizeWhenDone )
str = "";
else {
char buf2[32];
const double d = ( 100.0 * available ) / sizeWhenDone;
tr_strlpercent( buf2, d, sizeof( buf2 ) );
g_snprintf( buf, sizeof( buf ), _( "%1$s%%" ), buf2 );
str = buf;
}
gtr_label_set_text( GTK_LABEL( di->availability_lb ), str );
/* dl_lb */
if( n <= 0 )
str = no_torrent;
@ -965,10 +954,6 @@ info_page_new( struct DetailsImpl * di )
l = di->have_lb = gtk_label_new( NULL );
hig_workarea_add_row( t, &row, _( "Have:" ), l, NULL );
/* availability */
l = di->availability_lb = gtk_label_new( NULL );
hig_workarea_add_row( t, &row, _( "Availability:" ), l, NULL );
/* downloaded */
l = di->dl_lb = gtk_label_new( NULL );
hig_workarea_add_row( t, &row, _( "Downloaded:" ), l, NULL );

View File

@ -158,7 +158,7 @@ char*
tr_strlsize( char * buf, guint64 bytes, size_t buflen )
{
if( !bytes )
g_strlcpy( buf, _( "size|None" ), buflen );
g_strlcpy( buf, Q_( "size|None" ), buflen );
else
tr_formatter_size_B( buf, bytes, buflen );

View File

@ -362,20 +362,37 @@ Details :: refresh( )
available += t->sizeWhenDone() - t->leftUntilDone() + t->desiredAvailable();
}
}
if( !haveVerified && !haveUnverified )
string = none;
else {
{
const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 );
QString pct = Formatter::percentToString( d );
if( !haveUnverified )
QString astr;
if( sizeWhenDone )
astr = Formatter::percentToString( ( 100.0 * available ) / sizeWhenDone );
else
astr = "100";
if( !haveUnverified && !leftUntilDone )
{
string = tr( "%1 (%2%)" )
.arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
.arg( pct );
else
string = tr( "%1 (%2%); %3 Unverified" )
}
else if( !haveUnverified )
{
string = tr( "%1 (%2% of %3% Available)" )
.arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
.arg( pct )
.arg( astr );
}
else
{
string = tr( "%1 (%2% of %3% Available) + %4 Unverified" )
.arg( Formatter::sizeToString( haveVerified + haveUnverified ) )
.arg( pct )
.arg( astr )
.arg( Formatter::sizeToString( haveUnverified ) );
}
}
}
myHaveLabel->setText( string );