From 41b2f7a5712ef5cead3161bcc7bac6be45a76dd9 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 2 Apr 2023 17:05:14 +0200 Subject: [PATCH] - [GUI] added command to reload a gemini stream from the streams window. --- ...age-accept.png => fmw_document-accept.png} | Bin src/gui/client/constants.lisp | 6 ++++ src/gui/client/icons.lisp | 5 +++ src/gui/client/main-window.lisp | 32 ++++++++---------- src/gui/client/stream-window.lisp | 25 +++++++++++--- src/package.lisp | 6 +++- 6 files changed, 50 insertions(+), 24 deletions(-) rename data/icons/{fmw_page-accept.png => fmw_document-accept.png} (100%) diff --git a/data/icons/fmw_page-accept.png b/data/icons/fmw_document-accept.png similarity index 100% rename from data/icons/fmw_page-accept.png rename to data/icons/fmw_document-accept.png diff --git a/src/gui/client/constants.lisp b/src/gui/client/constants.lisp index 247ede5..ac80e3f 100644 --- a/src/gui/client/constants.lisp +++ b/src/gui/client/constants.lisp @@ -3,3 +3,9 @@ (define-constant +minimum-padding+ 2 :test #'=) (define-constant +ps-file-dialog-filter+ '(("PostScript Files" "*.ps")) :test #'equalp) + +(define-constant +stream-status-streaming+ :streaming :test #'eq) + +(define-constant +stream-status-canceled+ :canceled :test #'eq) + +(define-constant +stream-status-downloading+ :downloading :test #'eq) diff --git a/src/gui/client/icons.lisp b/src/gui/client/icons.lisp index cfc18bf..93b642e 100644 --- a/src/gui/client/icons.lisp +++ b/src/gui/client/icons.lisp @@ -18,6 +18,8 @@ (a:define-constant +document-add+ "fmw_document-add" :test #'string=) +(a:define-constant +document-accept+ "fmw_document-accept" :test #'string=) + (a:define-constant +folder+ "fmw_folder" :test #'string=) (defparameter *search* nil) @@ -36,6 +38,8 @@ (defparameter *document-add* nil) +(defparameter *document-accept* nil) + (defparameter *folder* nil) (defun load-icon (filename) @@ -56,4 +60,5 @@ (setf *up* (load-icon +up+)) (setf *document-delete* (load-icon +document-delete+)) (setf *document-add* (load-icon +document-add+)) + (setf *document-accept* (load-icon +document-accept+)) (setf *folder* (load-icon +folder+))) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 9e02c03..6f90de5 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -2,12 +2,6 @@ (named-readtables:in-readtable nodgui.syntax:nodgui-syntax) -(a:define-constant +stream-status-streaming+ :streaming :test #'eq) - -(a:define-constant +stream-status-canceled+ :canceled :test #'eq) - -(a:define-constant +stream-status-downloading+ :downloading :test #'eq) - (defclass gemini-stream () ((server-stream-handle :initform nil @@ -77,8 +71,9 @@ (defmethod stop-stream-thread ((object gemini-stream)) (with-accessors ((fetching-thread fetching-thread)) object - (abort-downloading object) - (when (bt:threadp fetching-thread) + (abort-downloading object) + (when (and (bt:threadp fetching-thread) + (bt:thread-alive-p fetching-thread)) (bt:join-thread fetching-thread))) object) @@ -853,13 +848,14 @@ (setf (gui:text (gemtext-widget main-window)) text)) (defun init-main-window () - (gui:with-nodgui (:title +program-name+) - (icons:load-icons) - (initialize-menu gui:*tk*) - (setf gui-goodies:*toplevel* gui:*tk*) - (setf gui-goodies:*gui-server* gui:*wish*) - (client-events:start-events-loop) - (let ((main-frame (make-instance 'main-frame))) - (setf gui-goodies:*main-frame* main-frame) - (gui:grid main-frame 0 0 :sticky :nswe) - (gui-goodies:gui-resize-grid-all gui-goodies:*toplevel*)))) + (let ((gui:*debug-tk* nil)) + (gui:with-nodgui (:title +program-name+) + (icons:load-icons) + (initialize-menu gui:*tk*) + (setf gui-goodies:*toplevel* gui:*tk*) + (setf gui-goodies:*gui-server* gui:*wish*) + (client-events:start-events-loop) + (let ((main-frame (make-instance 'main-frame))) + (setf gui-goodies:*main-frame* main-frame) + (gui:grid main-frame 0 0 :sticky :nswe) + (gui-goodies:gui-resize-grid-all gui-goodies:*toplevel*))))) diff --git a/src/gui/client/stream-window.lisp b/src/gui/client/stream-window.lisp index e83ee71..1ef1121 100644 --- a/src/gui/client/stream-window.lisp +++ b/src/gui/client/stream-window.lisp @@ -52,14 +52,23 @@ (stream-client-wrapper (client-main-window::find-db-stream-url url))) (when (eq (client-main-window:status stream-client-wrapper) client-main-window:+stream-status-streaming+) - (ev:with-enqueued-process-and-unblock () - (client-main-window:stop-steaming-stream-thread))) + (ev:with-enqueued-process-and-unblock () + (client-main-window:stop-steaming-stream-thread))) (ev:with-enqueued-process-and-unblock () (client-main-window:remove-db-stream stream-client-wrapper) (comm:make-request :gemini-remove-stream 1 url)) (let ((new-rows (all-rows))) (resync-rows stream-frame new-rows))))))) +(defun revive-stream-clsr (stream-frame) + (lambda () + (a:when-let* ((selections (gui:treeview-get-selection (gui-goodies:tree stream-frame))) + (selection (first selections))) + (let* ((url (gui:id selection)) + (new-rows (all-rows))) + (resync-rows stream-frame new-rows) + (client-main-window::open-iri url gui-goodies:*main-frame* t))))) + (defun init-window (master) (gui:with-modal-toplevel (toplevel :master master :title (_ "Streams")) (gui:transient toplevel master) @@ -68,8 +77,14 @@ (delete-button (make-instance 'gui:button :master buttons-frame :image icons:*document-delete* - :command (delete-stream-clsr table)))) - (gui-goodies:attach-tooltips (delete-button (_ "delete selected stream"))) + :command (delete-stream-clsr table))) + (revive-button (make-instance 'gui:button + :master buttons-frame + :image icons:*document-accept* + :command (revive-stream-clsr table)))) + (gui-goodies:attach-tooltips (delete-button (_ "delete selected stream")) + (delete-button (_ "show selected stream"))) (gui:grid table 0 0 :sticky :nwe) (gui:grid buttons-frame 1 0 :sticky :s) - (gui:grid delete-button 0 0 :sticky :s)))) + (gui:grid delete-button 0 0 :sticky :s) + (gui:grid revive-button 0 1 :sticky :s)))) diff --git a/src/package.lisp b/src/package.lisp index 872d868..101f076 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -70,7 +70,10 @@ :+gemini-file-extension+ ;; GUI :+minimum-padding+ - :+ps-file-dialog-filter+)) + :+ps-file-dialog-filter+ + :+stream-status-streaming+ + :+stream-status-canceled+ + :+stream-status-downloading+)) (defpackage :conditions (:use :cl @@ -3321,6 +3324,7 @@ :*up* :*document-delete* :*document-add* + :*document-accept* :*folder*)) (defpackage :validation