Changeset 4338
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/stats.c
r4217 r4338 60 60 setLabel( ui->one_up_lb, tr_strlsize( buf, one.uploadedBytes, sizeof(buf) ) ); 61 61 setLabel( ui->one_down_lb, tr_strlsize( buf, one.downloadedBytes, sizeof(buf) ) ); 62 setLabel( ui->one_time_lb, tr_strl size( buf, one.secondsActive, sizeof(buf) ) );62 setLabel( ui->one_time_lb, tr_strltime( buf, one.secondsActive, sizeof(buf) ) ); 63 63 setLabelFromRatio( ui->one_ratio_lb, one.ratio ); 64 64 setLabel( ui->all_sessions_lb, g_strdup_printf( _("Started %d times"), (int)all.sessionCount ) ); 65 65 setLabel( ui->all_up_lb, tr_strlsize( buf, all.uploadedBytes, sizeof(buf) ) ); 66 66 setLabel( ui->all_down_lb, tr_strlsize( buf, all.downloadedBytes, sizeof(buf) ) ); 67 setLabel( ui->all_time_lb, readabletime( all.secondsActive) );67 setLabel( ui->all_time_lb, tr_strltime( buf, all.secondsActive, sizeof(buf) ) ); 68 68 setLabelFromRatio( ui->all_ratio_lb, all.ratio ); 69 69 -
trunk/gtk/tr_torrent.c
r4306 r4338 310 310 top = g_strdup_printf( _("Stalled (%.1f%%)"), prog ); 311 311 else { 312 char * timestr = readabletime(eta); 312 char timestr[128]; 313 tr_strltime( timestr, eta, sizeof( timestr ) ); 313 314 top = g_strdup_printf( _("%s remaining (%.1f%%)"), timestr, prog ); 314 g_free(timestr);315 315 } 316 316 break; -
trunk/gtk/util.c
r4273 r4338 92 92 #define DAYS(s) ((s) / 60 / 60 / 24 % 7) 93 93 94 char * 95 readabletime(int secs) { 96 if(60 > secs) 97 return g_strdup_printf(_("%i %s"), 98 SECONDS(secs), ngettext("sec", "secs", SECONDS(secs))); 99 else if(60 * 60 > secs) 100 return g_strdup_printf(_("%i %s %i %s"), 101 MINUTES(secs), ngettext("min", "mins", MINUTES(secs)), 102 SECONDS(secs), ngettext("sec", "secs", SECONDS(secs))); 103 else if(60 * 60 * 24 > secs) 104 return g_strdup_printf(_("%i %s %i %s"), 105 HOURS(secs), ngettext("hr", "hrs", HOURS(secs)), 106 MINUTES(secs), ngettext("min", "mins", MINUTES(secs))); 107 else 108 return g_strdup_printf(_("%i %s %i %s"), 109 DAYS(secs), ngettext("day", "days", DAYS(secs)), 110 HOURS(secs), ngettext("hr", "hrs", HOURS(secs))); 94 char* 95 tr_strltime( char * buf, int secs, size_t buflen ) 96 { 97 if( secs < 60 ) 98 { 99 g_snprintf( buf, buflen, _( "%i %s" ), 100 SECONDS(secs), ngettext("sec", "secs", SECONDS(secs))); 101 } 102 else if( secs < 60*60 ) 103 { 104 g_snprintf( buf, buflen, _("%i %s %i %s"), 105 MINUTES(secs), ngettext("min", "mins", MINUTES(secs)), 106 SECONDS(secs), ngettext("sec", "secs", SECONDS(secs))); 107 } 108 else if( secs < 60*60*24 ) 109 { 110 g_snprintf( buf, buflen, _("%i %s %i %s"), 111 HOURS(secs), ngettext("hr", "hrs", HOURS(secs)), 112 MINUTES(secs), ngettext("min", "mins", MINUTES(secs))); 113 } 114 else 115 { 116 g_snprintf( buf, buflen, _("%i %s %i %s"), 117 DAYS(secs), ngettext("day", "days", DAYS(secs)), 118 HOURS(secs), ngettext("hr", "hrs", HOURS(secs))); 119 } 120 121 return buf; 111 122 } 112 123 -
trunk/gtk/util.h
r4210 r4338 51 51 char* tr_strlspeed (char * buf, double KiBps, size_t buflen ); 52 52 53 /* return a human-readable string for the time given in seconds. 54 the string must be g_free()d */ 55 char * 56 readabletime(int secs); 53 /* return a human-readable string for the time given in seconds. */ 54 char* tr_strltime( char * buf, int secs, size_t buflen ); 57 55 58 56 char *
Note: See TracChangeset
for help on using the changeset viewer.