From 39886718ccba88350b184fd1b527c8151a8c9a3c Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 31 May 2024 12:56:52 +0200 Subject: [PATCH] - [GUI] added contextual menu to gemtext widget; - [GUI] added command to collect all the links of a page in the tour. --- po/it.po | 24 ++++++++++-------------- src/gui/client/main-window.lisp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/po/it.po b/po/it.po index c85aced..17776b5 100644 --- a/po/it.po +++ b/po/it.po @@ -2595,23 +2595,19 @@ msgstr "Criterio di ricerca: " msgid "Default" msgstr "Default" -#: src/message-rendering-utils.lisp:354 -msgid "Multiple choices allowed" -msgstr "Sono ammesse scelte multiple" +#~ msgid "Multiple choices allowed" +#~ msgstr "Sono ammesse scelte multiple" -#: src/message-rendering-utils.lisp:355 -msgid "A single choice allowed" -msgstr "È ammessa una sola scelta" +#~ msgid "A single choice allowed" +#~ msgstr "È ammessa una sola scelta" -#: src/message-rendering-utils.lisp:357 -msgid "The poll has expired" -msgstr "Il sondaggio è scaduto" +#~ msgid "The poll has expired" +#~ msgstr "Il sondaggio è scaduto" -#: src/message-rendering-utils.lisp:358 -msgid "NB: results not shown as the poll has not expired" -msgstr "" -"NB: I risultati non sono mostrati dato che il sondaggio non è ancora " -"terminato." +#~ msgid "NB: results not shown as the poll has not expired" +#~ msgstr "" +#~ "NB: I risultati non sono mostrati dato che il sondaggio non è ancora " +#~ "terminato." #~ msgid "Subject:" #~ msgstr "Oggetto del messaggio: " diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 42b2b8a..9751718 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -580,6 +580,26 @@ local file paths." link-name link-value))))) +(defun contextual-menu-gemtext-widget (main-window) + (labels ((add-to-tour-callback () + (let ((links (collect-link-lines main-window))) + (loop for line in links + for link-value = (ir-href line) then (ir-href line) + for link-name = (or (ir-line line) + (ir-href line)) + then (or (ir-line line) + (ir-href line)) + when (gemini-client:absolute-gemini-url-p link-value) + do + (enqueue-add-link-to-tour link-value link-name))))) + (lambda (e) + (declare (ignore e)) + (let* ((popup-menu (gui:make-menu nil (_"gemtext window menu"))) + (x (gui:screen-mouse-x)) + (y (gui:screen-mouse-y))) + (gui:make-menubutton popup-menu (_ "Add all links to tour") #'add-to-tour-callback) + (gui:popup popup-menu x y))))) + (defun contextual-menu-link-clrs (link-name link-value main-window) (labels ((add-to-tour-callback () (enqueue-add-link-to-tour link-value link-name)) @@ -987,6 +1007,13 @@ local file paths." (strcat iri "/") iri))) +(defun collect-link-lines (main-window) + (with-accessors ((ir-lines ir-lines)) main-window + (loop for line across ir-lines + when (eq (format-keyword (ir-type line)) + :a) + collect line))) + (defun collect-source-lines-clsr (main-window) (lambda (stream-wrapper lines) ;; this test ensures that the @@ -1476,6 +1503,9 @@ local file paths." (gui:bind toc-listbox #$<>$ (toc-callback-clsr main-window)) + (gui:bind (gui:inner-text gemtext-widget) + #$<3>$ + (contextual-menu-gemtext-widget main-window)) (setf (gui:command go-button) (open-iri-clsr main-window t)) (setf (gui:command reload-button) (reload-iri-clsr main-window)) (setf (gui:command back-button) (back-iri-clsr main-window))