Changeset 525 for trunk/gtk


Ignore:
Timestamp:
Jul 4, 2006, 10:31:14 PM (15 years ago)
Author:
joshe
Message:

Move the ETA cap of 99:59:59 from libtransmission to the MacOS X GUI.
Display the ETA better in the GTK GUI.

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r468 r525  
    679679dfname(GtkTreeViewColumn *col SHUTUP, GtkCellRenderer *rend,
    680680       GtkTreeModel *model, GtkTreeIter *iter, gpointer gdata SHUTUP) {
    681   char *name, *mb, *terr, *str, *top, *bottom;
     681  char *name, *mb, *terr, *str, *top, *bottom, *timestr;
    682682  guint64 size;
    683683  gfloat prog;
     
    701701  else if(status & TR_STATUS_DOWNLOAD) {
    702702    if(0 > eta)
    703       top = g_strdup_printf(_("Finishing in --:--:-- (%.1f%%)"), prog);
    704     else
    705       top = g_strdup_printf(_("Finishing in %02i:%02i:%02i (%.1f%%)"),
    706                             eta / 60 / 60, eta / 60 % 60, eta % 60, prog);
     703      top = g_strdup_printf(_("Stalled (%.1f%%)"), prog);
     704    else {
     705      timestr = readabletime(eta);
     706      top = g_strdup_printf(_("Finishing in %s (%.1f%%)"), timestr, prog);
     707      g_free(timestr);
     708    }
    707709  }
    708710  else if(status & TR_STATUS_SEED)
  • trunk/gtk/util.c

    r320 r525  
    8585}
    8686
     87#define SECONDS(s)              ((s) % 60)
     88#define MINUTES(s)              ((s) / 60 % 60)
     89#define HOURS(s)                ((s) / 60 / 60 % 24)
     90#define DAYS(s)                 ((s) / 60 / 60 / 24 % 7)
     91#define WEEKS(s)                ((s) / 60 / 60 / 24 / 7)
     92
     93char *
     94readabletime(int secs) {
     95  if(60 > secs)
     96    return g_strdup_printf(_("%i %s"),
     97      SECONDS(secs), ngettext("second", "seconds", SECONDS(secs)));
     98  else if(60 * 60 > secs)
     99    return g_strdup_printf(_("%i %s %i %s"),
     100      MINUTES(secs), ngettext("minute", "minutes", MINUTES(secs)),
     101      SECONDS(secs), ngettext("second", "seconds", SECONDS(secs)));
     102  else if(60 * 60 * 24 > secs)
     103    return g_strdup_printf(_("%i %s %i %s"),
     104      HOURS(secs),   ngettext("hour", "hours", HOURS(secs)),
     105      MINUTES(secs), ngettext("minute", "minutes", MINUTES(secs)));
     106  else if(60 * 60 * 24 * 7 > secs)
     107    return g_strdup_printf(_("%i %s %i %s"),
     108      DAYS(secs),    ngettext("day", "days", DAYS(secs)),
     109      HOURS(secs),   ngettext("hour", "hours", HOURS(secs)));
     110  else
     111    return g_strdup_printf(_("%i %s %i %s"),
     112      WEEKS(secs),   ngettext("week", "weeks", WEEKS(secs)),
     113      DAYS(secs),    ngettext("hour", "hours", DAYS(secs)));
     114}
     115
    87116char *
    88117ratiostr(guint64 down, guint64 up) {
  • trunk/gtk/util.h

    r320 r525  
    5959char *
    6060readablesize(guint64 size);
     61
     62/* return a human-readable string for the time given in seconds.
     63   the string must be g_free()d */
     64char *
     65readabletime(int secs);
    6166
    6267/* returns a string representing the download ratio.
Note: See TracChangeset for help on using the changeset viewer.