cruft removal: use tr_stat's ratio field instead of calculating it ourself.
This commit is contained in:
parent
dd4fb1e6d1
commit
8653817e5d
|
@ -820,7 +820,7 @@ refresh_activity (GtkWidget * top)
|
|||
gtk_label_set_text (GTK_LABEL(a->ul_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = ratiostr (stat->downloadedEver, stat->uploadedEver);
|
||||
pch = g_strdup_printf( "%.1f", stat->ratio );
|
||||
gtk_label_set_text (GTK_LABEL(a->ratio_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
|
|
|
@ -269,8 +269,8 @@ tr_core_init( GTypeInstance * instance, gpointer g_class SHUTUP )
|
|||
G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT,
|
||||
/* leechers, completedFromTracker, downloaded, uploaded */
|
||||
G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT64, G_TYPE_UINT64,
|
||||
/* left, TrTorrent object, ID for IPC */
|
||||
G_TYPE_UINT64, TR_TORRENT_TYPE, G_TYPE_INT,
|
||||
/* ratio, left, TrTorrent object, ID for IPC */
|
||||
G_TYPE_FLOAT, G_TYPE_UINT64, TR_TORRENT_TYPE, G_TYPE_INT,
|
||||
};
|
||||
|
||||
#ifdef REFDBG
|
||||
|
@ -562,6 +562,7 @@ tr_core_update( TrCore * self )
|
|||
MC_DONE, st->completedFromTracker,
|
||||
MC_DOWN, st->downloadedEver,
|
||||
MC_UP, st->uploadedEver,
|
||||
MC_RATIO, st->ratio,
|
||||
MC_LEFT, st->leftUntilDone,
|
||||
-1 );
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ enum {
|
|||
MC_NAME, MC_SIZE, MC_HASH, MC_STAT, MC_ERR, MC_TERR,
|
||||
MC_PROG_C, MC_PROG_D, MC_DRATE, MC_URATE, MC_ETA, MC_PEERS,
|
||||
MC_UPEERS, MC_DPEERS, MC_SEED, MC_LEECH, MC_DONE,
|
||||
MC_DOWN, MC_UP, MC_LEFT, MC_TORRENT, MC_ID,
|
||||
MC_DOWN, MC_UP, MC_RATIO, MC_LEFT, MC_TORRENT, MC_ID,
|
||||
MC_ROW_COUNT
|
||||
};
|
||||
|
||||
|
|
|
@ -119,18 +119,18 @@ formatprog( GtkTreeViewColumn * col UNUSED, GtkCellRenderer * rend,
|
|||
GtkTreeModel * model, GtkTreeIter * iter, gpointer data UNUSED )
|
||||
{
|
||||
char * dlstr, * ulstr, * str, * marked;
|
||||
gfloat prog, dl, ul;
|
||||
gfloat prog, dl, ul, ratio;
|
||||
guint64 down, up;
|
||||
|
||||
gtk_tree_model_get( model, iter, MC_PROG_D, &prog, MC_DRATE, &dl,
|
||||
MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, -1 );
|
||||
MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, MC_RATIO, &ratio, -1 );
|
||||
prog = MAX( prog, 0.0 );
|
||||
prog = MIN( prog, 1.0 );
|
||||
|
||||
ulstr = readablespeed (ul);
|
||||
if( 1.0 == prog )
|
||||
{
|
||||
dlstr = ratiostr( down, up );
|
||||
dlstr = g_strdup_printf( "%.1f", ratio );
|
||||
str = g_strdup_printf( _("Ratio: %s\nUL: %s"), dlstr, ulstr );
|
||||
}
|
||||
else
|
||||
|
|
16
gtk/util.c
16
gtk/util.c
|
@ -121,22 +121,6 @@ rfc822date (guint64 epoch_msec)
|
|||
return g_locale_to_utf8( buf, -1, NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
char *
|
||||
ratiostr(guint64 down, guint64 up) {
|
||||
double ratio;
|
||||
|
||||
if(0 == up && 0 == down)
|
||||
return g_strdup(_("N/A"));
|
||||
|
||||
if(0 == down)
|
||||
/* this is a UTF-8 infinity symbol */
|
||||
return g_strdup("\xE2\x88\x9E");
|
||||
|
||||
ratio = (double)up / (double)down;
|
||||
|
||||
return g_strdup_printf("%.*f", BESTDECIMAL(ratio), ratio);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mkdir_p(const char *name, mode_t mode)
|
||||
{
|
||||
|
|
|
@ -63,11 +63,6 @@ readabletime(int secs);
|
|||
char *
|
||||
rfc822date (guint64 epoch_msec);
|
||||
|
||||
/* returns a string representing the download ratio.
|
||||
the string must be g_free()d */
|
||||
char *
|
||||
ratiostr(guint64 down, guint64 up);
|
||||
|
||||
/* create a directory and any missing parent directories */
|
||||
gboolean
|
||||
mkdir_p(const char *name, mode_t mode);
|
||||
|
|
Loading…
Reference in New Issue