[Commits] [SCM] claws branch, master, updated. 3.17.0-6-g043c413

wwp at claws-mail.org wwp at claws-mail.org
Tue Aug 21 10:20:57 CEST 2018


The branch, master has been updated
       via  043c4130bb7c2fef2107ac999c00406d406ea806 (commit)
      from  c4b436bcd0e31fa1c2a71c0725a775af3d04a06e (commit)

Summary of changes:
 src/inc.c |   36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 043c4130bb7c2fef2107ac999c00406d406ea806
Author: wwp <subscript at free.fr>
Date:   Tue Aug 21 10:20:05 2018 +0200

    Fix wrong time unit shown in offline-override dialog (IMAP), and
    while we're at it, use the most appropriate reduced number+unit.

diff --git a/src/inc.c b/src/inc.c
index 2415e46..ed681fb 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -1596,7 +1596,7 @@ void inc_account_autocheck_timer_set_interval(PrefsAccount *account)
 
 gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
 {
-	int length = 10; /* minutes */
+	gint length = 10; /* seconds */
 	gint answer = G_ALERTDEFAULT;
 
 #ifdef HAVE_NETWORKMANAGER_SUPPORT
@@ -1606,7 +1606,7 @@ gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
 #endif
 
 	if (prefs_common.autochk_newmail)
-		length = prefs_common.autochk_itv; /* minutes */
+		length = prefs_common.autochk_itv; /* seconds */
 
 	if (force_ask) {
 		inc_offline_overridden_no = (time_t)0;
@@ -1620,13 +1620,37 @@ gboolean inc_offline_should_override(gboolean force_ask, const gchar *msg)
 		else if (time(NULL) - inc_offline_overridden_no < length * 60) /* seconds */
 			 return FALSE;
 
-		if (!force_ask)
+		if (!force_ask) {
+			gchar *unit = _("seconds");
+
+			/* show the offline override time (length) using the must appropriate unit:
+			   the biggest unit possible (hours, minutes, seconds), provided that there
+			   is not inferior unit involved: 1 hour, 150 minutes, 25 minutes, 90 minutes,
+			   30 seconds, 90 seconds. */
+			if ((length / 3600) > 0) { /* hours? */
+				if (((length % 3600) % 60) == 0) { /* no seconds left? */
+					if ((length % 3600) > 0) { /* minutes left? */
+						length = length / 60;
+						unit = ngettext("minute", "minutes", length);
+					} else {
+						length = length / 3600;
+						unit = ngettext("hour", "hours", length);
+					}
+				} /* else: seconds */
+			} else {
+				if ((length / 60) > 0) { /* minutes left? */
+					if ((length % 60) == 0) {
+						length = length / 60;
+						unit = ngettext("minute", "minutes", length);
+					}
+				} /* else: seconds */
+			}
 			tmp = g_strdup_printf(
-				_("%s%sYou're working offline. Override for %d minutes?"),
+				_("%s%sYou're working offline. Override for %d %s?"),
 				msg?msg:"", 
 				msg?"\n\n":"",
-				length);
-		else
+				length, unit);
+		} else
 			tmp = g_strdup_printf(
 				_("%s%sYou're working offline. Override?"),
 				msg?msg:"", 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list