mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-17 08:10:36 +01:00
- [GUI] added method "stream-url" specialized on 'gemini-stream';
- [GUI] fixed setting status of stream on completion; - [GUI] removed freezing when scaling text on rendering of an active stream; - [GUI] prevented crash when ask the program to shows an already shown stream frame.
This commit is contained in:
parent
d647465c1e
commit
409e8c5cb9
@ -9,3 +9,5 @@
|
|||||||
(define-constant +stream-status-canceled+ :canceled :test #'eq)
|
(define-constant +stream-status-canceled+ :canceled :test #'eq)
|
||||||
|
|
||||||
(define-constant +stream-status-downloading+ :downloading :test #'eq)
|
(define-constant +stream-status-downloading+ :downloading :test #'eq)
|
||||||
|
|
||||||
|
(define-constant +stream-status-completed+ :completed :test #'eq)
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
(defgeneric status (object))
|
(defgeneric status (object))
|
||||||
|
|
||||||
|
(defgeneric streaming-url (object))
|
||||||
|
|
||||||
(defmethod status ((object gemini-stream))
|
(defmethod status ((object gemini-stream))
|
||||||
(misc:with-lock ((status-lock object))
|
(misc:with-lock ((status-lock object))
|
||||||
(slot-value object 'status)))
|
(slot-value object 'status)))
|
||||||
@ -30,33 +32,42 @@
|
|||||||
(setf (slot-value object 'status) val)
|
(setf (slot-value object 'status) val)
|
||||||
val))
|
val))
|
||||||
|
|
||||||
|
(defmethod streaming-url ((object gemini-stream))
|
||||||
|
(server-stream-handle object))
|
||||||
|
|
||||||
(defparameter *gemini-streams-db* ())
|
(defparameter *gemini-streams-db* ())
|
||||||
|
|
||||||
|
(defparameter *gemini-streams-db-lock* (bt:make-lock "gemini-streams-db-lock"))
|
||||||
|
|
||||||
(defun push-db-stream (stream-object)
|
(defun push-db-stream (stream-object)
|
||||||
(pushnew stream-object
|
(misc:with-lock (*gemini-streams-db-lock*)
|
||||||
*gemini-streams-db*
|
(pushnew stream-object
|
||||||
:test (lambda (a b)
|
*gemini-streams-db*
|
||||||
(string= (server-stream-handle a)
|
:test (lambda (a b)
|
||||||
(server-stream-handle b))))
|
(string= (server-stream-handle a)
|
||||||
*gemini-streams-db*)
|
(server-stream-handle b))))
|
||||||
|
*gemini-streams-db*))
|
||||||
|
|
||||||
(defun remove-db-stream (stream-object)
|
(defun remove-db-stream (stream-object)
|
||||||
(setf *gemini-streams-db*
|
(misc:with-lock (*gemini-streams-db-lock*)
|
||||||
(remove stream-object *gemini-streams-db*))
|
(setf *gemini-streams-db*
|
||||||
*gemini-streams-db*)
|
(remove stream-object *gemini-streams-db*))
|
||||||
|
*gemini-streams-db*))
|
||||||
|
|
||||||
(defmethod abort-downloading ((object gemini-stream))
|
(defmethod abort-downloading ((object gemini-stream))
|
||||||
(setf (status object) +stream-status-canceled+))
|
(setf (status object) +stream-status-canceled+))
|
||||||
|
|
||||||
(defun remove-all-db-stream ()
|
(defun remove-all-db-stream ()
|
||||||
(map nil
|
(misc:with-lock (*gemini-streams-db-lock*)
|
||||||
(lambda (a) (abort-downloading a))
|
(map nil
|
||||||
*gemini-streams-db*)
|
(lambda (a) (abort-downloading a))
|
||||||
(setf *gemini-streams-db* ())
|
*gemini-streams-db*)
|
||||||
*gemini-streams-db*)
|
(setf *gemini-streams-db* ())
|
||||||
|
*gemini-streams-db*))
|
||||||
|
|
||||||
(defun find-db-stream-if (predicate)
|
(defun find-db-stream-if (predicate)
|
||||||
(find-if predicate *gemini-streams-db*))
|
(misc:with-lock (*gemini-streams-db-lock*)
|
||||||
|
(find-if predicate *gemini-streams-db*)))
|
||||||
|
|
||||||
(defun find-db-stream-url (url)
|
(defun find-db-stream-url (url)
|
||||||
(find-db-stream-if (lambda (a) (string= (server-stream-handle a) url))))
|
(find-db-stream-if (lambda (a) (string= (server-stream-handle a) url))))
|
||||||
@ -124,6 +135,8 @@
|
|||||||
iri)))
|
iri)))
|
||||||
status-completed))
|
status-completed))
|
||||||
(perform-after-stream-exausted-actions ()
|
(perform-after-stream-exausted-actions ()
|
||||||
|
(a:when-let ((current-streaming-stream (find-streaming-stream-url)))
|
||||||
|
(setf (status current-streaming-stream) +stream-status-completed+))
|
||||||
(print-info-message (_ "Stream finished"))
|
(print-info-message (_ "Stream finished"))
|
||||||
(gui:configure-mouse-pointer (gemtext-widget main-window) :xterm)
|
(gui:configure-mouse-pointer (gemtext-widget main-window) :xterm)
|
||||||
(render-toc main-window iri)
|
(render-toc main-window iri)
|
||||||
@ -162,7 +175,11 @@
|
|||||||
(ev:with-enqueued-process-and-unblock ()
|
(ev:with-enqueued-process-and-unblock ()
|
||||||
(set-bookmark-button-false main-window)))
|
(set-bookmark-button-false main-window)))
|
||||||
(ev:with-enqueued-process-and-unblock ()
|
(ev:with-enqueued-process-and-unblock ()
|
||||||
(set-gemlog-toolbar-button-appearance main-window iri))))
|
(set-gemlog-toolbar-button-appearance main-window iri))
|
||||||
|
(ev:with-enqueued-process-and-unblock (program-events:+minimum-event-priority+)
|
||||||
|
(client-stream-frame::refresh-all-streams
|
||||||
|
(client-stream-frame::table (stream-frame main-window))
|
||||||
|
#'client-stream-frame::all-rows-non-blocking))))
|
||||||
|
|
||||||
(defun set-gemlog-toolbar-button-appearance (main-window iri)
|
(defun set-gemlog-toolbar-button-appearance (main-window iri)
|
||||||
(if (comm:make-request :gemini-gemlog-subscribed-p 1 iri)
|
(if (comm:make-request :gemini-gemlog-subscribed-p 1 iri)
|
||||||
@ -1083,8 +1100,8 @@ local file paths."
|
|||||||
;; collecting events left on
|
;; collecting events left on
|
||||||
;; the queue won't be actually
|
;; the queue won't be actually
|
||||||
;; processed, just discarded
|
;; processed, just discarded
|
||||||
(when (not (eq (status stream-wrapper)
|
(when (eq (status stream-wrapper)
|
||||||
+stream-status-canceled+))
|
+stream-status-streaming+)
|
||||||
(collect-ir-lines iri main-window lines)))))
|
(collect-ir-lines iri main-window lines)))))
|
||||||
((gemini-client:text-file-stream-p meta)
|
((gemini-client:text-file-stream-p meta)
|
||||||
(slurp-text-data main-window iri))
|
(slurp-text-data main-window iri))
|
||||||
@ -1563,13 +1580,19 @@ local file paths."
|
|||||||
,@body)))
|
,@body)))
|
||||||
|
|
||||||
(defun scale-gemtext (main-window offset)
|
(defun scale-gemtext (main-window offset)
|
||||||
(with-interrupt-rendering-enqueue-restart-rendering (main-window ())
|
(let ((saved-active-stream (find-streaming-stream-url)))
|
||||||
(clear-gemtext main-window)
|
(interrupt-rendering main-window)
|
||||||
(setf (gemtext-font-scaling main-window)
|
(maybe-stop-streaming-stream-thread)
|
||||||
(if offset
|
(when saved-active-stream
|
||||||
(max 0.1 (+ (gemtext-font-scaling main-window) offset))
|
(open-iri (streaming-url saved-active-stream) main-window t))
|
||||||
1.0))
|
(ev:with-enqueued-process-and-unblock (program-events:+minimum-event-priority+)
|
||||||
(render-ir-lines (get-address-bar-text main-window) main-window)))
|
(restart-rendering main-window)
|
||||||
|
(clear-gemtext main-window)
|
||||||
|
(setf (gemtext-font-scaling main-window)
|
||||||
|
(if offset
|
||||||
|
(max 0.1 (+ (gemtext-font-scaling main-window) offset))
|
||||||
|
1.0))
|
||||||
|
(render-ir-lines (get-address-bar-text main-window) main-window))))
|
||||||
|
|
||||||
(defun initialize-keybindings (main-window target)
|
(defun initialize-keybindings (main-window target)
|
||||||
(gui:bind target
|
(gui:bind target
|
||||||
|
@ -58,7 +58,8 @@
|
|||||||
(let* ((master gui-goodies:*main-frame*)
|
(let* ((master gui-goodies:*main-frame*)
|
||||||
(stream-frame (client-main-window::stream-frame master))
|
(stream-frame (client-main-window::stream-frame master))
|
||||||
(main-frame (client-main-window::main-paned-frame master)))
|
(main-frame (client-main-window::main-paned-frame master)))
|
||||||
(gui:add-pane main-frame stream-frame)))
|
(when (not (gui:paned-widget-p main-frame stream-frame))
|
||||||
|
(gui:add-pane main-frame stream-frame))))
|
||||||
|
|
||||||
(defun show-bookmarks-clsr (main-window)
|
(defun show-bookmarks-clsr (main-window)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
@ -40,13 +40,20 @@
|
|||||||
(getf b :download-iri)))))
|
(getf b :download-iri)))))
|
||||||
rows))
|
rows))
|
||||||
|
|
||||||
(defun refresh-all-streams (stream-table)
|
(defun refresh-all-streams (stream-table &optional (all-rows-fn #'all-rows))
|
||||||
(with-accessors ((tree gui-goodies:tree)
|
(with-accessors ((tree gui-goodies:tree)
|
||||||
(rows gui-goodies:rows)) stream-table
|
(rows gui-goodies:rows)) stream-table
|
||||||
(let ((new-rows (all-rows)))
|
(let ((new-rows (funcall all-rows-fn)))
|
||||||
(resync-rows stream-table new-rows)
|
(resync-rows stream-table new-rows)
|
||||||
stream-table)))
|
stream-table)))
|
||||||
|
|
||||||
|
(defun all-rows-non-blocking ()
|
||||||
|
(let ((rows (comm:make-request :gemini-all-stream-info 1)))
|
||||||
|
(setf rows (sort rows
|
||||||
|
(lambda (a b) (string< (getf a :download-iri)
|
||||||
|
(getf b :download-iri)))))
|
||||||
|
rows))
|
||||||
|
|
||||||
(defmethod initialize-instance :after ((object stream-table) &key &allow-other-keys)
|
(defmethod initialize-instance :after ((object stream-table) &key &allow-other-keys)
|
||||||
(with-accessors ((tree gui-goodies:tree)) object
|
(with-accessors ((tree gui-goodies:tree)) object
|
||||||
(let ((treeview (make-instance 'gui:scrolled-treeview
|
(let ((treeview (make-instance 'gui:scrolled-treeview
|
||||||
@ -83,6 +90,7 @@
|
|||||||
(with-accessors ((tree gui-goodies:tree)) stream-table
|
(with-accessors ((tree gui-goodies:tree)) stream-table
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(client-main-window::interrupt-rendering main-window)
|
(client-main-window::interrupt-rendering main-window)
|
||||||
|
(client-main-window::maybe-stop-streaming-stream-thread)
|
||||||
(a:when-let* ((selections (gui:treeview-get-selection tree))
|
(a:when-let* ((selections (gui:treeview-get-selection tree))
|
||||||
(selection (first selections)))
|
(selection (first selections)))
|
||||||
(let* ((url (gui:id selection))
|
(let* ((url (gui:id selection))
|
||||||
|
@ -81,7 +81,8 @@
|
|||||||
:+ps-file-dialog-filter+
|
:+ps-file-dialog-filter+
|
||||||
:+stream-status-streaming+
|
:+stream-status-streaming+
|
||||||
:+stream-status-canceled+
|
:+stream-status-canceled+
|
||||||
:+stream-status-downloading+))
|
:+stream-status-downloading+
|
||||||
|
:+stream-status-completed+))
|
||||||
|
|
||||||
(defpackage :conditions
|
(defpackage :conditions
|
||||||
(:use :cl
|
(:use :cl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user