Typo
[cl-gtk2.git] / gtk / gtk.main_loop_events.lisp
index 6c7376a..5fbc15f 100644 (file)
 
 (gtk-init)
 
-(defcfun gtk-test-register-all-types :void)
-
-(gtk-test-register-all-types)
-
 (defcfun gtk-events-pending :boolean)
 
 (defcfun gtk-main :void)
 
-(defcfun gtk-main-level :uint)
+#+thread-support
+(defvar *main-thread* nil)
 
-(defcfun gtk-main-quit :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: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 ()
+  (gtk-main))
 
-(defcfun gtk-main-iteration :boolean)
+(export 'ensure-gtk-main)
 
-(defcfun gtk-main-iteration-do :boolean
-  (blocking :boolean))
+#+thread-support
+(defun leave-gtk-main ()) ;noop on multithreading
+
+#-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))