From 1d2d528d95908a9507264b10e4ba7c25d5c61436 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 23 Jan 2022 12:53:08 +0100 Subject: [PATCH] - [kami] close the connection when closing the filesystem explorer window; - fixed a prompt and an error message. --- src/filesystem-tree-window.lisp | 12 +++++++++--- src/kami/client.lisp | 3 +-- src/package.lisp | 1 + src/ui-goodies.lisp | 5 +++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/filesystem-tree-window.lisp b/src/filesystem-tree-window.lisp index 5480cbf..b132439 100644 --- a/src/filesystem-tree-window.lisp +++ b/src/filesystem-tree-window.lisp @@ -94,10 +94,10 @@ to query Valid feature values are :size. Returns nil if Returns nil if the path does not point to an actual file.") (filesystem-close-connection-function - :initform (lambda (stream) (declare (ignore stream))) + :initform (constantly t) :accessor filesystem-close-connection-function :type function - :documentation "function with a signle parameter the connection stream to be closed.")) + :documentation "function with no parameter to close the connection.")) (:documentation "A window that shows and allow interacting with a hierarchical filesystem")) @@ -119,7 +119,9 @@ (filesystem-upload-function object) (getf handlers-plist :filesystem-upload-function) (filesystem-query-path-function object) - (getf handlers-plist :filesystem-query-path-function))) + (getf handlers-plist :filesystem-query-path-function) + (filesystem-close-connection-function object) + (getf handlers-plist :filesystem-close-connection-function))) object) (defmethod refresh-config :after ((object filesystem-tree-window)) @@ -526,6 +528,10 @@ (upload-treenode window downloaded-path node-path))))) + +(defun close-connection (window) + (funcall (filesystem-close-connection-function window))) + (defun init (root &optional (handlers-plist nil)) "Initialize the window" (let* ((low-level-window (make-croatoan-window :border t)) diff --git a/src/kami/client.lisp b/src/kami/client.lisp index 89ab3ca..70c70d1 100644 --- a/src/kami/client.lisp +++ b/src/kami/client.lisp @@ -171,8 +171,7 @@ :filesystem-download-function (download-node *stream* *root-fid*) :filesystem-upload-function (upload-node *stream* *root-fid*) :filesystem-query-path-function (query-path *stream* *root-fid*) - :filesystem-close-connection-function (lambda (stream) - (declare (ignore stream)) + :filesystem-close-connection-function (lambda () (9p:close-client socket)))))) (defun iri->filesystem-window-handlers (kami-iri) diff --git a/src/package.lisp b/src/package.lisp index c5ee7d2..3a72e07 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -2049,6 +2049,7 @@ :mark-node :open-node :edit-node + :close-connection :resync-rows-db :init)) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 67cfdf9..33e29b6 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -2421,7 +2421,7 @@ printed, on the main window." (focus-to-filesystem-explorer-window)))) (defun kami-open-url-prompt () - (_ "Open Kami url: ")) + (_ "Open kami url: ")) (defun kami-open-url () (flet ((on-input-complete (url) @@ -2434,7 +2434,7 @@ printed, on the main window." handlers) (focus-to-filesystem-explorer-window)) (error-message (format nil - (_ "~s is not a valid gemini address") + (_ "~s is not a valid kami address") url)))))))) (let ((prompt (kami-open-url-prompt))) (ask-string-input #'on-input-complete @@ -2622,6 +2622,7 @@ printed, on the main window." (windows:draw win)))) (defun file-explorer-close-window () + (fstree:close-connection *filesystem-explorer-window*) (close-window-and-return-to-message *filesystem-explorer-window*)) (defun file-explorer-open-node ()