From 80ad62643249db04200287a9084c6679c07ddc20 Mon Sep 17 00:00:00 2001 From: cage Date: Thu, 27 Jul 2023 15:55:20 +0200 Subject: [PATCH] - [GUI] refactored name for stream window to stream frame. --- src/gui/client/main-window.lisp | 4 +- src/gui/client/menu-command.lisp | 2 +- src/gui/client/search-frame.lisp | 2 +- src/gui/client/stream-window.lisp | 116 ------------------------------ src/package.lisp | 6 +- tinmop.asd | 2 +- 6 files changed, 8 insertions(+), 124 deletions(-) delete mode 100644 src/gui/client/stream-window.lisp diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index a5073c9..8044480 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -1378,8 +1378,8 @@ local file paths." (setf info-frame (make-instance 'gui:frame :master object :relief :sunken :borderwidth 1)) (setf info-text (make-instance 'gui:text :height 2 :wrap :none :master info-frame)) (gui:configure info-text :font gui:+tk-small-caption-font+) - (setf search-frame (client-search-frame:init-window object)) - (setf stream-frame (client-stream-window:init-window object)) + (setf search-frame (client-search-frame:init-frame object)) + (setf stream-frame (client-stream-frame:init-frame object)) (gui:grid info-text 0 0 :sticky :news) (gui-goodies:gui-resize-grid-all info-frame) (gui:grid tool-bar 0 0 :sticky :news) diff --git a/src/gui/client/menu-command.lisp b/src/gui/client/menu-command.lisp index ba16f7f..5c7ab52 100644 --- a/src/gui/client/menu-command.lisp +++ b/src/gui/client/menu-command.lisp @@ -58,7 +58,7 @@ (let* ((master gui-goodies:*main-frame*) (frame (client-main-window::stream-frame master))) (gui:grid frame 3 0 :sticky :news) - (client-stream-window::refresh-all-streams (client-stream-window::table frame)))) + (client-stream-frame::refresh-all-streams (client-stream-frame::table frame)))) (defun show-bookmarks-clsr (main-window) (lambda () diff --git a/src/gui/client/search-frame.lisp b/src/gui/client/search-frame.lisp index 65ef543..47f22a9 100644 --- a/src/gui/client/search-frame.lisp +++ b/src/gui/client/search-frame.lisp @@ -41,7 +41,7 @@ :selectforeground) :background (gui:cget gemtext-widget :selectbackground))))) -(defun init-window (main-window) +(defun init-frame (main-window) (let* ((frame (make-instance 'search-frame :master main-window)) (gemtext-widget (client-main-window::gemtext-widget main-window)) (search-label (make-instance 'gui:label :master frame :text (_ "Search: "))) diff --git a/src/gui/client/stream-window.lisp b/src/gui/client/stream-window.lisp deleted file mode 100644 index 61b47be..0000000 --- a/src/gui/client/stream-window.lisp +++ /dev/null @@ -1,116 +0,0 @@ -(in-package :client-stream-window) - -(named-readtables:in-readtable nodgui.syntax:nodgui-syntax) - -(defclass stream-frame (gui:frame) - ((table - :initform nil - :initarg :table - :accessor table))) - -(defclass stream-table (gui-goodies:table-frame) ()) - -(defun resync-rows (stream-table new-rows) - (with-accessors ((tree gui-goodies:tree) - (rows gui-goodies:rows)) stream-table - (gui:treeview-delete-all tree) - (setf rows new-rows) - (loop for row in rows do - (let* ((iri (getf row :download-iri)) - (stream-client-wrapper (client-main-window:find-db-stream-url iri)) - (stream-status (to-s (client-main-window::status stream-client-wrapper))) - (tree-row (make-instance 'gui:tree-item - :id iri - :text iri - :column-values - (list stream-status - (to-s (getf row :octect-count))) - :index gui:+treeview-last-index+))) - (gui:treeview-insert-item tree :item tree-row))) - (gui:treeview-refit-columns-width (gui-goodies:tree stream-table)) - stream-table)) - -(defun all-rows () - (let ((rows (cev:enqueue-request-and-wait-results :gemini-all-stream-info - 1 - ev:+standard-event-priority+))) - (setf rows (sort rows - (lambda (a b) (string< (getf a :download-iri) - (getf b :download-iri))))) - rows)) - -(defun refresh-all-streams (stream-table) - (with-accessors ((tree gui-goodies:tree) - (rows gui-goodies:rows)) stream-table - (let ((new-rows (all-rows))) - (resync-rows stream-table new-rows) - stream-table))) - -(defmethod initialize-instance :after ((object stream-table) &key &allow-other-keys) - (with-accessors ((tree gui-goodies:tree)) object - (let ((treeview (make-instance 'gui:scrolled-treeview - :master object - :pack '(:side :top :expand t :fill :both) - :columns (list (_ "Status") - (_ "Number of octects downloaded"))))) - (gui:treeview-heading treeview - gui:+treeview-first-column-id+ - :text (_ "Address")) - (setf tree treeview) - (refresh-all-streams object)))) - -(defun delete-stream-clsr (stream-table) - (with-accessors ((tree gui-goodies:tree)) stream-table - (lambda () - (a:when-let* ((selections (gui:treeview-get-selection tree))) - (loop for selection in selections do - (let* ((url (gui:id selection)) - (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:remove-db-stream stream-client-wrapper) - (comm:make-request :gemini-remove-stream 1 url)) - (let ((new-rows (all-rows))) - (resync-rows stream-table new-rows)))))))) - -(defun revive-stream-clsr (stream-table) - (with-accessors ((tree gui-goodies:tree)) stream-table - (lambda () - (a:when-let* ((selections (gui:treeview-get-selection tree)) - (selection (first selections))) - (let* ((url (gui:id selection)) - (new-rows (all-rows))) - (client-main-window::open-iri url gui-goodies:*main-frame* t) - (resync-rows stream-table new-rows)))))) - -(defun init-window (main-window) - (let* ((wrapper-frame (make-instance 'stream-frame :master main-window)) - (table (make-instance 'stream-table :master wrapper-frame)) - (buttons-frame (make-instance 'gui:frame :master wrapper-frame)) - (delete-button (make-instance 'gui:button - :master buttons-frame - :image icons:*document-delete* - :command (delete-stream-clsr table))) - (revive-button (make-instance 'gui:button - :master buttons-frame - :image icons:*document-accept* - :command (revive-stream-clsr table))) - (close-button (make-instance 'gui:button :image icons:*cross* - :master buttons-frame - :command (lambda () - (gui:grid-forget wrapper-frame))))) - (setf (table wrapper-frame) table) - (gui-goodies:attach-tooltips (delete-button (_ "delete selected stream")) - (revive-button (_ "show selected stream")) - (close-button (_ "close"))) - (gui:grid table 0 0 :sticky :news) - (gui:grid buttons-frame 1 0 :sticky :s) - (gui:grid delete-button 0 0 :sticky :s) - (gui:grid revive-button 0 1 :sticky :s) - (gui:grid close-button 0 2 :sticky :s) - (gui:grid-columnconfigure wrapper-frame 0 :weight 1) - (gui:grid-rowconfigure wrapper-frame 1 :weight 1) - wrapper-frame)) diff --git a/src/package.lisp b/src/package.lisp index 2e6503e..bd7a016 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -3523,7 +3523,7 @@ :enqueue-shuffle-tour :init-window)) -(defpackage :client-stream-window +(defpackage :client-stream-frame (:use :cl :config @@ -3541,7 +3541,7 @@ (:gui-shapes :nodgui.shapes) (:menu :client-menu-command)) (:export - :init-window)) + :init-frame)) (defpackage :client-bookmark-window (:use @@ -3600,7 +3600,7 @@ (:gui-mw :nodgui.mw) (:gui-shapes :nodgui.shapes)) (:export - :init-window)) + :init-frame)) (defpackage :client-scheduler (:use :cl diff --git a/tinmop.asd b/tinmop.asd index 6338e4f..cd63795 100644 --- a/tinmop.asd +++ b/tinmop.asd @@ -172,7 +172,7 @@ (:file "certificates-window") (:file "titan-window") (:file "tour-window") - (:file "stream-window") + (:file "stream-frame") (:file "bookmark-window") (:file "gemlog-window") (:file "menu-command")