(gtk) fix wrong units in the s stats dialog. plug small memory leak.
This commit is contained in:
parent
e5592c3404
commit
cb65fe24bd
|
@ -59,12 +59,12 @@ updateStats( gpointer gdata )
|
|||
|
||||
setLabel( ui->one_up_lb, tr_strlsize( buf, one.uploadedBytes, sizeof(buf) ) );
|
||||
setLabel( ui->one_down_lb, tr_strlsize( buf, one.downloadedBytes, sizeof(buf) ) );
|
||||
setLabel( ui->one_time_lb, tr_strlsize( buf, one.secondsActive, sizeof(buf) ) );
|
||||
setLabel( ui->one_time_lb, tr_strltime( buf, one.secondsActive, sizeof(buf) ) );
|
||||
setLabelFromRatio( ui->one_ratio_lb, one.ratio );
|
||||
setLabel( ui->all_sessions_lb, g_strdup_printf( _("Started %d times"), (int)all.sessionCount ) );
|
||||
setLabel( ui->all_up_lb, tr_strlsize( buf, all.uploadedBytes, sizeof(buf) ) );
|
||||
setLabel( ui->all_down_lb, tr_strlsize( buf, all.downloadedBytes, sizeof(buf) ) );
|
||||
setLabel( ui->all_time_lb, readabletime( all.secondsActive ) );
|
||||
setLabel( ui->all_time_lb, tr_strltime( buf, all.secondsActive, sizeof(buf) ) );
|
||||
setLabelFromRatio( ui->all_ratio_lb, all.ratio );
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -309,9 +309,9 @@ tr_torrent_status_str ( TrTorrent * gtor )
|
|||
if( eta < 0 )
|
||||
top = g_strdup_printf( _("Stalled (%.1f%%)"), prog );
|
||||
else {
|
||||
char * timestr = readabletime(eta);
|
||||
char timestr[128];
|
||||
tr_strltime( timestr, eta, sizeof( timestr ) );
|
||||
top = g_strdup_printf( _("%s remaining (%.1f%%)"), timestr, prog );
|
||||
g_free(timestr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
45
gtk/util.c
45
gtk/util.c
|
@ -91,23 +91,34 @@ tr_strlspeed( char * buf, double KiBps, size_t buflen )
|
|||
#define HOURS(s) ((s) / 60 / 60 % 24)
|
||||
#define DAYS(s) ((s) / 60 / 60 / 24 % 7)
|
||||
|
||||
char *
|
||||
readabletime(int secs) {
|
||||
if(60 > secs)
|
||||
return g_strdup_printf(_("%i %s"),
|
||||
SECONDS(secs), ngettext("sec", "secs", SECONDS(secs)));
|
||||
else if(60 * 60 > secs)
|
||||
return g_strdup_printf(_("%i %s %i %s"),
|
||||
MINUTES(secs), ngettext("min", "mins", MINUTES(secs)),
|
||||
SECONDS(secs), ngettext("sec", "secs", SECONDS(secs)));
|
||||
else if(60 * 60 * 24 > secs)
|
||||
return g_strdup_printf(_("%i %s %i %s"),
|
||||
HOURS(secs), ngettext("hr", "hrs", HOURS(secs)),
|
||||
MINUTES(secs), ngettext("min", "mins", MINUTES(secs)));
|
||||
else
|
||||
return g_strdup_printf(_("%i %s %i %s"),
|
||||
DAYS(secs), ngettext("day", "days", DAYS(secs)),
|
||||
HOURS(secs), ngettext("hr", "hrs", HOURS(secs)));
|
||||
char*
|
||||
tr_strltime( char * buf, int secs, size_t buflen )
|
||||
{
|
||||
if( secs < 60 )
|
||||
{
|
||||
g_snprintf( buf, buflen, _( "%i %s" ),
|
||||
SECONDS(secs), ngettext("sec", "secs", SECONDS(secs)));
|
||||
}
|
||||
else if( secs < 60*60 )
|
||||
{
|
||||
g_snprintf( buf, buflen, _("%i %s %i %s"),
|
||||
MINUTES(secs), ngettext("min", "mins", MINUTES(secs)),
|
||||
SECONDS(secs), ngettext("sec", "secs", SECONDS(secs)));
|
||||
}
|
||||
else if( secs < 60*60*24 )
|
||||
{
|
||||
g_snprintf( buf, buflen, _("%i %s %i %s"),
|
||||
HOURS(secs), ngettext("hr", "hrs", HOURS(secs)),
|
||||
MINUTES(secs), ngettext("min", "mins", MINUTES(secs)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_snprintf( buf, buflen, _("%i %s %i %s"),
|
||||
DAYS(secs), ngettext("day", "days", DAYS(secs)),
|
||||
HOURS(secs), ngettext("hr", "hrs", HOURS(secs)));
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
@ -50,10 +50,8 @@ char* tr_strlsize( char * buf, guint64 size, size_t buflen );
|
|||
/* return a human-readable string for the transfer rate given in bytes. */
|
||||
char* tr_strlspeed (char * buf, double KiBps, size_t buflen );
|
||||
|
||||
/* return a human-readable string for the time given in seconds.
|
||||
the string must be g_free()d */
|
||||
char *
|
||||
readabletime(int secs);
|
||||
/* return a human-readable string for the time given in seconds. */
|
||||
char* tr_strltime( char * buf, int secs, size_t buflen );
|
||||
|
||||
char *
|
||||
rfc822date (guint64 epoch_msec);
|
||||
|
|
Loading…
Reference in New Issue