From cefbe59be6e4b5570ef75a94824e9c742f79aadb Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 19 Feb 2023 15:45:22 +0100 Subject: [PATCH] - [GUI] bound the wish interpreter handle to a special variable so that the gui event loop can reference it and call, without errors, nodgui functions. --- src/gui/client/gui-goodies.lisp | 2 ++ src/gui/client/main-window.lisp | 13 ++++++++----- src/gui/client/program-events.lisp | 5 +++-- src/main.lisp | 1 - src/package.lisp | 2 ++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gui/client/gui-goodies.lisp b/src/gui/client/gui-goodies.lisp index f00b5b4..25a2da8 100644 --- a/src/gui/client/gui-goodies.lisp +++ b/src/gui/client/gui-goodies.lisp @@ -4,6 +4,8 @@ (defparameter *toplevel* gui:*tk*) +(defparameter *gui-server* nil) + (a:define-constant +font-h1+ "sans 20 bold" :test #'string=) (a:define-constant +font-h2+ "sans 15 bold" :test #'string=) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 87cc774..926a1d5 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -65,7 +65,7 @@ (defun notify-request-error (e) (let ((message (format nil (_ "Comunication with backend failed: ~a") e))) #+debug-mode (misc:dbg "request error ~a" message) - #-debug-mode (gui-goodies:error-dialog gui:*tk* message))) + #-debug-mode (gui-goodies:error-dialog gui-goodies:*toplevel* message))) (defmacro with-notify-errors (&body body) `(handler-case @@ -124,10 +124,10 @@ (defun initialize-menu (parent) (with-accessors ((main-window main-window)) parent (let* ((bar (gui:make-menubar parent)) - (file (gui:make-menu bar (_ "File") :underline 0)) - (help (gui:make-menu bar (_ "Help") :underline 0))) - (gui:make-menubutton file (_ "Quit") #'menu:quit :underline 0) - (gui:make-menubutton help (_ "About") #'menu:help-about :underline 0)))) + (file (gui:make-menu bar (_ "File") :underline 0)) + (help (gui:make-menu bar (_ "Help") :underline 0))) + (gui:make-menubutton file (_ "Quit") #'menu:quit :underline 0) + (gui:make-menubutton help (_ "About") #'menu:help-about :underline 0)))) (defclass tool-bar (gui:frame) ((iri-entry @@ -274,6 +274,9 @@ (gui:with-nodgui (:title +program-name+) (icons:load-icons) (initialize-menu gui:*tk*) + (setf gui-goodies:*toplevel* gui:*tk*) + (setf gui-goodies:*gui-server* gui:*wish*) + (client-events:start-events-loop) (let ((main-frame (make-instance 'main-frame))) (gui:grid main-frame 0 0 :sticky :nswe) (gui-goodies:gui-resize-grid-all gui:*tk*)))) diff --git a/src/gui/client/program-events.lisp b/src/gui/client/program-events.lisp index 019f04f..6d34802 100644 --- a/src/gui/client/program-events.lisp +++ b/src/gui/client/program-events.lisp @@ -23,8 +23,9 @@ (setf *stop-events-loop* nil)) (setf *events-loop-thread* (bt:make-thread (lambda () - (loop while (events-loop-running-p) do - (ev:dispatch-program-events-or-wait)))))) + (let ((gui:*wish* gui-goodies:*gui-server*)) + (loop while (events-loop-running-p) do + (ev:dispatch-program-events-or-wait))))))) (defmacro with-enqueue-request ((method-name id the-error &rest args) &body on-error) `(ev:with-enqueued-process-and-unblock () diff --git a/src/main.lisp b/src/main.lisp index 1263c0c..54a5971 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -264,7 +264,6 @@ etc.) happened" (rpc-server-init))) (command-line:*rpc-client-mode* (rpc-client-load-configuration) - (client-events:start-events-loop) (json-rpc-communication::start-client) (client-main-window:init-main-window)) (command-line:*print-lisp-dependencies* diff --git a/src/package.lisp b/src/package.lisp index e4d52d7..acd71db 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -3256,6 +3256,7 @@ (:local-nicknames (:comm :json-rpc-communication) (:re :cl-ppcre) (:a :alexandria) + (:gui :nodgui) (:ev :program-events)) (:export :events-loop-running-p @@ -3315,6 +3316,7 @@ (:gui-shapes :nodgui.shapes)) (:export :*toplevel* + :*gui-server* :gui-resize-grid-all :confirm-deletion :info-operation-completed