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 | |
parent | 731672c70665c7f24b416818a2137b5ee2e3ee19 (diff) |
Customizable navbar button actions
-rw-r--r-- | res/about/version.gmi | 3 | ||||
-rw-r--r-- | src/app.c | 17 | ||||
-rw-r--r-- | src/defs.h | 5 | ||||
-rw-r--r-- | src/fontpack.c | 2 | ||||
-rw-r--r-- | src/prefs.c | 4 | ||||
-rw-r--r-- | src/prefs.h | 3 | ||||
-rw-r--r-- | src/ui/mobile.c | 3 | ||||
-rw-r--r-- | src/ui/root.c | 82 | ||||
-rw-r--r-- | src/ui/util.c | 4 |
9 files changed, 100 insertions, 23 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi index 3745a7cb..d5e701c3 100644 --- a/res/about/version.gmi +++ b/res/about/version.gmi | |||
@@ -9,6 +9,7 @@ | |||
9 | ## 1.10 | 9 | ## 1.10 |
10 | New features: | 10 | New features: |
11 | * macOS: Trackpad swipe navigation. | 11 | * macOS: Trackpad swipe navigation. |
12 | * Customizable navbar actions. Right-click on a button to change its action. (Identity and hamburger buttons cannot be changed.) | ||
12 | * Identity toolbar menu can be used to switch between alternate identities. If you have used multiple identities on one site, this makes it more convenient to switch between them. | 13 | * Identity toolbar menu can be used to switch between alternate identities. If you have used multiple identities on one site, this makes it more convenient to switch between them. |
13 | * Added "Edit Page with Titan": opens the upload dialog with current page's content prefilled. | 14 | * Added "Edit Page with Titan": opens the upload dialog with current page's content prefilled. |
14 | * Added "Paste Preceding Line" in the input prompt dialog. Potential use cases include user-editable sections on a page and suggested/example input values. | 15 | * Added "Paste Preceding Line" in the input prompt dialog. Potential use cases include user-editable sections on a page and suggested/example input values. |
@@ -35,6 +36,8 @@ Changes and enhancements: | |||
35 | Fixes: | 36 | Fixes: |
36 | * Fixed a history caching issue: if there were multiple instances of the same URL in history, only the latest one's content would be used when navigating back/forward. | 37 | * Fixed a history caching issue: if there were multiple instances of the same URL in history, only the latest one's content would be used when navigating back/forward. |
37 | * Fixed handling of reserved characters in URLs (cf. RFC 3986, section 2.2). | 38 | * Fixed handling of reserved characters in URLs (cf. RFC 3986, section 2.2). |
39 | * Fixed the copy/paste context menu not showing in input fields. | ||
40 | * Fixed duplicated warnings showing in the page banner. | ||
38 | * Fixed very narrow input fields causing the app to hang. | 41 | * Fixed very narrow input fields causing the app to hang. |
39 | * Fixed initial scroll position in multiline input fields. | 42 | * Fixed initial scroll position in multiline input fields. |
40 | * Fixed lookup results list becoming too narrow. | 43 | * Fixed lookup results list becoming too narrow. |
@@ -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")) { |
@@ -80,6 +80,7 @@ enum iToolbarAction { | |||
80 | editPage_ToolbarAction = 10, | 80 | editPage_ToolbarAction = 10, |
81 | findText_ToolbarAction = 11, | 81 | findText_ToolbarAction = 11, |
82 | settings_ToolbarAction = 12, | 82 | settings_ToolbarAction = 12, |
83 | sidebar_ToolbarAction = 13, /* desktop only */ | ||
83 | max_ToolbarAction | 84 | max_ToolbarAction |
84 | }; | 85 | }; |
85 | 86 | ||
@@ -116,7 +117,7 @@ iLocalDef int acceptKeyMod_ReturnKeyBehavior(int behavior) { | |||
116 | 117 | ||
117 | #define menu_Icon "\U0001d362" | 118 | #define menu_Icon "\U0001d362" |
118 | #define rightArrowhead_Icon "\u27a4" | 119 | #define rightArrowhead_Icon "\u27a4" |
119 | #define leftArrowhead_Icon "\u27a4" | 120 | #define leftArrowhead_Icon "\u2b9c" |
120 | #define warning_Icon "\u26a0" | 121 | #define warning_Icon "\u26a0" |
121 | #define openLock_Icon "\U0001f513" | 122 | #define openLock_Icon "\U0001f513" |
122 | #define closedLock_Icon "\U0001f512" | 123 | #define closedLock_Icon "\U0001f512" |
@@ -124,7 +125,7 @@ iLocalDef int acceptKeyMod_ReturnKeyBehavior(int behavior) { | |||
124 | #define reload_Icon "\U0001f503" | 125 | #define reload_Icon "\U0001f503" |
125 | #define backArrow_Icon "\U0001f870" | 126 | #define backArrow_Icon "\U0001f870" |
126 | #define forwardArrow_Icon "\U0001f872" | 127 | #define forwardArrow_Icon "\U0001f872" |
127 | #define upArrow_Icon "\u2191" | 128 | #define upArrow_Icon "\U0001f871" |
128 | #define upArrowBar_Icon "\u2912" | 129 | #define upArrowBar_Icon "\u2912" |
129 | #define downArrowBar_Icon "\u2913" | 130 | #define downArrowBar_Icon "\u2913" |
130 | #define rightArrowWhite_Icon "\u21e8" | 131 | #define rightArrowWhite_Icon "\u21e8" |
diff --git a/src/fontpack.c b/src/fontpack.c index 79f35526..a440234e 100644 --- a/src/fontpack.c +++ b/src/fontpack.c | |||
@@ -818,7 +818,7 @@ const iArray *actions_FontPack(const iFontPack *d, iBool showInstalled) { | |||
818 | pushBack_Array( | 818 | pushBack_Array( |
819 | items, | 819 | items, |
820 | &(iMenuItem){ format_Lang(isEnabled ? close_Icon " ${fontpack.disable}" | 820 | &(iMenuItem){ format_Lang(isEnabled ? close_Icon " ${fontpack.disable}" |
821 | : leftArrowhead_Icon " ${fontpack.enable}", | 821 | : "${fontpack.enable}", |
822 | fpId), | 822 | fpId), |
823 | 0, | 823 | 0, |
824 | 0, | 824 | 0, |
diff --git a/src/prefs.c b/src/prefs.c index 3aa05f01..6164ca25 100644 --- a/src/prefs.c +++ b/src/prefs.c | |||
@@ -44,6 +44,10 @@ void init_Prefs(iPrefs *d) { | |||
44 | d->uiAnimations = iTrue; | 44 | d->uiAnimations = iTrue; |
45 | d->uiScale = 1.0f; /* default set elsewhere */ | 45 | d->uiScale = 1.0f; /* default set elsewhere */ |
46 | d->zoomPercent = 100; | 46 | d->zoomPercent = 100; |
47 | d->navbarActions[0] = back_ToolbarAction; | ||
48 | d->navbarActions[1] = forward_ToolbarAction; | ||
49 | d->navbarActions[2] = sidebar_ToolbarAction; | ||
50 | d->navbarActions[3] = home_ToolbarAction; | ||
47 | #if defined (iPlatformAndroidMobile) | 51 | #if defined (iPlatformAndroidMobile) |
48 | /* Android has a system-wide back button so no need to have a duplicate. */ | 52 | /* Android has a system-wide back button so no need to have a duplicate. */ |
49 | d->toolbarActions[0] = closeTab_ToolbarAction; | 53 | d->toolbarActions[0] = closeTab_ToolbarAction; |
diff --git a/src/prefs.h b/src/prefs.h index 43f7fc0e..ea864f51 100644 --- a/src/prefs.h +++ b/src/prefs.h | |||
@@ -101,6 +101,8 @@ enum iPrefsBool { | |||
101 | max_PrefsBool | 101 | max_PrefsBool |
102 | }; | 102 | }; |
103 | 103 | ||
104 | #define maxNavbarActions_Prefs 4 | ||
105 | |||
104 | /* TODO: Use a systematic command naming convention for notifications. */ | 106 | /* TODO: Use a systematic command naming convention for notifications. */ |
105 | 107 | ||
106 | struct Impl_Prefs { | 108 | struct Impl_Prefs { |
@@ -159,6 +161,7 @@ struct Impl_Prefs { | |||
159 | enum iColorAccent accent; | 161 | enum iColorAccent accent; |
160 | /* Window and User Interface */ | 162 | /* Window and User Interface */ |
161 | float uiScale; | 163 | float uiScale; |
164 | enum iToolbarAction navbarActions[maxNavbarActions_Prefs]; | ||
162 | enum iToolbarAction toolbarActions[2]; | 165 | enum iToolbarAction toolbarActions[2]; |
163 | /* Document presentation */ | 166 | /* Document presentation */ |
164 | int zoomPercent; | 167 | int zoomPercent; |
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index e34cad3a..cf955423 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -50,7 +50,8 @@ const iToolbarActionSpec toolbarActions_Mobile[max_ToolbarAction] = { | |||
50 | { upload_Icon, "${menu.page.upload}", "document.upload" }, | 50 | { upload_Icon, "${menu.page.upload}", "document.upload" }, |
51 | { edit_Icon, "${menu.page.upload.edit}", "document.upload copy:1" }, | 51 | { edit_Icon, "${menu.page.upload.edit}", "document.upload copy:1" }, |
52 | { magnifyingGlass_Icon, "${menu.find}", "focus.set id:find.input" }, | 52 | { magnifyingGlass_Icon, "${menu.find}", "focus.set id:find.input" }, |
53 | { gear_Icon, "${menu.settings}", "preferences" }, | 53 | { gear_Icon, "${menu.settings}", "preferences" }, |
54 | { leftHalf_Icon, "${menu.sidebar.left}", "sidebar.toggle" }, | ||
54 | }; | 55 | }; |
55 | 56 | ||
56 | iBool isUsingPanelLayout_Mobile(void) { | 57 | iBool isUsingPanelLayout_Mobile(void) { |
diff --git a/src/ui/root.c b/src/ui/root.c index 0a366996..a3c2e0ae 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -596,11 +596,17 @@ static void updateNavBarIdentity_(iWidget *navBar) { | |||
596 | } | 596 | } |
597 | 597 | ||
598 | static void updateNavDirButtons_(iWidget *navBar) { | 598 | static void updateNavDirButtons_(iWidget *navBar) { |
599 | const iHistory *history = history_DocumentWidget(document_App()); | 599 | iBeginCollect(); |
600 | iBool atOldest = atOldest_History(history); | 600 | const iHistory *history = history_DocumentWidget(document_App()); |
601 | iBool atNewest = atNewest_History(history); | 601 | const iBool atOldest = atOldest_History(history); |
602 | setFlags_Widget(findChild_Widget(navBar, "navbar.back"), disabled_WidgetFlag, atOldest); | 602 | const iBool atNewest = atNewest_History(history); |
603 | setFlags_Widget(findChild_Widget(navBar, "navbar.forward"), disabled_WidgetFlag, atNewest); | 603 | /* Reset button state. */ |
604 | for (size_t i = 0; i < maxNavbarActions_Prefs; i++) { | ||
605 | const char *id = format_CStr("navbar.action%d", i + 1); | ||
606 | setFlags_Widget(findChild_Widget(navBar, id), disabled_WidgetFlag, iFalse); | ||
607 | } | ||
608 | setFlags_Widget(as_Widget(findMenuItem_Widget(navBar, "navigate.back")), disabled_WidgetFlag, atOldest); | ||
609 | setFlags_Widget(as_Widget(findMenuItem_Widget(navBar, "navigate.forward")), disabled_WidgetFlag, atNewest); | ||
604 | iWidget *toolBar = findWidget_App("toolbar"); | 610 | iWidget *toolBar = findWidget_App("toolbar"); |
605 | if (toolBar) { | 611 | if (toolBar) { |
606 | /* Reset the state. */ | 612 | /* Reset the state. */ |
@@ -618,6 +624,7 @@ static void updateNavDirButtons_(iWidget *navBar) { | |||
618 | setOutline_LabelWidget(fwd, atNewest); | 624 | setOutline_LabelWidget(fwd, atNewest); |
619 | refresh_Widget(toolBar); | 625 | refresh_Widget(toolBar); |
620 | } | 626 | } |
627 | iEndCollect(); | ||
621 | } | 628 | } |
622 | 629 | ||
623 | static const char *loadAnimationCStr_(void) { | 630 | static const char *loadAnimationCStr_(void) { |
@@ -777,7 +784,7 @@ static void updateNavBarSize_(iWidget *navBar) { | |||
777 | /* Button sizing. */ | 784 | /* Button sizing. */ |
778 | if (isNarrow ^ ((flags_Widget(navBar) & tight_WidgetFlag) != 0)) { | 785 | if (isNarrow ^ ((flags_Widget(navBar) & tight_WidgetFlag) != 0)) { |
779 | setFlags_Widget(navBar, tight_WidgetFlag, isNarrow); | 786 | setFlags_Widget(navBar, tight_WidgetFlag, isNarrow); |
780 | showCollapsed_Widget(findChild_Widget(navBar, "navbar.sidebar"), !isNarrow); | 787 | showCollapsed_Widget(findChild_Widget(navBar, "navbar.action3"), !isNarrow); |
781 | iObjectList *lists[] = { | 788 | iObjectList *lists[] = { |
782 | children_Widget(navBar), | 789 | children_Widget(navBar), |
783 | children_Widget(findChild_Widget(navBar, "url")), | 790 | children_Widget(findChild_Widget(navBar, "url")), |
@@ -798,8 +805,8 @@ static void updateNavBarSize_(iWidget *navBar) { | |||
798 | updateUrlInputContentPadding_(navBar); | 805 | updateUrlInputContentPadding_(navBar); |
799 | } | 806 | } |
800 | if (isPhone) { | 807 | if (isPhone) { |
801 | static const char *buttons[] = { "navbar.back", "navbar.forward", "navbar.sidebar", | 808 | static const char *buttons[] = { "navbar.action1", "navbar.action2", "navbar.action3", |
802 | "navbar.ident", "navbar.home", "navbar.menu" }; | 809 | "navbar.action4", "navbar.ident", "navbar.menu" }; |
803 | iWidget *toolBar = findWidget_Root("toolbar"); | 810 | iWidget *toolBar = findWidget_Root("toolbar"); |
804 | setVisualOffset_Widget(toolBar, 0, 0, 0); | 811 | setVisualOffset_Widget(toolBar, 0, 0, 0); |
805 | setFlags_Widget(toolBar, hidden_WidgetFlag, isLandscape_App()); | 812 | setFlags_Widget(toolBar, hidden_WidgetFlag, isLandscape_App()); |
@@ -824,6 +831,22 @@ static void updateNavBarSize_(iWidget *navBar) { | |||
824 | postCommand_Widget(navBar, "layout.changed id:navbar"); | 831 | postCommand_Widget(navBar, "layout.changed id:navbar"); |
825 | } | 832 | } |
826 | 833 | ||
834 | static void updateNavBarActions_(iWidget *navBar) { | ||
835 | const iPrefs *prefs = prefs_App(); | ||
836 | for (size_t i = 0; i < iElemCount(prefs->navbarActions); i++) { | ||
837 | iBeginCollect(); | ||
838 | const int action = prefs->navbarActions[i]; | ||
839 | iLabelWidget *button = | ||
840 | findChild_Widget(navBar, format_CStr("navbar.action%d", i + 1)); | ||
841 | if (button) { | ||
842 | setFlags_Widget(as_Widget(button), disabled_WidgetFlag, iFalse); | ||
843 | updateTextCStr_LabelWidget(button, toolbarActions_Mobile[action].icon); | ||
844 | setCommand_LabelWidget(button, collectNewCStr_String(toolbarActions_Mobile[action].command)); | ||
845 | } | ||
846 | iEndCollect(); | ||
847 | } | ||
848 | } | ||
849 | |||
827 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | 850 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { |
828 | if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) { | 851 | if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) { |
829 | updateNavBarSize_(navBar); | 852 | updateNavBarSize_(navBar); |
@@ -836,6 +859,33 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
836 | } | 859 | } |
837 | return iFalse; | 860 | return iFalse; |
838 | } | 861 | } |
862 | else if (equal_Command(cmd, "navbar.actions.changed")) { | ||
863 | updateNavBarActions_(navBar); | ||
864 | return iTrue; | ||
865 | } | ||
866 | else if (equal_Command(cmd, "contextclick")) { | ||
867 | const iRangecc id = range_Command(cmd, "id"); | ||
868 | if (id.start && startsWith_CStr(id.start, "navbar.action")) { | ||
869 | const int buttonIndex = id.end[-1] - '1'; | ||
870 | iArray items; | ||
871 | init_Array(&items, sizeof(iMenuItem)); | ||
872 | for (size_t i = 0; i < max_ToolbarAction; i++) { | ||
873 | pushBack_Array( | ||
874 | &items, | ||
875 | &(iMenuItem){ | ||
876 | format_CStr( | ||
877 | "%s %s", toolbarActions_Mobile[i].icon, toolbarActions_Mobile[i].label), | ||
878 | 0, | ||
879 | 0, | ||
880 | format_CStr("navbar.action.set arg:%d button:%d", i, buttonIndex) }); | ||
881 | } | ||
882 | openMenu_Widget( | ||
883 | makeMenu_Widget(get_Root()->widget, constData_Array(&items), size_Array(&items)), | ||
884 | coord_Command(cmd)); | ||
885 | deinit_Array(&items); | ||
886 | } | ||
887 | return iFalse; | ||
888 | } | ||
839 | else if (equal_Command(cmd, "navigate.focus")) { | 889 | else if (equal_Command(cmd, "navigate.focus")) { |
840 | /* The upload dialog has its own path field. */ | 890 | /* The upload dialog has its own path field. */ |
841 | if (findWidget_App("upload")) { | 891 | if (findWidget_App("upload")) { |
@@ -1068,9 +1118,7 @@ static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) { | |||
1068 | static void updateToolBarActions_(iWidget *toolBar) { | 1118 | static void updateToolBarActions_(iWidget *toolBar) { |
1069 | const iPrefs *prefs = prefs_App(); | 1119 | const iPrefs *prefs = prefs_App(); |
1070 | for (int i = 0; i < 2; i++) { | 1120 | for (int i = 0; i < 2; i++) { |
1071 | int action = prefs->toolbarActions[i] | 1121 | const int action = prefs->toolbarActions[i]; |
1072 | ? prefs->toolbarActions[i] | ||
1073 | : (i == 0 ? back_ToolbarAction : forward_ToolbarAction); | ||
1074 | iLabelWidget *button = | 1122 | iLabelWidget *button = |
1075 | findChild_Widget(toolBar, i == 0 ? "toolbar.action1" : "toolbar.action2"); | 1123 | findChild_Widget(toolBar, i == 0 ? "toolbar.action1" : "toolbar.action2"); |
1076 | if (button) { | 1124 | if (button) { |
@@ -1260,14 +1308,14 @@ void createUserInterface_Root(iRoot *d) { | |||
1260 | addUnsplitButton_(navBar); | 1308 | addUnsplitButton_(navBar); |
1261 | #endif | 1309 | #endif |
1262 | iWidget *navBack; | 1310 | iWidget *navBack; |
1263 | setId_Widget(navBack = addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(backArrow_Icon, 0, 0, "navigate.back")), collapse_WidgetFlag), "navbar.back"); | 1311 | setId_Widget(navBack = addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(backArrow_Icon, 0, 0, "navigate.back")), collapse_WidgetFlag), "navbar.action1"); |
1264 | setId_Widget(addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(forwardArrow_Icon, 0, 0, "navigate.forward")), collapse_WidgetFlag), "navbar.forward"); | 1312 | setId_Widget(addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(forwardArrow_Icon, 0, 0, "navigate.forward")), collapse_WidgetFlag), "navbar.action2"); |
1265 | /* Button for toggling the left sidebar. */ | 1313 | /* Button for toggling the left sidebar. */ |
1266 | setId_Widget(addChildFlags_Widget( | 1314 | setId_Widget(addChildFlags_Widget( |
1267 | navBar, | 1315 | navBar, |
1268 | iClob(newIcon_LabelWidget(leftHalf_Icon, 0, 0, "sidebar.toggle")), | 1316 | iClob(newIcon_LabelWidget(leftHalf_Icon, 0, 0, "sidebar.toggle")), |
1269 | collapse_WidgetFlag), | 1317 | collapse_WidgetFlag), |
1270 | "navbar.sidebar"); | 1318 | "navbar.action3"); |
1271 | addChildFlags_Widget(navBar, iClob(new_Widget()), expand_WidgetFlag); | 1319 | addChildFlags_Widget(navBar, iClob(new_Widget()), expand_WidgetFlag); |
1272 | iInputWidget *url; | 1320 | iInputWidget *url; |
1273 | /* URL input field. */ { | 1321 | /* URL input field. */ { |
@@ -1421,9 +1469,9 @@ void createUserInterface_Root(iRoot *d) { | |||
1421 | addChildFlags_Widget(navBar, iClob(new_Widget()), expand_WidgetFlag); | 1469 | addChildFlags_Widget(navBar, iClob(new_Widget()), expand_WidgetFlag); |
1422 | setId_Widget(addChildFlags_Widget(navBar, | 1470 | setId_Widget(addChildFlags_Widget(navBar, |
1423 | iClob(newIcon_LabelWidget( | 1471 | iClob(newIcon_LabelWidget( |
1424 | home_Icon, SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home")), | 1472 | home_Icon, 0, 0, "navigate.home")), |
1425 | collapse_WidgetFlag), | 1473 | collapse_WidgetFlag), |
1426 | "navbar.home"); | 1474 | "navbar.action4"); |
1427 | #if defined (iPlatformMobile) | 1475 | #if defined (iPlatformMobile) |
1428 | const iBool isPhone = (deviceType_App() == phone_AppDeviceType); | 1476 | const iBool isPhone = (deviceType_App() == phone_AppDeviceType); |
1429 | #endif | 1477 | #endif |
@@ -1583,6 +1631,7 @@ void createUserInterface_Root(iRoot *d) { | |||
1583 | setId_Widget(menu, "toolbar.menu"); /* view menu */ | 1631 | setId_Widget(menu, "toolbar.menu"); /* view menu */ |
1584 | } | 1632 | } |
1585 | #endif | 1633 | #endif |
1634 | updateNavBarActions_(navBar); | ||
1586 | updatePadding_Root(d); | 1635 | updatePadding_Root(d); |
1587 | /* Global context menus. */ { | 1636 | /* Global context menus. */ { |
1588 | iWidget *tabsMenu = makeMenu_Widget( | 1637 | iWidget *tabsMenu = makeMenu_Widget( |
@@ -1651,6 +1700,7 @@ void createUserInterface_Root(iRoot *d) { | |||
1651 | setId_Widget(splitMenu, "splitmenu"); | 1700 | setId_Widget(splitMenu, "splitmenu"); |
1652 | } | 1701 | } |
1653 | /* Global keyboard shortcuts. */ { | 1702 | /* Global keyboard shortcuts. */ { |
1703 | addAction_Widget(root, SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home"); | ||
1654 | addAction_Widget(root, 'l', KMOD_PRIMARY, "navigate.focus"); | 1704 | addAction_Widget(root, 'l', KMOD_PRIMARY, "navigate.focus"); |
1655 | addAction_Widget(root, 'f', KMOD_PRIMARY, "focus.set id:find.input"); | 1705 | addAction_Widget(root, 'f', KMOD_PRIMARY, "focus.set id:find.input"); |
1656 | addAction_Widget(root, '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1"); | 1706 | addAction_Widget(root, '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1"); |
diff --git a/src/ui/util.c b/src/ui/util.c index 0adaebb6..41e645de 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -2404,10 +2404,10 @@ iWidget *makePreferences_Widget(void) { | |||
2404 | format_CStr("returnkey.set arg:%d", acceptWithPrimaryMod_ReturnKeyBehavior) }, | 2404 | format_CStr("returnkey.set arg:%d", acceptWithPrimaryMod_ReturnKeyBehavior) }, |
2405 | { NULL } | 2405 | { NULL } |
2406 | }; | 2406 | }; |
2407 | iMenuItem toolbarActionItems[2][max_ToolbarAction + 1]; | 2407 | iMenuItem toolbarActionItems[2][max_ToolbarAction]; |
2408 | iZap(toolbarActionItems); | 2408 | iZap(toolbarActionItems); |
2409 | for (int j = 0; j < 2; j++) { | 2409 | for (int j = 0; j < 2; j++) { |
2410 | for (int i = 0; i < max_ToolbarAction; i++) { | 2410 | for (int i = 0; i < sidebar_ToolbarAction; i++) { |
2411 | toolbarActionItems[j][i].label = toolbarActions_Mobile[i].label; | 2411 | toolbarActionItems[j][i].label = toolbarActions_Mobile[i].label; |
2412 | toolbarActionItems[j][i].command = | 2412 | toolbarActionItems[j][i].command = |
2413 | format_CStr("toolbar.action.set arg:%d button:%d", i, j); | 2413 | format_CStr("toolbar.action.set arg:%d button:%d", i, j); |