File: threads.scm

package info (click to toggle)
guile-gtk-1.2 0.31-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,544 kB
  • ctags: 2,413
  • sloc: sh: 11,073; ansic: 3,380; lisp: 1,058; makefile: 106
file content (24 lines) | stat: -rw-r--r-- 555 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(define-module (gtk-1.2 threads)
  :use-module (gtk-1.2 gtk)
  :use-module (gtk-1.2 gdk)
  :use-module (ice-9 threads))

(export gtk-threads-handler? gtk-threads-ensure-handler)

(define handler-running? #f)

(define (gtk-threads-handler?)
  handler-running?)

(define (gtk-threads-ensure-handler)
  (if (not handler-running?)
      (begin-thread
       (dynamic-wind
	   (lambda ()
	     (gdk-threads-enter)
	     (set! handler-running? #t))
	   (lambda ()
	     (gtk-main))
	   (lambda ()
	     (set! handler-running? #f)
	     (gdk-threads-leave))))))