diff options
author | ZenWalker <[email protected]> | 2017-09-06 16:22:42 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-09-10 11:55:55 +0200 |
commit | dc78be7f55cd093c1be8dcc04d8231ba44d94399 (patch) | |
tree | d322383367140e3da9f9c1533bfc99b85b9f269c /src/mate-screensaver-preferences.c | |
parent | 52d6486da4529cb48c414c0434722e589c19820a (diff) | |
download | mate-screensaver-dc78be7f55cd093c1be8dcc04d8231ba44d94399.tar.bz2 mate-screensaver-dc78be7f55cd093c1be8dcc04d8231ba44d94399.tar.xz |
Fix: idle slider display in all languages
Fixes #101
This is a squashed commit from master
Diffstat (limited to 'src/mate-screensaver-preferences.c')
-rw-r--r-- | src/mate-screensaver-preferences.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c index ad38b36..0a9f9a6 100644 --- a/src/mate-screensaver-preferences.c +++ b/src/mate-screensaver-preferences.c @@ -935,6 +935,8 @@ time_to_string_text (long time) char *secs, *mins, *hours, *string; int sec, min, hour; + int inc_len, len_minutes; + sec = time % 60; time = time - sec; min = (time % (60 * 60)) / 60; @@ -950,6 +952,43 @@ time_to_string_text (long time) secs = g_strdup_printf (ngettext ("%d second", "%d seconds", sec), sec); + inc_len = strlen (g_strdup_printf (_("%s %s"), + g_strdup_printf (ngettext ("%d hour", + "%d hours", 1), 1), + g_strdup_printf (ngettext ("%d minute", + "%d minutes", 59), 59))) - 1; + + len_minutes = 0; + + for (int n = 2; n < 60; n++) + { + if (n < 10) + { + if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", n), n), NULL)) - 2) > len_minutes) + + len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", n), n), NULL)) - 2; + } + else + { + if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", n), n), NULL)) - 3) > len_minutes) + + len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", n), n), NULL)) - 3; + } + } + + if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", 1), 1), NULL)) - 2) > len_minutes) + + len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute", + "%d minutes", 1), 1), NULL)) - 2; + + if (len_minutes < 1) + len_minutes = 1; + if (hour > 0) { if (sec > 0) @@ -979,6 +1018,36 @@ time_to_string_text (long time) { /* minutes */ string = g_strdup_printf (_("%s"), mins); + + if (min < 10) + { + if (min == 1) + while (strlen (string) != (len_minutes + inc_len + 3)) + { + if (strlen (string) % 2 == 0) + string = g_strconcat (string, " ", NULL); + else + string = g_strconcat (" " , string, NULL); + } + else + while (strlen (string) != (len_minutes + inc_len)) + { + if (strlen (string) % 2 == 0) + string = g_strconcat (string, " ", NULL); + else + string = g_strconcat (" " , string, NULL); + } + } + else + { + while (strlen (string) != (len_minutes + inc_len - 1)) + { + if (strlen (string) % 2 == 0) + string = g_strconcat (string, " ", NULL); + else + string = g_strconcat (" " , string, NULL); + } + } } } else |