summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/history.c12
-rw-r--r--src/history.h3
-rw-r--r--src/ui/window.c35
3 files changed, 45 insertions, 5 deletions
diff --git a/src/history.c b/src/history.c
index 6876d8e3..48820f6d 100644
--- a/src/history.c
+++ b/src/history.c
@@ -268,6 +268,18 @@ iBool goForward_History(iHistory *d) {
268 return iFalse; 268 return iFalse;
269} 269}
270 270
271iBool atLatest_History(const iHistory *d) {
272 iBool isLatest;
273 iGuardMutex(d->mtx, isLatest = (d->recentPos == 0));
274 return isLatest;
275}
276
277iBool atOldest_History(const iHistory *d) {
278 iBool isOldest;
279 iGuardMutex(d->mtx, isOldest = (d->recentPos == size_Array(&d->recent) - 1));
280 return isOldest;
281}
282
271const iGmResponse *cachedResponse_History(const iHistory *d) { 283const iGmResponse *cachedResponse_History(const iHistory *d) {
272 const iRecentUrl *item = constMostRecentUrl_History(d); 284 const iRecentUrl *item = constMostRecentUrl_History(d);
273 return item ? item->cachedResponse : NULL; 285 return item ? item->cachedResponse : NULL;
diff --git a/src/history.h b/src/history.h
index ce3b8e47..164a61d6 100644
--- a/src/history.h
+++ b/src/history.h
@@ -59,6 +59,9 @@ iRecentUrl *findUrl_History (iHistory *, const iString *url);
59void clearCache_History (iHistory *); 59void clearCache_History (iHistory *);
60size_t pruneLeastImportant_History (iHistory *); 60size_t pruneLeastImportant_History (iHistory *);
61 61
62iBool atLatest_History (const iHistory *);
63iBool atOldest_History (const iHistory *);
64
62const iStringArray * searchContents_History (const iHistory *, const iRegExp *pattern); /* chronologically ascending */ 65const iStringArray * searchContents_History (const iHistory *, const iRegExp *pattern); /* chronologically ascending */
63 66
64const iString * 67const iString *
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
466static 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
465static const int loadAnimIntervalMs_ = 133; 478static const int loadAnimIntervalMs_ = 133;
466static int loadAnimIndex_ = 0; 479static 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);