summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-11 18:54:59 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-19 11:15:30 +0300
commit65ae29b56803c1ba779ab9b0a6b09333482ee13a (patch)
treeb46703ee24ad816d6f2837ee1b013f5164d2fec3
parent6770449bef6c04c7e6d10a26755fdd77c8b6947c (diff)
Preferences: Add bookmarks to bottom/top
IssueID #358 # Conflicts: # res/lang/de.bin # res/lang/en.bin # res/lang/eo.bin # res/lang/es.bin # res/lang/es_MX.bin # res/lang/fi.bin # res/lang/fr.bin # res/lang/gl.bin # res/lang/ia.bin # res/lang/ie.bin # res/lang/isv.bin # res/lang/pl.bin # res/lang/ru.bin # res/lang/sk.bin # res/lang/sr.bin # res/lang/tok.bin # res/lang/zh_Hans.bin # res/lang/zh_Hant.bin
-rw-r--r--po/en.po3
-rw-r--r--src/app.c6
-rw-r--r--src/bookmarks.c21
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h1
-rw-r--r--src/ui/util.c1
6 files changed, 29 insertions, 4 deletions
diff --git a/po/en.po b/po/en.po
index 9b09ec9c..dcbcc67f 100644
--- a/po/en.po
+++ b/po/en.po
@@ -1314,6 +1314,9 @@ msgstr "Vertical centering:"
1314msgid "prefs.collapsepreonload" 1314msgid "prefs.collapsepreonload"
1315msgstr "Collapse preformatted:" 1315msgstr "Collapse preformatted:"
1316 1316
1317msgid "prefs.bookmarks.addbottom"
1318msgstr "Add bookmarks to bottom:"
1319
1317# User preference that controls whether index.gmi pages get automatically opened when browsing the contents of a directory inside a compressed archive. 1320# User preference that controls whether index.gmi pages get automatically opened when browsing the contents of a directory inside a compressed archive.
1318msgid "prefs.archive.openindex" 1321msgid "prefs.archive.openindex"
1319msgstr "Open archive indices:" 1322msgstr "Open archive indices:"
diff --git a/src/app.c b/src/app.c
index 5fc01a5b..b7db6dce 100644
--- a/src/app.c
+++ b/src/app.c
@@ -238,6 +238,7 @@ static iString *serializePrefs_App_(const iApp *d) {
238 appendFormat_String(str, "prefs.centershort.changed arg:%d\n", d->prefs.centerShortDocs); 238 appendFormat_String(str, "prefs.centershort.changed arg:%d\n", d->prefs.centerShortDocs);
239 appendFormat_String(str, "prefs.collapsepreonload.changed arg:%d\n", d->prefs.collapsePreOnLoad); 239 appendFormat_String(str, "prefs.collapsepreonload.changed arg:%d\n", d->prefs.collapsePreOnLoad);
240 appendFormat_String(str, "prefs.hoverlink.changed arg:%d\n", d->prefs.hoverLink); 240 appendFormat_String(str, "prefs.hoverlink.changed arg:%d\n", d->prefs.hoverLink);
241 appendFormat_String(str, "prefs.bookmarks.addbottom.changed arg:%d\n", d->prefs.addBookmarksToBottom);
241 appendFormat_String(str, "prefs.archive.openindex.changed arg:%d\n", d->prefs.openArchiveIndexPages); 242 appendFormat_String(str, "prefs.archive.openindex.changed arg:%d\n", d->prefs.openArchiveIndexPages);
242 appendFormat_String(str, "quoteicon.set arg:%d\n", d->prefs.quoteIcon ? 1 : 0); 243 appendFormat_String(str, "quoteicon.set arg:%d\n", d->prefs.quoteIcon ? 1 : 0);
243 appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); 244 appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme);
@@ -2358,6 +2359,10 @@ iBool handleCommand_App(const char *cmd) {
2358 d->prefs.openArchiveIndexPages = arg_Command(cmd) != 0; 2359 d->prefs.openArchiveIndexPages = arg_Command(cmd) != 0;
2359 return iTrue; 2360 return iTrue;
2360 } 2361 }
2362 else if (equal_Command(cmd, "prefs.bookmarks.addbottom.changed")) {
2363 d->prefs.addBookmarksToBottom = arg_Command(cmd) != 0;
2364 return iTrue;
2365 }
2361 else if (equal_Command(cmd, "prefs.animate.changed")) { 2366 else if (equal_Command(cmd, "prefs.animate.changed")) {
2362 d->prefs.uiAnimations = arg_Command(cmd) != 0; 2367 d->prefs.uiAnimations = arg_Command(cmd) != 0;
2363 return iTrue; 2368 return iTrue;
@@ -2654,6 +2659,7 @@ iBool handleCommand_App(const char *cmd) {
2654 setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling); 2659 setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling);
2655 setToggle_Widget(findChild_Widget(dlg, "prefs.imageloadscroll"), d->prefs.loadImageInsteadOfScrolling); 2660 setToggle_Widget(findChild_Widget(dlg, "prefs.imageloadscroll"), d->prefs.loadImageInsteadOfScrolling);
2656 setToggle_Widget(findChild_Widget(dlg, "prefs.hidetoolbarscroll"), d->prefs.hideToolbarOnScroll); 2661 setToggle_Widget(findChild_Widget(dlg, "prefs.hidetoolbarscroll"), d->prefs.hideToolbarOnScroll);
2662 setToggle_Widget(findChild_Widget(dlg, "prefs.bookmarks.addbottom"), d->prefs.addBookmarksToBottom);
2657 setToggle_Widget(findChild_Widget(dlg, "prefs.archive.openindex"), d->prefs.openArchiveIndexPages); 2663 setToggle_Widget(findChild_Widget(dlg, "prefs.archive.openindex"), d->prefs.openArchiveIndexPages);
2658 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme); 2664 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme);
2659 setToggle_Widget(findChild_Widget(dlg, "prefs.customframe"), d->prefs.customFrame); 2665 setToggle_Widget(findChild_Widget(dlg, "prefs.customframe"), d->prefs.customFrame);
diff --git a/src/bookmarks.c b/src/bookmarks.c
index 67c6a25f..1a260f3a 100644
--- a/src/bookmarks.c
+++ b/src/bookmarks.c
@@ -327,11 +327,18 @@ void save_Bookmarks(const iBookmarks *d, const char *dirPath) {
327 unlock_Mutex(d->mtx); 327 unlock_Mutex(d->mtx);
328} 328}
329 329
330static int maxOrder_Bookmarks_(const iBookmarks *d) { 330static iRangei orderRange_Bookmarks_(const iBookmarks *d) {
331 int ord = 0; 331 iRangei ord = { 0, 0 };
332 iConstForEach(Hash, i, &d->bookmarks) { 332 iConstForEach(Hash, i, &d->bookmarks) {
333 const iBookmark *bm = (const iBookmark *) i.value; 333 const iBookmark *bm = (const iBookmark *) i.value;
334 ord = iMax(ord, bm->order); 334 if (isEmpty_Range(&ord)) {
335 ord.start = bm->order;
336 ord.end = bm->order + 1;
337 }
338 else {
339 ord.start = iMin(ord.start, bm->order);
340 ord.end = iMax(ord.end, bm->order + 1);
341 }
335 } 342 }
336 return ord; 343 return ord;
337} 344}
@@ -349,7 +356,13 @@ uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title,
349 } 356 }
350 bm->icon = icon; 357 bm->icon = icon;
351 initCurrent_Time(&bm->when); 358 initCurrent_Time(&bm->when);
352 bm->order = maxOrder_Bookmarks_(d) + 1; /* Last in lists. */ 359 const iRangei ord = orderRange_Bookmarks_(d);
360 if (prefs_App()->addBookmarksToBottom) {
361 bm->order = ord.end; /* Last in lists. */
362 }
363 else {
364 bm->order = ord.start - 1; /* First in lists. */
365 }
353 insert_Bookmarks_(d, bm); 366 insert_Bookmarks_(d, bm);
354 unlock_Mutex(d->mtx); 367 unlock_Mutex(d->mtx);
355 return id_Bookmark(bm); 368 return id_Bookmark(bm);
diff --git a/src/prefs.c b/src/prefs.c
index 088cc7bc..5fed0a76 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -47,6 +47,7 @@ void init_Prefs(iPrefs *d) {
47 d->loadImageInsteadOfScrolling = iFalse; 47 d->loadImageInsteadOfScrolling = iFalse;
48 d->collapsePreOnLoad = iFalse; 48 d->collapsePreOnLoad = iFalse;
49 d->openArchiveIndexPages = iTrue; 49 d->openArchiveIndexPages = iTrue;
50 d->addBookmarksToBottom = iTrue;
50 d->decodeUserVisibleURLs = iTrue; 51 d->decodeUserVisibleURLs = iTrue;
51 d->maxCacheSize = 10; 52 d->maxCacheSize = 10;
52 d->maxMemorySize = 200; 53 d->maxMemorySize = 200;
diff --git a/src/prefs.h b/src/prefs.h
index 37aeb260..a04cda70 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -63,6 +63,7 @@ struct Impl_Prefs {
63 iBool collapsePreOnLoad; 63 iBool collapsePreOnLoad;
64 iString searchUrl; 64 iString searchUrl;
65 iBool openArchiveIndexPages; 65 iBool openArchiveIndexPages;
66 iBool addBookmarksToBottom;
66 /* Network */ 67 /* Network */
67 iString caFile; 68 iString caFile;
68 iString caPath; 69 iString caPath;
diff --git a/src/ui/util.c b/src/ui/util.c
index adca6269..b18a3292 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2349,6 +2349,7 @@ iWidget *makePreferences_Widget(void) {
2349 setUrlContent_InputWidget(searchUrl, iTrue); 2349 setUrlContent_InputWidget(searchUrl, iTrue);
2350 addDialogPadding_(headings, values); 2350 addDialogPadding_(headings, values);
2351 addDialogToggle_(headings, values, "${prefs.hoverlink}", "prefs.hoverlink"); 2351 addDialogToggle_(headings, values, "${prefs.hoverlink}", "prefs.hoverlink");
2352 addDialogToggle_(headings, values, "${prefs.bookmarks.addbottom}", "prefs.bookmarks.addbottom");
2352 addDialogToggle_(headings, values, "${prefs.archive.openindex}", "prefs.archive.openindex"); 2353 addDialogToggle_(headings, values, "${prefs.archive.openindex}", "prefs.archive.openindex");
2353 if (deviceType_App() != phone_AppDeviceType) { 2354 if (deviceType_App() != phone_AppDeviceType) {
2354 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.pinsplit}"))); 2355 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.pinsplit}")));