From 1e88fe5805efb8228be308d24c7965e1c9f967c6 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 29 Oct 2023 12:41:17 +0100 Subject: [PATCH] - [GUI] added new events for links - button two will open the link in background; - button one pressed when simultaneously pressing the control button will add the link to the tour. --- src/gui/client/main-window.lisp | 39 +++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 40b91c3..496c667 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -521,18 +521,21 @@ local file paths." (lambda () (inline-all-images main-window))) +(defun enqueue-add-link-to-tour (link-value link-name) + (ev:with-enqueued-process-and-unblock () + (comm:make-request :tour-add-link + 1 + link-value + link-name) + (print-info-message (format nil + (_ "~a added to tour") + (if (string-not-empty-p link-name) + link-name + link-value))))) + (defun contextual-menu-link-clrs (link-name link-value main-window) (labels ((add-to-tour-callback () - (ev:with-enqueued-process-and-unblock () - (comm:make-request :tour-add-link - 1 - link-value - link-name) - (print-info-message (format nil - (_ "~a added to tour") - (if (string-not-empty-p link-name) - link-name - link-value))))) + (enqueue-add-link-to-tour link-value link-name)) (download-background-callback () (open-iri link-value main-window nil :status +stream-status-downloading+)) (copy-link-callback () @@ -730,7 +733,11 @@ local file paths." link-value))) (new-text-line-start `(:line ,line-number :char 0))) (gui:append-text gemtext-widget link-rendered-label) - (let ((tag-link (gui:make-link-button gemtext-widget + (let* ((tag-link-other-bindings + (list (cons #$$ + (lambda () (enqueue-add-link-to-tour target-iri + link-name))))) + (tag-link (gui:make-link-button gemtext-widget new-text-line-start `(- :end 1 :chars) link-font @@ -744,10 +751,18 @@ local file paths." (contextual-menu-link-clrs link-name target-iri main-window) + :button-2-callback + (lambda () + (open-iri target-iri + main-window + nil + :status +stream-status-downloading+)) :over-callback (lambda () (print-info-message target-iri)) :leave-callback - (lambda () (print-info-message ""))))) + (lambda () (print-info-message "")) + :other-bindings + tag-link-other-bindings))) (gui:tag-lower gemtext-widget tag-link) (gui:append-line gemtext-widget ""))))))) (render-line (key text line-number &key (wrap :word))