[gnome-disk-utility] Don't show sub-minute precision for restoring/creating disk images
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Don't show sub-minute precision for restoring/creating disk images
- Date: Fri, 13 Jul 2012 17:35:35 +0000 (UTC)
commit fce8b1d69618245f5b49b0c4358a933705751ad3
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Jul 13 13:34:21 2012 -0400
Don't show sub-minute precision for restoring/creating disk images
The seconds in the estimate seems to jumps around - it's much smoother
and better to just show the number of minutes.
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gducreatediskimagedialog.c | 2 +-
src/disks/gdurestorediskimagedialog.c | 2 +-
src/disks/gdutypes.h | 3 ++-
src/disks/gduutils.c | 26 +++++++++++++++++++++-----
4 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index 14c2221..8bad0a5 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -251,7 +251,7 @@ write_cb (GOutputStream *output_stream,
s2 = g_format_size (data->total_bytes_read);
s3 = g_format_size (data->block_size);
s4 = gdu_utils_format_duration_usec (usec_remaining,
- GDU_FORMAT_DURATION_FLAGS_NONE);
+ GDU_FORMAT_DURATION_FLAGS_NO_SECONDS);
s5 = g_format_size (bytes_per_sec);
s = g_strdup_printf ("%s of %s copied â %s remaining (%s/sec)", s2, s3, s4, s5);
g_free (s5);
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 03609e1..ecd845c 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -291,7 +291,7 @@ write_cb (GOutputStream *output_stream,
s2 = g_format_size (data->total_bytes_read);
s3 = g_format_size (data->file_size);
s4 = gdu_utils_format_duration_usec (usec_remaining,
- GDU_FORMAT_DURATION_FLAGS_NONE);
+ GDU_FORMAT_DURATION_FLAGS_NO_SECONDS);
s5 = g_format_size (bytes_per_sec);
s = g_strdup_printf ("%s of %s copied â %s remaining (%s/sec)", s2, s3, s4, s5);
g_free (s5);
diff --git a/src/disks/gdutypes.h b/src/disks/gdutypes.h
index c106d11..005d73e 100644
--- a/src/disks/gdutypes.h
+++ b/src/disks/gdutypes.h
@@ -55,7 +55,8 @@ typedef struct _GduEstimator GduEstimator;
typedef enum
{
GDU_FORMAT_DURATION_FLAGS_NONE = 0,
- GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION = (1<<0)
+ GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION = (1<<0),
+ GDU_FORMAT_DURATION_FLAGS_NO_SECONDS = (1<<1)
} GduFormatDurationFlags;
G_END_DECLS
diff --git a/src/disks/gduutils.c b/src/disks/gduutils.c
index 5893311..73264f1 100644
--- a/src/disks/gduutils.c
+++ b/src/disks/gduutils.c
@@ -500,13 +500,29 @@ gdu_utils_format_duration_usec (guint64 usec,
}
else if (minutes > 0)
{
- /* Translators: Used for durations less than one hour but greater than one minute. First %s is number of minutes, second %s is seconds */
- ret = g_strdup_printf (C_("duration-minute-to-hour", "%s and %s"), minutes_str, seconds_str);
+ if (flags & GDU_FORMAT_DURATION_FLAGS_NO_SECONDS)
+ {
+ ret = g_strdup (minutes_str);
+ }
+ else
+ {
+ /* Translators: Used for durations less than one hour but greater than one minute. First %s is number of minutes, second %s is seconds */
+ ret = g_strdup_printf (C_("duration-minute-to-hour", "%s and %s"), minutes_str, seconds_str);
+ }
}
- else if (seconds > 0 || !(flags & GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION))
+ else if (seconds > 0 ||
+ !(flags & GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION) ||
+ (flags & GDU_FORMAT_DURATION_FLAGS_NO_SECONDS))
{
- /* Translators: Used for durations less than one minute byte greater than one second. First %s is number of seconds */
- ret = g_strdup_printf (C_("duration-second-to-minute", "%s"), seconds_str);
+ if (flags & GDU_FORMAT_DURATION_FLAGS_NO_SECONDS)
+ {
+ ret = g_strdup (C_("duration", "Less than a minute"));
+ }
+ else
+ {
+ /* Translators: Used for durations less than one minute byte greater than one second. First %s is number of seconds */
+ ret = g_strdup_printf (C_("duration-second-to-minute", "%s"), seconds_str);
+ }
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]