summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-11-28 07:48:48 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-11-28 07:48:48 +0200
commite05a704154712184d73d85a3033e01337a11b380 (patch)
tree3aff6fcdda0a4a05dfc49e412eccd4dcc84dece9 /src
parent7c18495eb995f5c5997c201a8eef70b134fa5152 (diff)
Fixed page timestamp; 24-hour time preference
IssueID #349
Diffstat (limited to 'src')
-rw-r--r--src/app.c6
-rw-r--r--src/lang.c16
-rw-r--r--src/lang.h2
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h1
-rw-r--r--src/ui/documentwidget.c6
-rw-r--r--src/ui/util.c1
7 files changed, 31 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index 75e37a0b..a2de03ca 100644
--- a/src/app.c
+++ b/src/app.c
@@ -240,6 +240,7 @@ static iString *serializePrefs_App_(const iApp *d) {
240 const char * id; 240 const char * id;
241 const iBool *value; 241 const iBool *value;
242 } boolPrefs[] = { 242 } boolPrefs[] = {
243 { "prefs.time.24h", &d->prefs.time24h },
243 { "prefs.animate", &d->prefs.uiAnimations }, 244 { "prefs.animate", &d->prefs.uiAnimations },
244 { "prefs.font.smooth", &d->prefs.fontSmoothing }, 245 { "prefs.font.smooth", &d->prefs.fontSmoothing },
245 { "prefs.mono.gemini", &d->prefs.monospaceGemini }, 246 { "prefs.mono.gemini", &d->prefs.monospaceGemini },
@@ -2573,6 +2574,10 @@ iBool handleCommand_App(const char *cmd) {
2573 d->prefs.uiAnimations = arg_Command(cmd) != 0; 2574 d->prefs.uiAnimations = arg_Command(cmd) != 0;
2574 return iTrue; 2575 return iTrue;
2575 } 2576 }
2577 else if (equal_Command(cmd, "prefs.time.24h.changed")) {
2578 d->prefs.time24h = arg_Command(cmd) != 0;
2579 return iTrue;
2580 }
2576 else if (equal_Command(cmd, "saturation.set")) { 2581 else if (equal_Command(cmd, "saturation.set")) {
2577 d->prefs.saturation = (float) arg_Command(cmd) / 100.0f; 2582 d->prefs.saturation = (float) arg_Command(cmd) / 100.0f;
2578 if (!isFrozen) { 2583 if (!isFrozen) {
@@ -2892,6 +2897,7 @@ iBool handleCommand_App(const char *cmd) {
2892 updateScrollSpeedButtons_(dlg, mouse_ScrollType, d->prefs.smoothScrollSpeed[mouse_ScrollType]); 2897 updateScrollSpeedButtons_(dlg, mouse_ScrollType, d->prefs.smoothScrollSpeed[mouse_ScrollType]);
2893 updateScrollSpeedButtons_(dlg, keyboard_ScrollType, d->prefs.smoothScrollSpeed[keyboard_ScrollType]); 2898 updateScrollSpeedButtons_(dlg, keyboard_ScrollType, d->prefs.smoothScrollSpeed[keyboard_ScrollType]);
2894 updateDropdownSelection_LabelWidget(findChild_Widget(dlg, "prefs.uilang"), cstr_String(&d->prefs.strings[uiLanguage_PrefsString])); 2899 updateDropdownSelection_LabelWidget(findChild_Widget(dlg, "prefs.uilang"), cstr_String(&d->prefs.strings[uiLanguage_PrefsString]));
2900 setToggle_Widget(findChild_Widget(dlg, "prefs.time.24h"), d->prefs.time24h);
2895 updateDropdownSelection_LabelWidget( 2901 updateDropdownSelection_LabelWidget(
2896 findChild_Widget(dlg, "prefs.returnkey"), 2902 findChild_Widget(dlg, "prefs.returnkey"),
2897 format_CStr("returnkey.set arg:%d", d->prefs.returnKey)); 2903 format_CStr("returnkey.set arg:%d", d->prefs.returnKey));
diff --git a/src/lang.c b/src/lang.c
index 905601ca..831fa58f 100644
--- a/src/lang.c
+++ b/src/lang.c
@@ -22,6 +22,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
22 22
23#include "lang.h" 23#include "lang.h"
24#include "resources.h" 24#include "resources.h"
25#include "prefs.h"
26#include "app.h"
25 27
26#include <the_Foundation/sortedarray.h> 28#include <the_Foundation/sortedarray.h>
27#include <the_Foundation/string.h> 29#include <the_Foundation/string.h>
@@ -261,3 +263,17 @@ const char *format_Lang(const char *formatTextWithIds, ...) {
261 va_end(args); 263 va_end(args);
262 return cstr_Block(collect_Block(msg)); 264 return cstr_Block(collect_Block(msg));
263} 265}
266
267iString *timeFormatHourPreference_Lang(const char *formatMsgId) {
268 iString *str = newCStr_String(cstr_Lang(formatMsgId));
269 translate_Lang(str);
270 if (prefs_App()->time24h) {
271 replace_String(str, "%I", "%H");
272 replace_String(str, " %p", "");
273 replace_String(str, "%p", "");
274 }
275 else {
276 replace_String(str, "%H:%M", "%I:%M %p");
277 }
278 return str;
279}
diff --git a/src/lang.h b/src/lang.h
index e3e6c433..8ed5eca9 100644
--- a/src/lang.h
+++ b/src/lang.h
@@ -40,3 +40,5 @@ const char * cstrCount_Lang (const char *msgId, int count);
40const char * formatCStr_Lang (const char *formatMsgId, int count); 40const char * formatCStr_Lang (const char *formatMsgId, int count);
41const char * formatCStrs_Lang (const char *formatMsgId, size_t count); 41const char * formatCStrs_Lang (const char *formatMsgId, size_t count);
42const char * format_Lang (const char *formatTextWithIds, ...); 42const char * format_Lang (const char *formatTextWithIds, ...);
43
44iString * timeFormatHourPreference_Lang (const char *formatMsgId);
diff --git a/src/prefs.c b/src/prefs.c
index 956a75ae..10df9ade 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -43,6 +43,7 @@ void init_Prefs(iPrefs *d) {
43 d->sideIcon = iTrue; 43 d->sideIcon = iTrue;
44 d->hideToolbarOnScroll = iTrue; 44 d->hideToolbarOnScroll = iTrue;
45 d->pinSplit = 1; 45 d->pinSplit = 1;
46 d->time24h = iTrue;
46 d->returnKey = default_ReturnKeyBehavior; 47 d->returnKey = default_ReturnKeyBehavior;
47 d->hoverLink = iFalse; 48 d->hoverLink = iFalse;
48 d->smoothScrolling = iTrue; 49 d->smoothScrolling = iTrue;
diff --git a/src/prefs.h b/src/prefs.h
index d7712c9d..2fbff9de 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -73,6 +73,7 @@ struct Impl_Prefs {
73 iBool sideIcon; 73 iBool sideIcon;
74 iBool hideToolbarOnScroll; 74 iBool hideToolbarOnScroll;
75 int pinSplit; /* 0: no pinning, 1: left doc, 2: right doc */ 75 int pinSplit; /* 0: no pinning, 1: left doc, 2: right doc */
76 iBool time24h;
76 /* Behavior */ 77 /* Behavior */
77 int returnKey; 78 int returnKey;
78 iBool hoverLink; 79 iBool hoverLink;
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index c41c77d6..aac77572 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1038,10 +1038,12 @@ static void updateTimestampBuf_DocumentWidget_(const iDocumentWidget *d) {
1038 d->drawBufs->timestampBuf = NULL; 1038 d->drawBufs->timestampBuf = NULL;
1039 } 1039 }
1040 if (isValid_Time(&d->sourceTime)) { 1040 if (isValid_Time(&d->sourceTime)) {
1041 iString *fmt = timeFormatHourPreference_Lang("page.timestamp");
1041 d->drawBufs->timestampBuf = newRange_TextBuf( 1042 d->drawBufs->timestampBuf = newRange_TextBuf(
1042 uiLabel_FontId, 1043 uiLabel_FontId,
1043 white_ColorId, 1044 white_ColorId,
1044 range_String(collect_String(format_Time(&d->sourceTime, cstr_Lang("page.timestamp"))))); 1045 range_String(collect_String(format_Time(&d->sourceTime, cstr_String(fmt)))));
1046 delete_String(fmt);
1045 } 1047 }
1046 d->drawBufs->flags &= ~updateTimestampBuf_DrawBufsFlag; 1048 d->drawBufs->flags &= ~updateTimestampBuf_DrawBufsFlag;
1047} 1049}
@@ -4792,7 +4794,7 @@ static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
4792 bottomLeft_Rect(bounds), 4794 bottomLeft_Rect(bounds),
4793 init_I2(margin, 4795 init_I2(margin,
4794 -margin + -dbuf->timestampBuf->size.y + 4796 -margin + -dbuf->timestampBuf->size.y +
4795 iMax(0, d->scrollY.max + viewPos_DocumentWidget_(d)))), 4797 iMax(0, d->scrollY.max - pos_SmoothScroll(&d->scrollY)))),
4796 tmQuoteIcon_ColorId); 4798 tmQuoteIcon_ColorId);
4797 } 4799 }
4798 unsetClip_Paint(&p); 4800 unsetClip_Paint(&p);
diff --git a/src/ui/util.c b/src/ui/util.c
index 57fa9f3d..baa05082 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2507,6 +2507,7 @@ iWidget *makePreferences_Widget(void) {
2507 alignLeft_WidgetFlag), 2507 alignLeft_WidgetFlag),
2508 "prefs.uilang"); 2508 "prefs.uilang");
2509 } 2509 }
2510 addDialogToggle_(headings, values, "${prefs.time.24h}", "prefs.time.24h");
2510 } 2511 }
2511 /* User Interface. */ { 2512 /* User Interface. */ {
2512 appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.interface}", '2', &headings, &values); 2513 appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.interface}", '2', &headings, &values);