Changeset 131


Ignore:
Timestamp:
Feb 24, 2006, 2:07:38 PM (16 years ago)
Author:
joshe
Message:

GTK:

Adjust the number of decimals shown with sizes based on the number size,
as is done with the ratio.

Location:
trunk/gtk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/dialogs.c

    r117 r131  
    418418              sb[id].info.trackerAddress, sb[id].info.trackerPort));
    419419  INFOLINE(table, ii, _("Announce:"), sb[id].info.trackerAnnounce);
    420   INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize, 1));
     420  INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize));
    421421  INFOLINEF(table, ii, "%i", _("Pieces:"), sb[id].info.pieceCount);
    422   INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize, 1));
     422  INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize));
    423423  if(0 > sb[id].seeders)
    424424    INFOLINE(table, ii, _("Seeders:"), _("?"));
     
    433433
    434434  INFOLINE(table, ii, _("Directory:"), sb[id].folder);
    435   INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded, 1));
    436   INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded, 1));
     435  INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded));
     436  INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded));
    437437
    438438  INFOSEP(table, ii);
  • trunk/gtk/main.c

    r130 r131  
    683683  if(0 > dpeers)
    684684    dpeers = 0;
    685   mb = readablesize(size, 1);
     685  mb = readablesize(size);
    686686  prog *= 100;
    687687
     
    745745    prog = 1.0;
    746746
    747   ulstr = readablesize(ul * 1024.0, 2);
     747  ulstr = readablesize(ul * 1024.0);
    748748  if(1.0 == prog) {
    749749    dlstr = ratiostr(down, up);
    750750    str = g_strdup_printf(_("Ratio: %s\nUL: %s/s"), dlstr, ulstr);
    751751  } else {
    752     dlstr = readablesize(dl * 1024.0, 2);
     752    dlstr = readablesize(dl * 1024.0);
    753753    str = g_strdup_printf(_("DL: %s/s\nUL: %s/s"), dlstr, ulstr);
    754754  }
     
    797797  /* update the status bar */
    798798  tr_torrentRates(data->tr, &up, &down);
    799   downstr = readablesize(down * 1024.0, 2);
    800   upstr = readablesize(up * 1024.0, 2);
     799  downstr = readablesize(down * 1024.0);
     800  upstr = readablesize(up * 1024.0);
    801801  str = g_strdup_printf(_("     Total DL: %s/s     Total UL: %s/s"),
    802802                        upstr, downstr);
  • trunk/gtk/util.c

    r125 r131  
    3737#include "util.h"
    3838
     39#define BESTDECIMAL(d)          (10.0 > (d) ? 2 : (100.0 > (d) ? 1 : 0))
     40
    3941static void
    4042sigexithandler(int sig);
     
    6567
    6668char *
    67 readablesize(guint64 size, int decimals) {
     69readablesize(guint64 size) {
    6870  unsigned int ii;
    6971  double small = size;
     
    7779  }
    7880
    79   return g_strdup_printf("%.*f %s", decimals, small, gettext(sizestrs[ii]));
     81  return g_strdup_printf("%.*f %s", BESTDECIMAL(small), small,
     82                         gettext(sizestrs[ii]));
    8083}
    8184
  • trunk/gtk/util.h

    r125 r131  
    4949strbool(const char *str);
    5050
    51 /* return a human-readable string for the size given in bytes with the
    52    requested number of decimal places.  the string must be g_free()d */
     51/* return a human-readable string for the size given in bytes.
     52   the string must be g_free()d */
    5353char *
    54 readablesize(guint64 size, int decimals);
     54readablesize(guint64 size);
    5555
    5656/* returns a string representing the download ratio.
Note: See TracChangeset for help on using the changeset viewer.