X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=gtk%2Fgtk.main_loop_events.lisp;h=961b357f5334e11ea31a12778f79a042a7192cf3;hb=c5a046da8c5ca824b266ff48034a860790dc1aa3;hp=a98262c206a01d0339dc6e6c38ba6ea2f2176135;hpb=500d18cd286348c598c6644a31f7cd7867b37f98;p=cl-gtk2.git diff --git a/gtk/gtk.main_loop_events.lisp b/gtk/gtk.main_loop_events.lisp index a98262c..961b357 100644 --- a/gtk/gtk.main_loop_events.lisp +++ b/gtk/gtk.main_loop_events.lisp @@ -17,20 +17,33 @@ (error "Cannot initialize Gtk+")) (foreign-free (mem-ref argv '(:pointer :string)))))) -(gtk-init) +(at-init () (gtk-init)) -(defcfun gtk-test-register-all-types :void) - -(gtk-test-register-all-types) +(defcfun gtk-main :void) -(defcfun gtk-events-pending :boolean) +#+thread-support +(defvar *main-thread* nil) -(defcfun gtk-main :void) +#+thread-support +(at-finalize () + (when (and *main-thread* (bt:thread-alive-p *main-thread*)) + (bt:destroy-thread *main-thread*) + (setf *main-thread* nil))) #+thread-support (defun ensure-gtk-main () - (unless (find "gtk main thread" (bt:all-threads) :test 'string= :key 'bt:thread-name) - (bt:make-thread (lambda () (gtk:gtk-main)) :name "gtk main thread"))) + (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")))) + +#+thread-support +(defun join-main-thread () + (when *main-thread* + (bt:join-thread *main-thread*))) + +#+thread-support +(export 'join-main-thread) #-thread-support (defun ensure-gtk-main () @@ -51,11 +64,6 @@ (defcfun gtk-main-quit :void) -(defcfun gtk-main-iteration :boolean) - -(defcfun gtk-main-iteration-do :boolean - (blocking :boolean)) - (defcfun gtk-grab-add :void (widget g-object))