diff --git a/source/clog-window.lisp b/source/clog-window.lisp index 9b301a1..4d3bcff 100644 --- a/source/clog-window.lisp +++ b/source/clog-window.lisp @@ -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*) - (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" +;;;;;;;;;;;;;;;;;;;;; +;; 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)) (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)) + diff --git a/source/clog.lisp b/source/clog.lisp index 027bfce..04df644 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -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) diff --git a/tools/clog-builder-files.lisp b/tools/clog-builder-files.lisp index 2675f3d..02f6334 100644 --- a/tools/clog-builder-files.lisp +++ b/tools/clog-builder-files.lisp @@ -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) - (setf (title (html-document pop)) open-file) + (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")))))))))) - (set-on-click m-emacs (lambda (obj) - (when is-dirty - (save obj nil)) - (swank:ed-in-emacs file-name) - (window-close win))) - (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))) + (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)))) + (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)))) (set-on-window-can-close win (lambda (obj) (cond (is-dirty diff --git a/tools/preferences.lisp.sample b/tools/preferences.lisp.sample index da0ee73..573ba3c 100644 --- a/tools/preferences.lisp.sample +++ b/tools/preferences.lisp.sample @@ -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