3 (defcfun gtk-init-check
:boolean
5 (argv (:pointer
(:pointer
:string
))))
8 (gtk-init-check (foreign-alloc :int
:initial-element
0)
9 (foreign-alloc :string
:initial-contents
'("/usr/bin/sbcl")))
10 #+nil
(with-foreign-objects ((argc :int
)
11 (argv '(:pointer
:string
) 1))
12 (setf (mem-ref argc
:int
) 0
13 (mem-ref argv
'(:pointer
:string
)) (foreign-alloc :string
:count
1
14 :initial-element
"/usr/bin/sbcl"))
16 (unless (gtk-init-check argc argv
)
17 (error "Cannot initialize Gtk+"))
18 (foreign-free (mem-ref argv
'(:pointer
:string
))))))
20 (at-init () (gtk-init))
22 (defcfun (%gtk-main
"gtk_main") :void
)
25 (with-gdk-threads-lock (%gtk-main
)))
29 (defvar *main-thread
* nil
)
30 (defvar *main-thread-level
* nil
)
31 (defvar *main-thread-lock
* (bt:make-lock
"*main-thread* lock"))
34 (when (and *main-thread
* (bt:thread-alive-p
*main-thread
*))
35 (bt:destroy-thread
*main-thread
*)
36 (setf *main-thread
* nil
)))
38 (defun ensure-gtk-main ()
39 (bt:with-lock-held
(*main-thread-lock
*)
40 (when (and *main-thread
* (not (bt:thread-alive-p
*main-thread
*)))
41 (setf *main-thread
* nil
))
43 (setf *main-thread
* (bt:make-thread
(lambda () (gtk-main)) :name
"cl-gtk2 main thread")
44 *main-thread-level
* 0))
45 (incf *main-thread-level
*))
48 (defun join-gtk-main ()
50 (bt:join-thread
*main-thread
*)))
52 (defun leave-gtk-main ()
53 (bt:with-lock-held
(*main-thread-lock
*)
54 (decf *main-thread-level
*)
55 (when (zerop *main-thread-level
*)
60 (defun ensure-gtk-main ()
64 (defun leave-gtk-main ()
67 (defun join-gtk-main ()))
69 (export 'ensure-gtk-main
)
71 (export 'leave-gtk-main
)
73 (export 'join-gtk-main
)
75 (defcfun gtk-main-level
:uint
)
77 (defcfun gtk-main-quit
:void
)
79 (defcfun gtk-grab-add
:void
82 (defcfun gtk-grab-get-current g-object
)
84 (defcfun gtk-grab-remove
:void