X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=gtk%2Fgtk.main_loop_events.lisp;h=961b357f5334e11ea31a12778f79a042a7192cf3;hb=c5a046da8c5ca824b266ff48034a860790dc1aa3;hp=6c7376a46cd78eef95a415d19a3bb773c2ebc8f8;hpb=0d03b82a77743d2ea5ef69bea08735fa12857d92;p=cl-gtk2.git diff --git a/gtk/gtk.main_loop_events.lisp b/gtk/gtk.main_loop_events.lisp index 6c7376a..961b357 100644 --- a/gtk/gtk.main_loop_events.lisp +++ b/gtk/gtk.main_loop_events.lisp @@ -17,24 +17,52 @@ (error "Cannot initialize Gtk+")) (foreign-free (mem-ref argv '(:pointer :string)))))) -(gtk-init) +(at-init () (gtk-init)) -(defcfun gtk-test-register-all-types :void) +(defcfun gtk-main :void) -(gtk-test-register-all-types) +#+thread-support +(defvar *main-thread* nil) -(defcfun gtk-events-pending :boolean) +#+thread-support +(at-finalize () + (when (and *main-thread* (bt:thread-alive-p *main-thread*)) + (bt:destroy-thread *main-thread*) + (setf *main-thread* nil))) -(defcfun gtk-main :void) +#+thread-support +(defun ensure-gtk-main () + (when (and *main-thread* (not (bt:thread-alive-p *main-thread*))) + (setf *main-thread* nil)) + (unless *main-thread* + (setf *main-thread* (bt:make-thread (lambda () (gtk-main)) :name "cl-gtk2 main thread")))) -(defcfun gtk-main-level :uint) +#+thread-support +(defun join-main-thread () + (when *main-thread* + (bt:join-thread *main-thread*))) -(defcfun gtk-main-quit :void) +#+thread-support +(export 'join-main-thread) + +#-thread-support +(defun ensure-gtk-main () + (gtk-main)) + +(export 'ensure-gtk-main) -(defcfun gtk-main-iteration :boolean) +#+thread-support +(defun leave-gtk-main ()) ;noop on multithreading -(defcfun gtk-main-iteration-do :boolean - (blocking :boolean)) +#-thread-support +(defun leave-gtk-main () + (gtk-main-quit)) + +(export 'leave-gtk-main) + +(defcfun gtk-main-level :uint) + +(defcfun gtk-main-quit :void) (defcfun gtk-grab-add :void (widget g-object))