[gnome-control-center/improve-time-period-stringification] common: Improve how we print time periods
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/improve-time-period-stringification] common: Improve how we print time periods
- Date: Thu, 27 Feb 2020 00:25:17 +0000 (UTC)
commit 2f5811b8b13db491185d0022872528ccc0bc0642
Author: Matthew Leeds <matthew leeds endlessm com>
Date: Fri Feb 14 16:44:26 2020 -0800
common: Improve how we print time periods
Print e.g. "2 minutes" instead of "2 minutes 0 seconds". Also, update
the path in Totem from which this was copied. The MR to make the same
change in Totem is here:
https://gitlab.gnome.org/GNOME/totem/merge_requests/134
panels/common/cc-util.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/panels/common/cc-util.c b/panels/common/cc-util.c
index d37846a28..9418d5607 100644
--- a/panels/common/cc-util.c
+++ b/panels/common/cc-util.c
@@ -145,7 +145,7 @@ cc_util_get_smart_date (GDateTime *date)
}
}
-/* Copied from src/properties/bacon-video-widget-properties.c
+/* Copied from src/plugins/properties/bacon-video-widget-properties.c
* in totem */
char *
cc_util_time_to_string_text (gint64 msecs)
@@ -168,13 +168,34 @@ cc_util_time_to_string_text (gint64 msecs)
if (hour > 0)
{
- /* 5 hours 2 minutes 12 seconds */
- return g_strdup_printf (C_("time", "%s %s %s"), hours, mins, secs);
+ if (min > 0 && sec > 0)
+ {
+ /* 5 hours 2 minutes 12 seconds */
+ return g_strdup_printf (C_("hours minutes seconds", "%s %s %s"), hours, mins, secs);
+ }
+ else if (min > 0)
+ {
+ /* 5 hours 2 minutes */
+ return g_strdup_printf (C_("hours minutes", "%s %s"), hours, mins);
+ }
+ else
+ {
+ /* 5 hours */
+ return g_strdup_printf (C_("hours", "%s"), hours);
+ }
}
else if (min > 0)
{
- /* 2 minutes 12 seconds */
- return g_strdup_printf (C_("time", "%s %s"), mins, secs);
+ if (sec > 0)
+ {
+ /* 2 minutes 12 seconds */
+ return g_strdup_printf (C_("minutes seconds", "%s %s"), mins, secs);
+ }
+ else
+ {
+ /* 2 minutes */
+ return g_strdup_printf (C_("minutes", "%s"), mins);
+ }
}
else if (sec > 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]