mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
(trunk T) #3045 "units" -- modify the formatter functions based on feedback from BMW
This commit is contained in:
10
cli/cli.c
10
cli/cli.c
@@ -40,22 +40,24 @@
|
||||
***/
|
||||
|
||||
#define MEM_K 1024
|
||||
#define MEM_B_STR "B"
|
||||
#define MEM_K_STR "KiB"
|
||||
#define MEM_M_STR "MiB"
|
||||
#define MEM_G_STR "GiB"
|
||||
#define MEM_T_STR "TiB"
|
||||
|
||||
#define DISK_K 1000
|
||||
#define DISK_B_STR "B"
|
||||
#define DISK_K_STR "kB"
|
||||
#define DISK_M_STR "MB"
|
||||
#define DISK_G_STR "GB"
|
||||
#define DISK_T_STR "TB"
|
||||
|
||||
#define SPEED_K 1000
|
||||
#define SPEED_B_STR "B/s"
|
||||
#define SPEED_K_STR "kB/s"
|
||||
#define SPEED_M_STR "MB/s"
|
||||
#define SPEED_G_STR "GB/s"
|
||||
#define SPEED_T_STR "TB/s"
|
||||
|
||||
/***
|
||||
****
|
||||
@@ -221,9 +223,9 @@ main( int argc, char ** argv )
|
||||
uint8_t * fileContents;
|
||||
size_t fileLength;
|
||||
|
||||
tr_formatter_mem_init( MEM_K, MEM_B_STR, MEM_K_STR, MEM_M_STR, MEM_G_STR );
|
||||
tr_formatter_size_init( DISK_K,DISK_B_STR, DISK_K_STR, DISK_M_STR, DISK_G_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_B_STR, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR );
|
||||
tr_formatter_mem_init( MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR );
|
||||
tr_formatter_size_init( DISK_K,DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR );
|
||||
|
||||
printf( "Transmission %s - http://www.transmissionbt.com/\n",
|
||||
LONG_VERSION_STRING );
|
||||
|
||||
@@ -41,22 +41,24 @@
|
||||
#define PREF_KEY_DIR_WATCH_ENABLED "watch-dir-enabled"
|
||||
|
||||
#define MEM_K 1024
|
||||
#define MEM_B_STR "B"
|
||||
#define MEM_K_STR "KiB"
|
||||
#define MEM_M_STR "MiB"
|
||||
#define MEM_G_STR "GiB"
|
||||
#define MEM_T_STR "TiB"
|
||||
|
||||
#define DISK_K 1000
|
||||
#define DISK_B_STR "B"
|
||||
#define DISK_K_STR "kB"
|
||||
#define DISK_M_STR "MB"
|
||||
#define DISK_G_STR "GB"
|
||||
#define DISK_T_STR "TB"
|
||||
|
||||
#define SPEED_K 1000
|
||||
#define SPEED_B_STR "B/s"
|
||||
#define SPEED_K_STR "kB/s"
|
||||
#define SPEED_M_STR "MB/s"
|
||||
#define SPEED_G_STR "GB/s"
|
||||
#define SPEED_T_STR "TB/s"
|
||||
|
||||
static tr_bool paused = FALSE;
|
||||
static tr_bool closing = FALSE;
|
||||
@@ -463,9 +465,9 @@ main( int argc, char ** argv )
|
||||
}
|
||||
|
||||
/* start the session */
|
||||
tr_formatter_mem_init( MEM_K, MEM_B_STR, MEM_K_STR, MEM_M_STR, MEM_G_STR );
|
||||
tr_formatter_size_init( DISK_K,DISK_B_STR, DISK_K_STR, DISK_M_STR, DISK_G_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_B_STR, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR );
|
||||
tr_formatter_mem_init( MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR );
|
||||
tr_formatter_size_init( DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR );
|
||||
mySession = tr_sessionInit( "daemon", configDir, TRUE, &settings );
|
||||
tr_ninf( NULL, "Using settings from \"%s\"", configDir );
|
||||
tr_sessionSaveSettings( mySession, configDir, &settings );
|
||||
|
||||
@@ -44,22 +44,24 @@
|
||||
#define ARGUMENTS "arguments"
|
||||
|
||||
#define MEM_K 1024
|
||||
#define MEM_B_STR "B"
|
||||
#define MEM_K_STR "KiB"
|
||||
#define MEM_M_STR "MiB"
|
||||
#define MEM_G_STR "GiB"
|
||||
#define MEM_T_STR "TiB"
|
||||
|
||||
#define DISK_K 1000
|
||||
#define DISK_B_STR "B"
|
||||
#define DISK_K_STR "kB"
|
||||
#define DISK_M_STR "MB"
|
||||
#define DISK_G_STR "GB"
|
||||
#define DISK_T_STR "TB"
|
||||
|
||||
#define SPEED_K 1000
|
||||
#define SPEED_B_STR "B/s"
|
||||
#define SPEED_K_STR "kB/s"
|
||||
#define SPEED_M_STR "MB/s"
|
||||
#define SPEED_G_STR "GB/s"
|
||||
#define SPEED_T_STR "TB/s"
|
||||
|
||||
/***
|
||||
****
|
||||
@@ -2199,9 +2201,9 @@ main( int argc, char ** argv )
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
tr_formatter_mem_init( MEM_K, MEM_B_STR, MEM_K_STR, MEM_M_STR, MEM_G_STR );
|
||||
tr_formatter_size_init( DISK_K,DISK_B_STR, DISK_K_STR, DISK_M_STR, DISK_G_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_B_STR, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR );
|
||||
tr_formatter_mem_init( MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR );
|
||||
tr_formatter_size_init( DISK_K,DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR );
|
||||
tr_formatter_speed_init( SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR );
|
||||
|
||||
getHostAndPort( &argc, argv, &host, &port );
|
||||
if( host == NULL )
|
||||
|
||||
@@ -532,9 +532,9 @@ main( int argc, char ** argv )
|
||||
bind_textdomain_codeset( domain, "UTF-8" );
|
||||
textdomain( domain );
|
||||
g_set_application_name( _( "Transmission" ) );
|
||||
tr_formatter_mem_init( mem_K, _(mem_B_str), _(mem_K_str), _(mem_M_str), _(mem_G_str) );
|
||||
tr_formatter_size_init( disk_K, _(disk_B_str), _(disk_K_str), _(disk_M_str), _(disk_G_str) );
|
||||
tr_formatter_speed_init( speed_K, _(speed_B_str), _(speed_K_str), _(speed_M_str), _(speed_G_str) );
|
||||
tr_formatter_mem_init( mem_K, _(mem_K_str), _(mem_M_str), _(mem_G_str), _(mem_T_str) );
|
||||
tr_formatter_size_init( disk_K, _(disk_K_str), _(disk_M_str), _(disk_G_str), _(disk_T_str) );
|
||||
tr_formatter_speed_init( speed_K, _(speed_K_str), _(speed_M_str), _(speed_G_str), _(speed_T_str) );
|
||||
|
||||
/* initialize gtk */
|
||||
if( !g_thread_supported( ) )
|
||||
|
||||
18
gtk/util.c
18
gtk/util.c
@@ -47,34 +47,22 @@
|
||||
***/
|
||||
|
||||
const int mem_K = 1024;
|
||||
/* abbreviation for bytes */
|
||||
const char * mem_B_str = N_("B");
|
||||
/* abbreviation IEC base 2 units kilobyte */
|
||||
const char * mem_K_str = N_("KiB");
|
||||
/* abbreviation IEC base 2 units megabyte */
|
||||
const char * mem_M_str = N_("MiB");
|
||||
/* abbreviation IEC base 2 units gigabyte */
|
||||
const char * mem_G_str = N_("GiB");
|
||||
const char * mem_T_str = N_("TiB");
|
||||
|
||||
const int disk_K = 1000;
|
||||
/* abbreviation for bytes */
|
||||
const char * disk_B_str = N_("B");
|
||||
/* abbreviation for SI base 10 kilobyte */
|
||||
const char * disk_K_str = N_("kB");
|
||||
/* abbreviation for SI base 10 megabyte */
|
||||
const char * disk_M_str = N_("MB");
|
||||
/* abbreviation for SI base 10 gigabyte */
|
||||
const char * disk_G_str = N_("GB");
|
||||
const char * disk_T_str = N_("TB");
|
||||
|
||||
const int speed_K = 1000;
|
||||
/* abbreviation for bytes per second */
|
||||
const char * speed_B_str = N_("B/s");
|
||||
/* abbreviation for kilobytes per second */
|
||||
const char * speed_K_str = N_("kB/s");
|
||||
/* abbreviation for megabytes per second */
|
||||
const char * speed_M_str = N_("MB/s");
|
||||
/* abbreviation for gigabytes per second */
|
||||
const char * speed_G_str = N_("GB/s");
|
||||
const char * speed_T_str = N_("TB/s");
|
||||
|
||||
/***
|
||||
****
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
#include <libtransmission/transmission.h>
|
||||
|
||||
extern const int mem_K;
|
||||
extern const char * mem_B_str;
|
||||
extern const char * mem_K_str;
|
||||
extern const char * mem_M_str;
|
||||
extern const char * mem_G_str;
|
||||
extern const char * mem_T_str;
|
||||
|
||||
extern const int disk_K;
|
||||
extern const char * disk_B_str;
|
||||
extern const char * disk_K_str;
|
||||
extern const char * disk_M_str;
|
||||
extern const char * disk_G_str;
|
||||
extern const char * disk_T_str;
|
||||
|
||||
extern const int speed_K;
|
||||
extern const char * speed_B_str;
|
||||
extern const char * speed_K_str;
|
||||
extern const char * speed_M_str;
|
||||
extern const char * speed_G_str;
|
||||
extern const char * speed_T_str;
|
||||
|
||||
/* portability wrapper around g_warn_if_fail() for older versions of glib */
|
||||
#ifdef g_warn_if_fail
|
||||
|
||||
@@ -1516,7 +1516,7 @@ tr_realpath( const char * path, char * resolved_path )
|
||||
struct formatter_unit
|
||||
{
|
||||
char * name;
|
||||
unsigned int value;
|
||||
unsigned long value;
|
||||
};
|
||||
|
||||
struct formatter_units
|
||||
@@ -1524,25 +1524,29 @@ struct formatter_units
|
||||
struct formatter_unit units[4];
|
||||
};
|
||||
|
||||
enum { TR_FMT_B, TR_FMT_KB, TR_FMT_MB, TR_FMT_GB };
|
||||
enum { TR_FMT_KB, TR_FMT_MB, TR_FMT_GB, TR_FMT_TB };
|
||||
|
||||
static void
|
||||
formatter_init( struct formatter_units * units,
|
||||
unsigned int kilo,
|
||||
const char * b, const char * kb,
|
||||
const char * mb, const char * gb )
|
||||
const char * kb, const char * mb,
|
||||
const char * gb, const char * tb )
|
||||
{
|
||||
units->units[TR_FMT_B].name = tr_strdup( b );
|
||||
units->units[TR_FMT_B].value = 1;
|
||||
|
||||
unsigned long value = kilo;
|
||||
units->units[TR_FMT_KB].name = tr_strdup( kb );
|
||||
units->units[TR_FMT_KB].value = kilo;
|
||||
units->units[TR_FMT_KB].value = value;
|
||||
|
||||
value *= kilo;
|
||||
units->units[TR_FMT_MB].name = tr_strdup( mb );
|
||||
units->units[TR_FMT_MB].value = kilo * kilo;
|
||||
units->units[TR_FMT_MB].value = value;
|
||||
|
||||
value *= kilo;
|
||||
units->units[TR_FMT_GB].name = tr_strdup( gb );
|
||||
units->units[TR_FMT_GB].value = kilo * kilo * kilo;
|
||||
units->units[TR_FMT_GB].value = value;
|
||||
|
||||
value *= kilo;
|
||||
units->units[TR_FMT_TB].name = tr_strdup( tb );
|
||||
units->units[TR_FMT_TB].value = value;
|
||||
}
|
||||
|
||||
static char*
|
||||
|
||||
@@ -337,9 +337,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||
tr_bencFree(&settings);
|
||||
|
||||
#warning localize and make consistent
|
||||
tr_formatter_size_init(1024, "bytes", "KB", "MB", "GB");
|
||||
tr_formatter_speed_init(1024, "B/s", "KB/s", "MB/s", "GB/s");
|
||||
tr_formatter_mem_init(1024, "bytes", "KB", "MB", "GB");
|
||||
tr_formatter_size_init(1024, "KB", "MB", "GB", "TB");
|
||||
tr_formatter_speed_init(1024, "B/s", "KB/s", "MB/s", "GB/s", "TB/s");
|
||||
tr_formatter_mem_init(1024, "KB", "MB", "GB", "TB");
|
||||
|
||||
[NSApp setDelegate: self];
|
||||
|
||||
|
||||
12
qt/app.cc
12
qt/app.cc
@@ -101,20 +101,20 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
||||
|
||||
// initialize the units formatter
|
||||
tr_formatter_mem_init( Formatter::mem_K,
|
||||
qPrintable( Formatter::mem_B_str ),
|
||||
qPrintable( Formatter::mem_K_str ),
|
||||
qPrintable( Formatter::mem_M_str ),
|
||||
qPrintable( Formatter::mem_G_str ) );
|
||||
qPrintable( Formatter::mem_G_str ),
|
||||
qPrintable( Formatter::mem_T_str ) );
|
||||
tr_formatter_size_init( Formatter::size_K,
|
||||
qPrintable( Formatter::size_B_str ),
|
||||
qPrintable( Formatter::size_K_str ),
|
||||
qPrintable( Formatter::size_M_str ),
|
||||
qPrintable( Formatter::size_G_str ) );
|
||||
qPrintable( Formatter::size_G_str ),
|
||||
qPrintable( Formatter::size_T_str ) );
|
||||
tr_formatter_speed_init( Formatter::speed_K,
|
||||
qPrintable( Formatter::speed_B_str ),
|
||||
qPrintable( Formatter::speed_K_str ),
|
||||
qPrintable( Formatter::speed_M_str ),
|
||||
qPrintable( Formatter::speed_G_str ) );
|
||||
qPrintable( Formatter::speed_G_str ),
|
||||
qPrintable( Formatter::speed_T_str ) );
|
||||
|
||||
// set the default icon
|
||||
QIcon icon;
|
||||
|
||||
@@ -23,22 +23,22 @@
|
||||
***/
|
||||
|
||||
const int Formatter :: speed_K = 1000;
|
||||
const QString Formatter :: speed_B_str = "B/s";
|
||||
const QString Formatter :: speed_K_str = "kB/s";
|
||||
const QString Formatter :: speed_M_str = "MB/s";
|
||||
const QString Formatter :: speed_G_str = "GB/s";
|
||||
const QString Formatter :: speed_T_str = "TB/s";
|
||||
|
||||
const int Formatter :: size_K = 1000;
|
||||
const QString Formatter :: size_B_str = "B";
|
||||
const QString Formatter :: size_K_str = "kB";
|
||||
const QString Formatter :: size_M_str = "MB";
|
||||
const QString Formatter :: size_G_str = "GB";
|
||||
const QString Formatter :: size_T_str = "TB";
|
||||
|
||||
const int Formatter :: mem_K = 1024;
|
||||
const QString Formatter :: mem_B_str = "B";
|
||||
const QString Formatter :: mem_K_str = "KiB";
|
||||
const QString Formatter :: mem_M_str = "MiB";
|
||||
const QString Formatter :: mem_G_str = "GiB";
|
||||
const QString Formatter :: mem_T_str = "TiB";
|
||||
|
||||
/***
|
||||
****
|
||||
|
||||
@@ -40,22 +40,22 @@ class Formatter: public QObject
|
||||
public:
|
||||
|
||||
static const int speed_K;
|
||||
static const QString speed_B_str;
|
||||
static const QString speed_K_str;
|
||||
static const QString speed_M_str;
|
||||
static const QString speed_G_str;
|
||||
static const QString speed_T_str;
|
||||
|
||||
static const int size_K;
|
||||
static const QString size_B_str;
|
||||
static const QString size_K_str;
|
||||
static const QString size_M_str;
|
||||
static const QString size_G_str;
|
||||
static const QString size_T_str;
|
||||
|
||||
static const int mem_K;
|
||||
static const QString mem_B_str;
|
||||
static const QString mem_K_str;
|
||||
static const QString mem_M_str;
|
||||
static const QString mem_G_str;
|
||||
static const QString mem_T_str;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
10
utils/show.c
10
utils/show.c
@@ -29,22 +29,24 @@
|
||||
#define TIMEOUT_SECS 30
|
||||
|
||||
#define MEM_K 1024
|
||||
#define MEM_B_STR "B"
|
||||
#define MEM_K_STR "KiB"
|
||||
#define MEM_M_STR "MiB"
|
||||
#define MEM_G_STR "GiB"
|
||||
#define MEM_T_STR "TiB"
|
||||
|
||||
#define DISK_K 1000
|
||||
#define DISK_B_STR "B"
|
||||
#define DISK_K_STR "kB"
|
||||
#define DISK_M_STR "MB"
|
||||
#define DISK_G_STR "GB"
|
||||
#define DISK_T_STR "TB"
|
||||
|
||||
#define SPEED_K 1000
|
||||
#define SPEED_B_STR "B/s"
|
||||
#define SPEED_K_STR "kB/s"
|
||||
#define SPEED_M_STR "MB/s"
|
||||
#define SPEED_G_STR "GB/s"
|
||||
#define SPEED_T_STR "TB/s"
|
||||
|
||||
static tr_option options[] =
|
||||
{
|
||||
@@ -249,9 +251,9 @@ main( int argc, char * argv[] )
|
||||
tr_ctor * ctor;
|
||||
|
||||
tr_setMessageLevel( TR_MSG_ERR );
|
||||
tr_formatter_mem_init ( MEM_K, MEM_B_STR, MEM_K_STR, MEM_M_STR, MEM_G_STR );
|
||||
tr_formatter_size_init ( DISK_K, DISK_B_STR, DISK_K_STR, DISK_M_STR, DISK_G_STR );
|
||||
tr_formatter_size_init ( SPEED_K, SPEED_B_STR, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR );
|
||||
tr_formatter_mem_init ( MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR );
|
||||
tr_formatter_size_init ( DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR );
|
||||
tr_formatter_size_init ( SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR );
|
||||
|
||||
if( parseCommandLine( argc, (const char**)argv ) )
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user