diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-16 15:12:51 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-16 15:12:51 +0300 |
commit | e635e4c2c58afd3a329875b3b044d0df717b20a2 (patch) | |
tree | fa26b09975b65a5de30f625bbeca512c1f800adf /src/ui | |
parent | cab02631292145ba1cf15e19edcd59116f3900b4 (diff) |
Back/Forward buttons vs. navigation position
The Back and Forward arrow buttons are disabled if the navigation position is at the end/beginning of the history.
IssueID #247
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index fe2a3353..eb0c7d3a 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
37 | #include "touch.h" | 37 | #include "touch.h" |
38 | #include "../app.h" | 38 | #include "../app.h" |
39 | #include "../visited.h" | 39 | #include "../visited.h" |
40 | #include "../history.h" | ||
40 | #include "../gmcerts.h" | 41 | #include "../gmcerts.h" |
41 | #include "../gmutil.h" | 42 | #include "../gmutil.h" |
42 | #include "../visited.h" | 43 | #include "../visited.h" |
@@ -462,6 +463,18 @@ static void updateNavBarIdentity_(iWidget *navBar) { | |||
462 | setFlags_Widget(as_Widget(idItem), disabled_WidgetFlag, !ident); | 463 | setFlags_Widget(as_Widget(idItem), disabled_WidgetFlag, !ident); |
463 | } | 464 | } |
464 | 465 | ||
466 | static void updateNavDirButtons_(iWidget *navBar) { | ||
467 | const iHistory *history = history_DocumentWidget(document_App()); | ||
468 | setFlags_Widget(findChild_Widget(navBar, "navbar.back"), disabled_WidgetFlag, | ||
469 | atOldest_History(history)); | ||
470 | setFlags_Widget(findChild_Widget(navBar, "navbar.forward"), disabled_WidgetFlag, | ||
471 | atLatest_History(history)); | ||
472 | setFlags_Widget(findWidget_App("toolbar.back"), disabled_WidgetFlag, | ||
473 | atOldest_History(history)); | ||
474 | setFlags_Widget(findWidget_App("toolbar.forward"), disabled_WidgetFlag, | ||
475 | atLatest_History(history)); | ||
476 | } | ||
477 | |||
465 | static const int loadAnimIntervalMs_ = 133; | 478 | static const int loadAnimIntervalMs_ = 133; |
466 | static int loadAnimIndex_ = 0; | 479 | static int loadAnimIndex_ = 0; |
467 | 480 | ||
@@ -688,6 +701,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
688 | checkLoadAnimation_Window_(get_Window()); | 701 | checkLoadAnimation_Window_(get_Window()); |
689 | dismissPortraitPhoneSidebars_Window(get_Window()); | 702 | dismissPortraitPhoneSidebars_Window(get_Window()); |
690 | updateNavBarIdentity_(navBar); | 703 | updateNavBarIdentity_(navBar); |
704 | updateNavDirButtons_(navBar); | ||
691 | /* Icon updates should be limited to automatically chosen icons if the user | 705 | /* Icon updates should be limited to automatically chosen icons if the user |
692 | is allowed to pick their own in the future. */ | 706 | is allowed to pick their own in the future. */ |
693 | if (updateBookmarkIcon_Bookmarks(bookmarks_App(), urlStr, | 707 | if (updateBookmarkIcon_Bookmarks(bookmarks_App(), urlStr, |
@@ -1193,11 +1207,22 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1193 | resizeWidthOfChildren_WidgetFlag | | 1207 | resizeWidthOfChildren_WidgetFlag | |
1194 | arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); | 1208 | arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); |
1195 | setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); | 1209 | setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); |
1196 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag); | 1210 | setId_Widget(addChildFlags_Widget(toolBar, |
1197 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), frameless_WidgetFlag); | 1211 | iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), |
1198 | setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "toolbar.showident")), frameless_WidgetFlag), "toolbar.ident"); | 1212 | frameless_WidgetFlag), |
1199 | setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f588", "toolbar.showview arg:-1")), | 1213 | "toolbar.back"); |
1200 | frameless_WidgetFlag | commandOnClick_WidgetFlag), "toolbar.view"); | 1214 | setId_Widget(addChildFlags_Widget(toolBar, |
1215 | iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), | ||
1216 | frameless_WidgetFlag), | ||
1217 | "toolbar.forward"); | ||
1218 | setId_Widget(addChildFlags_Widget(toolBar, | ||
1219 | iClob(newLargeIcon_LabelWidget("\U0001f464", "toolbar.showident")), | ||
1220 | frameless_WidgetFlag), | ||
1221 | "toolbar.ident"); | ||
1222 | setId_Widget(addChildFlags_Widget(toolBar, | ||
1223 | iClob(newLargeIcon_LabelWidget("\U0001f588", "toolbar.showview arg:-1")), | ||
1224 | frameless_WidgetFlag | commandOnClick_WidgetFlag), | ||
1225 | "toolbar.view"); | ||
1201 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", phoneNavMenuItems_, | 1226 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", phoneNavMenuItems_, |
1202 | iElemCount(phoneNavMenuItems_)); | 1227 | iElemCount(phoneNavMenuItems_)); |
1203 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); | 1228 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); |