From 227c4f4621584ee9468b80f97cc088cabd58e9ce Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 2 Jun 2012 10:40:50 +0000 Subject: [PATCH] Also display the total amount copied --- src/copy.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/copy.c b/src/copy.c index 27e3466..b0ebc28 100644 --- a/src/copy.c +++ b/src/copy.c @@ -271,7 +271,8 @@ static int _single_symlink(Copy * copy, char const * src, char const * dst); static int _single_regular(Copy * copy, char const * src, char const * dst); static int _single_p(Copy * copy, char const * dst, struct stat const * st); static gboolean _single_timeout(gpointer data); -static void _single_unit(guint64 size, double * fraction, char const ** unit); +static void _single_unit(guint64 size, double * fraction, char const ** unit, + double * current); static int _copy_single(Copy * copy, char const * src, char const * dst) { @@ -595,6 +596,7 @@ static gboolean _single_timeout(gpointer data) char const * rate_unit; double total_fraction; char const * total_unit; + double current_fraction; if(copy->fpulse == 1) { @@ -617,15 +619,19 @@ static gboolean _single_timeout(gpointer data) } _single_unit((copy->cnt * 1024) / ((tv.tv_sec * 1000) + (tv.tv_usec / 1000)), - &rate_fraction, &rate_unit); - _single_unit(copy->cnt, &total_fraction, &total_unit); - snprintf(buf, sizeof(buf), "%.1f %s (%.1f %s/s)", total_fraction, - total_unit, rate_fraction, rate_unit); + &rate_fraction, &rate_unit, NULL); + current_fraction = copy->cnt; + _single_unit(copy->size, &total_fraction, &total_unit, + ¤t_fraction); + snprintf(buf, sizeof(buf), _("%.1f of %.1f %s (%.1f %s/s)"), + current_fraction, total_fraction, total_unit, + rate_fraction, rate_unit); gtk_label_set_text(GTK_LABEL(copy->fspeed), buf); return TRUE; } -static void _single_unit(guint64 size, double * fraction, char const ** unit) +static void _single_unit(guint64 size, double * fraction, char const ** unit, + double * current) { /* bytes */ *fraction = size; @@ -634,16 +640,22 @@ static void _single_unit(guint64 size, double * fraction, char const ** unit) return; /* kilobytes */ *fraction /= 1024; + if(current) + *current /= 1024; *unit = _("kB"); if(*fraction < 1024) return; /* megabytes */ *fraction /= 1024; + if(current) + *current /= 1024; *unit = _("MB"); if(*fraction < 1024) return; /* gigabytes */ *fraction /= 1024; + if(current) + *current /= 1024; *unit = _("GB"); }