mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
GTK:
Adjust the number of decimals shown with sizes based on the number size, as is done with the ratio.
This commit is contained in:
@@ -417,9 +417,9 @@ makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
||||
INFOLINEA(table, ii, _("Tracker:"), g_strdup_printf("http://%s:%i",
|
||||
sb[id].info.trackerAddress, sb[id].info.trackerPort));
|
||||
INFOLINE(table, ii, _("Announce:"), sb[id].info.trackerAnnounce);
|
||||
INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize, 1));
|
||||
INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize));
|
||||
INFOLINEF(table, ii, "%i", _("Pieces:"), sb[id].info.pieceCount);
|
||||
INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize, 1));
|
||||
INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize));
|
||||
if(0 > sb[id].seeders)
|
||||
INFOLINE(table, ii, _("Seeders:"), _("?"));
|
||||
else
|
||||
@@ -432,8 +432,8 @@ makeinfowind(GtkWindow *parent, tr_handle_t *tr, int id) {
|
||||
INFOSEP(table, ii);
|
||||
|
||||
INFOLINE(table, ii, _("Directory:"), sb[id].folder);
|
||||
INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded, 1));
|
||||
INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded, 1));
|
||||
INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded));
|
||||
INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded));
|
||||
|
||||
INFOSEP(table, ii);
|
||||
|
||||
|
||||
10
gtk/main.c
10
gtk/main.c
@@ -682,7 +682,7 @@ dfname(GtkTreeViewColumn *col SHUTUP, GtkCellRenderer *rend,
|
||||
upeers = 0;
|
||||
if(0 > dpeers)
|
||||
dpeers = 0;
|
||||
mb = readablesize(size, 1);
|
||||
mb = readablesize(size);
|
||||
prog *= 100;
|
||||
|
||||
if(status & TR_STATUS_CHECK)
|
||||
@@ -744,12 +744,12 @@ dfprog(GtkTreeViewColumn *col SHUTUP, GtkCellRenderer *rend,
|
||||
else if(1.0 < prog)
|
||||
prog = 1.0;
|
||||
|
||||
ulstr = readablesize(ul * 1024.0, 2);
|
||||
ulstr = readablesize(ul * 1024.0);
|
||||
if(1.0 == prog) {
|
||||
dlstr = ratiostr(down, up);
|
||||
str = g_strdup_printf(_("Ratio: %s\nUL: %s/s"), dlstr, ulstr);
|
||||
} else {
|
||||
dlstr = readablesize(dl * 1024.0, 2);
|
||||
dlstr = readablesize(dl * 1024.0);
|
||||
str = g_strdup_printf(_("DL: %s/s\nUL: %s/s"), dlstr, ulstr);
|
||||
}
|
||||
marked = g_markup_printf_escaped("<small>%s</small>", str);
|
||||
@@ -796,8 +796,8 @@ updatemodel(gpointer gdata) {
|
||||
|
||||
/* update the status bar */
|
||||
tr_torrentRates(data->tr, &up, &down);
|
||||
downstr = readablesize(down * 1024.0, 2);
|
||||
upstr = readablesize(up * 1024.0, 2);
|
||||
downstr = readablesize(down * 1024.0);
|
||||
upstr = readablesize(up * 1024.0);
|
||||
str = g_strdup_printf(_(" Total DL: %s/s Total UL: %s/s"),
|
||||
upstr, downstr);
|
||||
gtk_statusbar_pop(data->bar, 0);
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#define BESTDECIMAL(d) (10.0 > (d) ? 2 : (100.0 > (d) ? 1 : 0))
|
||||
|
||||
static void
|
||||
sigexithandler(int sig);
|
||||
static void
|
||||
@@ -64,7 +66,7 @@ static const char *sizestrs[] = {
|
||||
};
|
||||
|
||||
char *
|
||||
readablesize(guint64 size, int decimals) {
|
||||
readablesize(guint64 size) {
|
||||
unsigned int ii;
|
||||
double small = size;
|
||||
|
||||
@@ -76,7 +78,8 @@ readablesize(guint64 size, int decimals) {
|
||||
ii++;
|
||||
}
|
||||
|
||||
return g_strdup_printf("%.*f %s", decimals, small, gettext(sizestrs[ii]));
|
||||
return g_strdup_printf("%.*f %s", BESTDECIMAL(small), small,
|
||||
gettext(sizestrs[ii]));
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
@@ -48,10 +48,10 @@ typedef void (*callbackfunc_t)(void*);
|
||||
gboolean
|
||||
strbool(const char *str);
|
||||
|
||||
/* return a human-readable string for the size given in bytes with the
|
||||
requested number of decimal places. the string must be g_free()d */
|
||||
/* return a human-readable string for the size given in bytes.
|
||||
the string must be g_free()d */
|
||||
char *
|
||||
readablesize(guint64 size, int decimals);
|
||||
readablesize(guint64 size);
|
||||
|
||||
/* returns a string representing the download ratio.
|
||||
the string must be g_free()d */
|
||||
|
||||
Reference in New Issue
Block a user