Changeset 11216
- Timestamp:
- Sep 17, 2010, 5:43:06 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/details.c
r11214 r11216 63 63 GtkWidget * state_lb; 64 64 GtkWidget * have_lb; 65 GtkWidget * availability_lb;66 65 GtkWidget * dl_lb; 67 66 GtkWidget * ul_lb; … … 622 621 const char * stateString; 623 622 char buf[512]; 624 uint64_t available = 0;625 623 uint64_t sizeWhenDone = 0; 626 624 const tr_stat ** stats = g_new( const tr_stat*, n ); … … 808 806 uint64_t haveValid = 0; 809 807 uint32_t verifiedPieces = 0; 808 uint64_t available = 0; 810 809 for( i=0; i<n; ++i ) { 811 810 const tr_stat * st = stats[i]; … … 818 817 available += st->sizeWhenDone - st->leftUntilDone + st->desiredAvailable; 819 818 } 820 if( !haveValid && !haveUnchecked ) 821 str = ""; 822 else { 823 char buf2[32], unver[64], total[64]; 819 { 820 char buf2[32], unver[64], total[64], avail[32]; 821 const double d = ( 100.0 * available ) / sizeWhenDone; 824 822 const double ratio = 100.0 * ( leftUntilDone ? ( haveValid + haveUnchecked ) / (double)sizeWhenDone : 1 ); 823 tr_strlpercent( avail, d, sizeof( avail ) ); 825 824 tr_strlpercent( buf2, ratio, sizeof( buf2 ) ); 826 825 tr_strlsize( total, haveUnchecked + haveValid, sizeof( total ) ); 827 826 tr_strlsize( unver, haveUnchecked, sizeof( unver ) ); 828 if( haveUnchecked ) 829 g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%%); %3$s Unverified" ), total, buf2, unver ); 827 if( !haveUnchecked && !leftUntilDone ) 828 g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%%)" ), total, buf2 ); 829 else if( !haveUnchecked ) 830 g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%% of %3$s%% Available)" ), total, buf2, avail ); 830 831 else 831 g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%% )" ), total, buf2);832 g_snprintf( buf, sizeof( buf ), _( "%1$s (%2$s%% of %3$s%% Available) + %4$s Unverified" ), total, buf2, avail, unver ); 832 833 str = buf; 833 834 } 834 835 } 835 836 gtr_label_set_text( GTK_LABEL( di->have_lb ), str ); 836 837 /* availability_lb */838 if( !sizeWhenDone )839 str = "";840 else {841 char buf2[32];842 const double d = ( 100.0 * available ) / sizeWhenDone;843 tr_strlpercent( buf2, d, sizeof( buf2 ) );844 g_snprintf( buf, sizeof( buf ), _( "%1$s%%" ), buf2 );845 str = buf;846 }847 gtr_label_set_text( GTK_LABEL( di->availability_lb ), str );848 837 849 838 /* dl_lb */ … … 965 954 l = di->have_lb = gtk_label_new( NULL ); 966 955 hig_workarea_add_row( t, &row, _( "Have:" ), l, NULL ); 967 968 /* availability */969 l = di->availability_lb = gtk_label_new( NULL );970 hig_workarea_add_row( t, &row, _( "Availability:" ), l, NULL );971 956 972 957 /* downloaded */ -
trunk/gtk/util.c
r11214 r11216 159 159 { 160 160 if( !bytes ) 161 g_strlcpy( buf, _( "size|None" ), buflen );161 g_strlcpy( buf, Q_( "size|None" ), buflen ); 162 162 else 163 163 tr_formatter_size_B( buf, bytes, buflen ); -
trunk/qt/details.cc
r11209 r11216 363 363 } 364 364 } 365 if( !haveVerified && !haveUnverified ) 366 string = none; 367 else { 365 { 368 366 const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 ); 369 367 QString pct = Formatter::percentToString( d ); 370 if( !haveUnverified ) 368 QString astr; 369 370 if( sizeWhenDone ) 371 astr = Formatter::percentToString( ( 100.0 * available ) / sizeWhenDone ); 372 else 373 astr = "100"; 374 375 if( !haveUnverified && !leftUntilDone ) 376 { 371 377 string = tr( "%1 (%2%)" ) 372 378 .arg( Formatter::sizeToString( haveVerified + haveUnverified ) ) 373 379 .arg( pct ); 374 else 375 string = tr( "%1 (%2%); %3 Unverified" ) 380 } 381 else if( !haveUnverified ) 382 { 383 string = tr( "%1 (%2% of %3% Available)" ) 376 384 .arg( Formatter::sizeToString( haveVerified + haveUnverified ) ) 377 385 .arg( pct ) 386 .arg( astr ); 387 } 388 else 389 { 390 string = tr( "%1 (%2% of %3% Available) + %4 Unverified" ) 391 .arg( Formatter::sizeToString( haveVerified + haveUnverified ) ) 392 .arg( pct ) 393 .arg( astr ) 378 394 .arg( Formatter::sizeToString( haveUnverified ) ); 395 } 379 396 } 380 397 }
Note: See TracChangeset
for help on using the changeset viewer.