[totem/improve-time-period-stringification] properties: Improve how we print time periods



commit aecdfa351ce34cbe72d8a4f25db607caf5cfa16e
Author: Matthew Leeds <matthew leeds endlessm com>
Date:   Fri Feb 14 16:42:40 2020 -0800

    properties: Improve how we print time periods
    
    Print e.g. "2 minutes" instead of "2 minutes 0 seconds".

 .../properties/bacon-video-widget-properties.c     | 23 ++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/properties/bacon-video-widget-properties.c 
b/src/plugins/properties/bacon-video-widget-properties.c
index cebf39450..1cfbf0429 100644
--- a/src/plugins/properties/bacon-video-widget-properties.c
+++ b/src/plugins/properties/bacon-video-widget-properties.c
@@ -159,11 +159,26 @@ time_to_string_text (gint64 msecs)
 
        if (hour > 0)
        {
-               /* 5 hours 2 minutes 12 seconds */
-               string = g_strdup_printf (C_("time", "%s %s %s"), hours, mins, secs);
+               if (min > 0 && sec > 0)
+               {
+                       /* 5 hours 2 minutes 12 seconds */
+                       string = g_strdup_printf (C_("hours minutes seconds", "%s %s %s"), hours, mins, secs);
+               } else if (min > 0) {
+                       /* 5 hours 2 minutes */
+                       string = g_strdup_printf (C_("hours minutes", "%s %s"), hours, mins);
+               } else {
+                       /* 5 hours */
+                       string = g_strdup_printf (C_("hours", "%s"), hours);
+               }
        } else if (min > 0) {
-               /* 2 minutes 12 seconds */
-               string = g_strdup_printf (C_("time", "%s %s"), mins, secs);
+               if (sec > 0)
+               {
+                       /* 2 minutes 12 seconds */
+                       string = g_strdup_printf (C_("minutes seconds", "%s %s"), mins, secs);
+               } else {
+                       /* 2 minutes */
+                       string = g_strdup_printf (C_("minutes", "%s"), mins);
+               }
        } else if (sec > 0) {
                /* 10 seconds */
                string = g_strdup (secs);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]