Changeset 3821


Ignore:
Timestamp:
Nov 15, 2007, 4:19:53 AM (14 years ago)
Author:
charles
Message:

cruft removal: use tr_stat's ratio field instead of calculating it ourself.

Location:
trunk/gtk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-inspector.c

    r3470 r3821  
    821821  g_free (pch);
    822822
    823   pch = ratiostr (stat->downloadedEver, stat->uploadedEver);
     823  pch = g_strdup_printf( "%.1f", stat->ratio );
    824824  gtk_label_set_text (GTK_LABEL(a->ratio_lb), pch);
    825825  g_free (pch);
  • trunk/gtk/tr_core.c

    r3771 r3821  
    270270        /* leechers, completedFromTracker, downloaded,    uploaded */
    271271        G_TYPE_INT,  G_TYPE_INT,           G_TYPE_UINT64, G_TYPE_UINT64,
    272         /* left,       TrTorrent object, ID for IPC */
    273         G_TYPE_UINT64, TR_TORRENT_TYPE,  G_TYPE_INT,
     272        /* ratio,      left,          TrTorrent object, ID for IPC */
     273        G_TYPE_FLOAT,  G_TYPE_UINT64, TR_TORRENT_TYPE,  G_TYPE_INT,
    274274    };
    275275
     
    563563                            MC_DOWN,        st->downloadedEver,
    564564                            MC_UP,          st->uploadedEver,
     565                            MC_RATIO,       st->ratio,
    565566                            MC_LEFT,        st->leftUntilDone,
    566567                            -1 );
  • trunk/gtk/tr_core.h

    r3771 r3821  
    182182  MC_PROG_C, MC_PROG_D, MC_DRATE, MC_URATE, MC_ETA, MC_PEERS,
    183183  MC_UPEERS, MC_DPEERS, MC_SEED, MC_LEECH, MC_DONE,
    184   MC_DOWN, MC_UP, MC_LEFT, MC_TORRENT, MC_ID,
     184  MC_DOWN, MC_UP, MC_RATIO, MC_LEFT, MC_TORRENT, MC_ID,
    185185  MC_ROW_COUNT
    186186};
  • trunk/gtk/tr_window.c

    r3449 r3821  
    120120{
    121121    char  * dlstr, * ulstr, * str, * marked;
    122     gfloat  prog, dl, ul;
     122    gfloat  prog, dl, ul, ratio;
    123123    guint64 down, up;
    124124
    125125    gtk_tree_model_get( model, iter, MC_PROG_D, &prog, MC_DRATE, &dl,
    126                         MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, -1 );
     126                        MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, MC_RATIO, &ratio, -1 );
    127127    prog = MAX( prog, 0.0 );
    128128    prog = MIN( prog, 1.0 );
     
    131131    if( 1.0 == prog )
    132132    {
    133         dlstr = ratiostr( down, up );
     133        dlstr = g_strdup_printf( "%.1f", ratio );
    134134        str = g_strdup_printf( _("Ratio: %s\nUL: %s"), dlstr, ulstr );
    135135    }
  • trunk/gtk/util.c

    r3648 r3821  
    122122}
    123123
    124 char *
    125 ratiostr(guint64 down, guint64 up) {
    126   double ratio;
    127 
    128   if(0 == up && 0 == down)
    129     return g_strdup(_("N/A"));
    130 
    131   if(0 == down)
    132     /* this is a UTF-8 infinity symbol */
    133     return g_strdup("\xE2\x88\x9E");
    134 
    135   ratio = (double)up / (double)down;
    136 
    137   return g_strdup_printf("%.*f", BESTDECIMAL(ratio), ratio);
    138 }
    139 
    140124gboolean
    141125mkdir_p(const char *name, mode_t mode)
  • trunk/gtk/util.h

    r3380 r3821  
    6363char *
    6464rfc822date (guint64 epoch_msec);
    65 
    66 /* returns a string representing the download ratio.
    67    the string must be g_free()d */
    68 char *
    69 ratiostr(guint64 down, guint64 up);
    7065
    7166/* create a directory and any missing parent directories */
Note: See TracChangeset for help on using the changeset viewer.