diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-16 14:07:46 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-16 14:07:46 +0200 |
commit | 388a762a0f79b75e0c5e5b24ecb8e764b105d50c (patch) | |
tree | 566629233049f11636d64c806262da3d183f22e7 /src/app.c | |
parent | 731672c70665c7f24b416818a2137b5ee2e3ee19 (diff) |
Customizable navbar button actions
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -248,6 +248,9 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
248 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); | 248 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); |
249 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); | 249 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); |
250 | appendFormat_String(str, "returnkey.set arg:%d\n", d->prefs.returnKey); | 250 | appendFormat_String(str, "returnkey.set arg:%d\n", d->prefs.returnKey); |
251 | for (size_t i = 0; i < iElemCount(d->prefs.navbarActions); i++) { | ||
252 | appendFormat_String(str, "navbar.action.set arg:%d button:%d\n", d->prefs.navbarActions[i], i); | ||
253 | } | ||
251 | #if defined (iPlatformMobile) | 254 | #if defined (iPlatformMobile) |
252 | appendFormat_String(str, "toolbar.action.set arg:%d button:0\n", d->prefs.toolbarActions[0]); | 255 | appendFormat_String(str, "toolbar.action.set arg:%d button:0\n", d->prefs.toolbarActions[0]); |
253 | appendFormat_String(str, "toolbar.action.set arg:%d button:1\n", d->prefs.toolbarActions[1]); | 256 | appendFormat_String(str, "toolbar.action.set arg:%d button:1\n", d->prefs.toolbarActions[1]); |
@@ -961,6 +964,8 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
961 | if (!loadState_App_(d)) { | 964 | if (!loadState_App_(d)) { |
962 | postCommand_Root(NULL, "open url:about:help"); | 965 | postCommand_Root(NULL, "open url:about:help"); |
963 | } | 966 | } |
967 | postCommand_App("~navbar.actions.changed"); | ||
968 | postCommand_App("~toolbar.actions.changed"); | ||
964 | postCommand_Root(NULL, "~window.unfreeze"); | 969 | postCommand_Root(NULL, "~window.unfreeze"); |
965 | postCommand_Root(NULL, "font.reset"); | 970 | postCommand_Root(NULL, "font.reset"); |
966 | d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL); | 971 | d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL); |
@@ -2291,10 +2296,20 @@ iBool handleCommand_App(const char *cmd) { | |||
2291 | } | 2296 | } |
2292 | return iTrue; | 2297 | return iTrue; |
2293 | } | 2298 | } |
2299 | else if (equal_Command(cmd, "navbar.action.set")) { | ||
2300 | d->prefs.navbarActions[iClamp(argLabel_Command(cmd, "button"), 0, maxNavbarActions_Prefs - 1)] = | ||
2301 | iClamp(arg_Command(cmd), 0, max_ToolbarAction - 1); | ||
2302 | if (!isFrozen) { | ||
2303 | postCommand_App("~navbar.actions.changed"); | ||
2304 | } | ||
2305 | return iTrue; | ||
2306 | } | ||
2294 | else if (equal_Command(cmd, "toolbar.action.set")) { | 2307 | else if (equal_Command(cmd, "toolbar.action.set")) { |
2295 | d->prefs.toolbarActions[iClamp(argLabel_Command(cmd, "button"), 0, 1)] = | 2308 | d->prefs.toolbarActions[iClamp(argLabel_Command(cmd, "button"), 0, 1)] = |
2296 | iClamp(arg_Command(cmd), 0, max_ToolbarAction - 1); | 2309 | iClamp(arg_Command(cmd), 0, max_ToolbarAction - 1); |
2297 | postCommand_App("~toolbar.actions.changed"); | 2310 | if (!isFrozen) { |
2311 | postCommand_App("~toolbar.actions.changed"); | ||
2312 | } | ||
2298 | return iTrue; | 2313 | return iTrue; |
2299 | } | 2314 | } |
2300 | else if (equal_Command(cmd, "translation.languages")) { | 2315 | else if (equal_Command(cmd, "translation.languages")) { |