Add Gdk/Threads
authorDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sat, 14 Nov 2009 02:31:30 +0000 (05:31 +0300)
committerDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sat, 14 Nov 2009 02:31:30 +0000 (05:31 +0300)
gdk/cl-gtk2-gdk.asd
gdk/gdk.threads.lisp [new file with mode: 0644]

index 35692b5..80ccca8 100644 (file)
@@ -5,6 +5,7 @@
   :license "LLGPL"
   :serial t
   :components ((:file "gdk.package")
+               (:file "gdk.threads")
                (:file "gdk.objects")
                (:file "gdk.functions")
                (:file "gdk.general")
diff --git a/gdk/gdk.threads.lisp b/gdk/gdk.threads.lisp
new file mode 100644 (file)
index 0000000..268c05a
--- /dev/null
@@ -0,0 +1,64 @@
+(in-package :gdk)
+
+(defcfun gdk-threads-init :void)
+(glib:at-init () (gdk-threads-init))
+
+(defcfun gdk-threads-enter :void)
+(export 'gdk-threads-enter)
+
+(defcfun gdk-threads-leave :void)
+(export 'gdk-threads-leave)
+
+;; void                gdk_threads_set_lock_functions      (GCallback enter_fn,
+;;                                                          GCallback leave_fn);
+
+(defcallback source-func-callback :boolean
+    ((data :pointer))
+  (funcall (stable-pointer-value data)))
+
+(defcallback stable-pointer-free-destroy-notify-callback :void ((data :pointer))
+  (free-stable-pointer data))
+
+(defcfun gdk_threads_add_idle_full :uint
+  (priority :int)
+  (function :pointer)
+  (data :pointer)
+  (destroy-notify :pointer))
+
+(defun gdk-threads-add-idle-full (priority function)
+  (gdk_threads_add_idle_full priority
+                             (callback source-func-callback)
+                             (allocate-stable-pointer function)
+                             (callback stable-pointer-free-destroy-notify-callback)))
+
+(export 'gdk-threads-add-idle-full)
+
+(defcfun gdk_threads_add_timeout_full :uint
+  (priority :int)
+  (interval :uint)
+  (function :pointer)
+  (data :pointer)
+  (destroy-notify :pointer))
+
+(defun gdk-threads-add-timeout-full (priority interval-msec function)
+  (gdk_threads_add_timeout_full priority interval-msec
+                                (callback source-func-callback)
+                                (allocate-stable-pointer function)
+                                (callback stable-pointer-free-destroy-notify-callback)))
+
+(export 'gdk-threads-add-timeout-full)
+
+(defcfun gdk_threads_add_timeout_seconds_full :uint
+  (priority :int)
+  (interval :uint)
+  (function :pointer)
+  (data :pointer)
+  (destroy-notify :pointer))
+
+(defun gdk-threads-add-timeout-seconds-full (priority interval-sec function)
+  (gdk_threads_add_timeout_seconds_full priority interval-sec
+                                        (callback source-func-callback)
+                                        (allocate-stable-pointer function)
+                                        (callback stable-pointer-free-destroy-notify-callback)))
+
+(export 'gdk-threads-add-timeout-seconds-full)