1
0
Fork 0

- [GUI] embedded stream window into the main-window.

This commit is contained in:
cage 2023-07-26 14:37:15 +02:00
parent c5b94ae602
commit 8f67357dd2
3 changed files with 83 additions and 51 deletions

View File

@ -1327,6 +1327,10 @@ local file paths."
:initform nil
:initarg :search-frame
:accessor search-frame)
(stream-frame
:initform nil
:initarg :stream-frame
:accessor stream-frame)
(gemini-paned-frame
:initform nil
:initarg :gemini-paned-frame
@ -1346,6 +1350,7 @@ local file paths."
(toc-frame toc-frame)
(info-frame info-frame)
(search-frame search-frame)
(stream-frame stream-frame)
(info-text info-text)
(gemtext-widget gemtext-widget)
(gemini-paned-frame gemini-paned-frame)) object
@ -1374,6 +1379,7 @@ local file paths."
(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))
(gui:grid info-text 0 0 :sticky :news)
(gui-goodies:gui-resize-grid-all info-frame)
(gui:grid tool-bar 0 0 :sticky :news)
@ -1382,7 +1388,9 @@ local file paths."
(gui:grid gemini-paned-frame 1 0 :sticky :news)
(gui:grid search-frame 2 0 :sticky :news)
(gui:grid-forget search-frame)
(gui:grid info-frame 3 0 :sticky :ews)
(gui:grid stream-frame 3 0 :sticky :news)
(gui:grid-forget stream-frame)
(gui:grid info-frame 4 0 :sticky :ews)
(gui:grid-columnconfigure object 0 :weight 1)
(gui:grid-rowconfigure object 1 :weight 1)
(setup-main-window-events object)

View File

@ -55,8 +55,10 @@
(client-certificates-window:init-window master)))
(defun show-streams ()
(let ((master gui-goodies:*toplevel*))
(client-stream-window:init-window master)))
(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))))
(defun show-bookmarks-clsr (main-window)
(lambda ()

View File

@ -2,11 +2,17 @@
(named-readtables:in-readtable nodgui.syntax:nodgui-syntax)
(defclass stream-frame (gui-goodies:table-frame) ())
(defclass stream-frame (gui:frame)
((table
:initform nil
:initarg :table
:accessor table)))
(defun resync-rows (stream-frame new-rows)
(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-frame
(rows gui-goodies:rows)) stream-table
(gui:treeview-delete-all tree)
(setf rows new-rows)
(loop for row in rows do
@ -21,32 +27,38 @@
(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-frame))
stream-frame))
(gui:treeview-refit-columns-width (gui-goodies:tree stream-table))
stream-table))
(defun all-rows ()
(cev:enqueue-request-and-wait-results :gemini-all-stream-info
1
ev:+standard-event-priority+))
(defmethod initialize-instance :after ((object stream-frame) &key &allow-other-keys)
(defun refresh-all-streams (stream-table)
(with-accessors ((tree gui-goodies:tree)
(rows gui-goodies:rows)) object
(let ((new-rows (all-rows))
(treeview (make-instance 'gui:scrolled-treeview
(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")))))
(setf tree treeview)
(gui:treeview-heading tree gui:+treeview-first-column-id+
(gui:treeview-heading treeview
gui:+treeview-first-column-id+
:text (_ "Address"))
(resync-rows object new-rows)
object)))
(setf tree treeview)
(refresh-all-streams object))))
(defun delete-stream-clsr (stream-frame)
(defun delete-stream-clsr (stream-table)
(with-accessors ((tree gui-goodies:tree)) stream-table
(lambda ()
(a:when-let* ((selections (gui:treeview-get-selection (gui-goodies:tree stream-frame))))
(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)))
@ -58,22 +70,22 @@
(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)))))))
(resync-rows stream-table new-rows))))))))
(defun revive-stream-clsr (stream-frame)
(defun revive-stream-clsr (stream-table)
(with-accessors ((tree gui-goodies:tree)) stream-table
(lambda ()
(a:when-let* ((selections (gui:treeview-get-selection (gui-goodies:tree stream-frame)))
(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-frame new-rows)))))
(resync-rows stream-table new-rows))))))
(defun init-window (master)
(gui:with-toplevel (toplevel :master master :title (_ "Streams"))
(gui:transient toplevel master)
(let* ((table (make-instance 'stream-frame :master toplevel))
(buttons-frame (make-instance 'gui:frame :master toplevel))
(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*
@ -81,10 +93,20 @@
(revive-button (make-instance 'gui:button
:master buttons-frame
:image icons:*document-accept*
:command (revive-stream-clsr table))))
: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")))
(gui:grid table 0 0 :sticky :nwe)
(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 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))