turn off emcas and tab version on popups

This commit is contained in:
David Botton 2024-04-10 14:14:53 -04:00
parent b70a35d17b
commit 58c9f08880
4 changed files with 70 additions and 29 deletions

View file

@ -630,20 +630,36 @@ them.")
(t
(create-div body :content "Invalid Access")))))
;;;;;;;;;;;;;;;;;;;;;;;
;; enable-clog-popup ;;
;;;;;;;;;;;;;;;;;;;;;;;
(defun enable-clog-popup (&key (path *clog-popup-path*) (boot-file "/boot.html"))
"Enable handling of clog enabled popups"
(set-on-new-window 'clog-popup-handler :path path :boot-file boot-file))
(defun open-clog-popup (obj &key (path *clog-popup-path*)
;;;;;;;;;;;;;;;;;;;;;
;; open-clog-popup ;;
;;;;;;;;;;;;;;;;;;;;;
(defgeneric open-clog-popup (clog-obj &key path
add-sync-to-path
sync-key
name
specs
wait-timeout)
(:documentation "Open a new browser window/popup in most cases a tab.
Since they are controlled by clog you have full control of the new popups
and are more flexible than using open-windo. Returns the clog-body and the
clog-window in the same connnection as obj of the new window on the new
connection or nil if failed within :WAIT-TIMEOUT"))
(defmethod open-clog-popup ((obj clog-obj) &key (path *clog-popup-path*)
(add-sync-to-path t)
(sync-key (random-hex-string))
(name "_blank")
(specs "")
(wait-timeout 10))
"Open a new browser window/popup in most cases a tab. Since they are controlled
by clog you have full control of the new popups and are more flexible than using
open-windo. Returns the clog-body and the clog-window in the same connnection as
obj of the new window on the new connection or nil if failed within :WAIT-TIMEOUT"
(let* ((sem (bordeaux-threads:make-semaphore))
(mpath (if add-sync-to-path
(format nil "~A?sync=~A" path sync-key)
@ -659,12 +675,30 @@ obj of the new window on the new connection or nil if failed within :WAIT-TIMEOU
(values sem new-win))
nil)))
(defun clog-popup-openned (obj sync-key)
"Used to notify open-clog-popup the new popup window is ready for custom
clog-popup handlers."
;;;;;;;;;;;;;;;;;;;;;;;;
;; clog-popup-openned ;;
;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric clog-popup-openned (clog-obj sync-key)
(:documentation "Used to notify open-clog-popup the new popup window
is ready used for custom clog-popup handlers."))
(defmethod clog-popup-openned ((obj clog-obj) sync-key)
(let ((sem (gethash sync-key *clog-popup-sync-hash*)))
(cond (sem
(setf (gethash sync-key *clog-popup-sync-hash*) (connection-body obj))
(bordeaux-threads:signal-semaphore sem))
(t
(create-div obj :content "Invalid Sync")))))
;;;;;;;;;;;;;;;;;;;;;
;; in-clog-popup-p ;;
;;;;;;;;;;;;;;;;;;;;;
(defgeneric in-clog-popup-p (clog-obj)
(:documentation "Returns obj if clog-gui-window is a in a clog-popup window"))
(defmethod in-clog-popup-p ((obj clog-obj))
(when (connection-data-item obj "clog-popup")
obj))

View file

@ -943,8 +943,9 @@ embedded in a native template application.)"
"CLOG Popups"
(*clog-popup-path* variable)
(enable-clog-popup function)
(open-clog-popup function)
(clog-popup-openned function)
(open-clog-popup generic-function)
(clog-popup-openned generic-function)
(in-clog-popup-p generic-function)
"CLOG-Window - CLOG Window Objects"
(clog-window class)

View file

@ -45,7 +45,9 @@
(let ((app (connection-data-item obj "builder-app-data")))
(setf (connection-data-item pop "builder-app-data") app)
(clog-gui-initialize pop :parent-desktop-obj obj)
(if open-file
(setf (title (html-document pop)) open-file)
(setf (title (html-document pop)) "CLOG Builder Source Editor"))
(on-open-file pop :open-file open-file :maximized t))
(on-open-file obj :open-file open-file)))
(open-window (window (connection-body obj))
@ -97,8 +99,10 @@
(m-load (create-gui-menu-item m-file :content "load"))
(m-save (create-gui-menu-item m-file :content "save (cmd/ctrl-s)"))
(m-saveas (create-gui-menu-item m-file :content "save as.."))
(m-emacs (create-gui-menu-item m-file :content "open in emacs"))
(m-ntab (create-gui-menu-item m-file :content "open in new tab"))
(m-emacs (unless (in-clog-popup-p obj)
(create-gui-menu-item m-file :content "open in emacs")))
(m-ntab (unless (in-clog-popup-p obj)
(create-gui-menu-item m-file :content "open in new tab")))
(m-edit (create-gui-menu-drop-down menu :content "Edit"))
(m-undo (create-gui-menu-item m-edit :content "undo (cmd/ctrl-z)"))
(m-redo (create-gui-menu-item m-edit :content "redo (shift cmd/ctrl-z)"))
@ -311,16 +315,18 @@
(setf last-date (file-write-date file-name))
(sleep .5)
(remove-class btn-save "w3-animate-top"))))))))))
(when m-emacs
(set-on-click m-emacs (lambda (obj)
(when is-dirty
(save obj nil))
(swank:ed-in-emacs file-name)
(window-close win)))
(window-close win))))
(when m-ntab
(set-on-click m-ntab (lambda (obj)
(when is-dirty
(save obj nil))
(window-close win)
(on-open-file-ext obj :open-file file-name)))
(on-open-file-ext obj :open-file file-name))))
(set-on-window-can-close win
(lambda (obj)
(cond (is-dirty

View file

@ -10,7 +10,7 @@
;; Open panels and files in new browser tabs by default
(setf *open-external* nil)
;; Use clog-popup and extend desktop to popups
(setf *open-external-using-clog-popups* nil)
(setf *open-external-using-clog-popups* t)
;; CLOG Panels