1
0
Fork 0

- [GUI] added window to modify bookmark entry.

This commit is contained in:
cage 2023-04-09 14:25:47 +02:00
parent a848ea7730
commit 89dea0995e
3 changed files with 36 additions and 5 deletions

View File

@ -13,6 +13,7 @@
(gui:text description-entry))))
(if (gemini-parser:gemini-iri-p iri)
(ev:with-enqueued-process-and-unblock ()
(comm:make-request :gemini-bookmark-delete 1 iri)
(comm:make-request :gemini-bookmark-add 1 iri section description)
(gui-goodies:info-dialog toplevel
(format nil (_ "The address ~a has been bookmarked") iri))
@ -20,15 +21,18 @@
(gui-goodies:error-dialog toplevel
(format nil (_ "~s is not a valid gemini address.") iri))))))
(defun init-window (master iri)
(defun make-edit-window (master iri
&optional
(section-text (_ "Default"))
(description-text nil))
(gui:with-toplevel (toplevel :master master :title (_ "Streams"))
(gui:transient toplevel master)
(let* ((iri-label (make-instance 'gui:label :master toplevel :text (_ "Address")))
(section-label (make-instance 'gui:label :master toplevel :text (_ "Section")))
(description-label (make-instance 'gui:label :master toplevel :text (_ "Description")))
(iri-entry (make-instance 'gui:entry :master toplevel :text iri))
(section-entry (make-instance 'gui:entry :master toplevel :text (_ "Default")))
(description-entry (make-instance 'gui:entry :master toplevel))
(section-entry (make-instance 'gui:entry :master toplevel :text section-text))
(description-entry (make-instance 'gui:entry :master toplevel :text description-text))
(buttons-frame (make-instance 'gui:frame :master toplevel))
(add-button (make-instance 'gui:button
:master buttons-frame
@ -47,6 +51,9 @@
(gui:grid buttons-frame 6 0 :sticky :s)
(gui:grid add-button 0 0 :sticky :s))))
(defun init-window (master iri)
(make-edit-window master iri))
(defun bookmarks-table->lisbox-items (bookmarks-table)
(loop for bookmark in bookmarks-table
collect
@ -70,6 +77,17 @@
(length selected-indices))
(length selected-indices)))))))
(defun update-bookmark-clsr (toplevel searchbox bookmarks)
(lambda ()
(a:when-let ((selected-index (first (gui:listbox-get-selection-index searchbox))))
(ev:with-enqueued-process-and-unblock ()
(let ((iri (getf (elt bookmarks selected-index) :value)))
(comm:make-request :gemini-bookmark-delete 1 iri)
(make-edit-window toplevel
iri
(getf (elt bookmarks selected-index) :section)
(getf (elt bookmarks selected-index) :description)))))))
(defun manage-bookmarks (master)
(gui:with-toplevel (toplevel :master master :title (_ "Bookmarks"))
(gui:transient toplevel master)
@ -91,8 +109,15 @@
:master buttons-frame
:image icons:*document-delete*
:command (delete-bookmark-clsr toplevel
searchbox
bookmarks)))
(edit-button (make-instance 'gui:button
:master buttons-frame
:image icons:*document-edit*
:command (update-bookmark-clsr toplevel
searchbox
bookmarks))))
(gui:grid searchbox 0 0)
(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 edit-button 0 1 :sticky :s)
(gui:grid buttons-frame 1 0 :sticky :s))))

View File

@ -20,6 +20,8 @@
(a:define-constant +document-accept+ "fmw_document-accept" :test #'string=)
(a:define-constant +document-edit+ "fmw_document-accept" :test #'string=)
(a:define-constant +folder+ "fmw_folder" :test #'string=)
(a:define-constant +star-yellow+ "fmw_star-yellow.png" :test #'string=)
@ -44,6 +46,8 @@
(defparameter *document-accept* nil)
(defparameter *document-edit* nil)
(defparameter *folder* nil)
(defparameter *star-yellow* nil)
@ -69,6 +73,7 @@
(setf *document-delete* (load-icon +document-delete+))
(setf *document-add* (load-icon +document-add+))
(setf *document-accept* (load-icon +document-accept+))
(setf *document-edit* (load-icon +document-edit+))
(setf *folder* (load-icon +folder+))
(setf *star-yellow* (load-icon +star-yellow+))
(setf *star-blue* (load-icon +star-blue+)))

View File

@ -3331,6 +3331,7 @@
:*document-delete*
:*document-add*
:*document-accept*
:*document-edit*
:*folder*
:*star-yellow*
:*star-blue*))