summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-19 08:27:14 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-19 08:27:14 +0200
commit88a1c5b30d6ff07c9a3d0a9644ed02a4b8090d4b (patch)
tree9b5a496f7d7ad2d00677d2032ade61aba78aee0e
parente5af4c98f3f95781c190c2f16c286f8370cfe011 (diff)
Bookmark a link via context menu
-rw-r--r--res/about/version.gmi3
-rw-r--r--src/app.c15
-rw-r--r--src/ui/documentwidget.c12
3 files changed, 24 insertions, 6 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi
index 28263653..f9be6955 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -7,10 +7,11 @@
7# Release notes 7# Release notes
8 8
9## 1.0 9## 1.0
10* Export bookmarks via "about:bookmarks". Added a menu item for showing this page. 10* Export bookmarks via "about:bookmarks". Added a menu item for showing the page.
11* Listing all bookmarks by tag or creation time. 11* Listing all bookmarks by tag or creation time.
12* Import all links on page as bookmarks. 12* Import all links on page as bookmarks.
13* Open links with an unrecognized scheme in the default browser. 13* Open links with an unrecognized scheme in the default browser.
14* Removed unimplemented menu items.
14 15
15## 0.13.2 16## 0.13.2
16* Added a little spinner to indicate ongoing requests. 17* Added a little spinner to indicate ongoing requests.
diff --git a/src/app.c b/src/app.c
index 12d4024d..dd4d4ed2 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1383,9 +1383,18 @@ iBool handleCommand_App(const char *cmd) {
1383 } 1383 }
1384 else if (equal_Command(cmd, "bookmark.add")) { 1384 else if (equal_Command(cmd, "bookmark.add")) {
1385 iDocumentWidget *doc = document_App(); 1385 iDocumentWidget *doc = document_App();
1386 makeBookmarkCreation_Widget(url_DocumentWidget(doc), 1386 if (suffixPtr_Command(cmd, "url")) {
1387 bookmarkTitle_DocumentWidget(doc), 1387 iString *title = collect_String(newRange_String(range_Command(cmd, "title")));
1388 siteIcon_GmDocument(document_DocumentWidget(doc))); 1388 replace_String(title, "%20", " ");
1389 makeBookmarkCreation_Widget(collect_String(suffix_Command(cmd, "url")),
1390 title,
1391 0x1f588 /* pin */);
1392 }
1393 else {
1394 makeBookmarkCreation_Widget(url_DocumentWidget(doc),
1395 bookmarkTitle_DocumentWidget(doc),
1396 siteIcon_GmDocument(document_DocumentWidget(doc)));
1397 }
1389 postCommand_App("focus.set id:bmed.title"); 1398 postCommand_App("focus.set id:bmed.title");
1390 return iTrue; 1399 return iTrue;
1391 } 1400 }
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 3f3e453a..1830239a 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2325,10 +2325,18 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2325 format_CStr("!open noproxy:1 url:%s", cstr_String(linkUrl)) } }, 2325 format_CStr("!open noproxy:1 url:%s", cstr_String(linkUrl)) } },
2326 2); 2326 2);
2327 } 2327 }
2328 iString *linkLabel = collect_String(newRange_String(d->contextLink->text));
2329 urlEncodeSpaces_String(linkLabel);
2328 pushBackN_Array(&items, 2330 pushBackN_Array(&items,
2329 (iMenuItem[]){ { "---", 0, 0, NULL }, 2331 (iMenuItem[]){ { "---", 0, 0, NULL },
2330 { "Copy Link", 0, 0, "document.copylink" } }, 2332 { "Copy Link", 0, 0, "document.copylink" },
2331 2); 2333 { "Bookmark Link...",
2334 0,
2335 0,
2336 format_CStr("!bookmark.add title:%s url:%s",
2337 cstr_String(linkLabel),
2338 cstr_String(linkUrl)) } },
2339 3);
2332 iMediaRequest *mediaReq; 2340 iMediaRequest *mediaReq;
2333 if ((mediaReq = findMediaRequest_DocumentWidget_(d, d->contextLink->linkId)) != NULL) { 2341 if ((mediaReq = findMediaRequest_DocumentWidget_(d, d->contextLink->linkId)) != NULL) {
2334 if (isFinished_GmRequest(mediaReq->req)) { 2342 if (isFinished_GmRequest(mediaReq->req)) {