summaryrefslogtreecommitdiff
path: root/gtkcalls_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-12 20:00:29 -0400
committerPietro Gagliardi <[email protected]>2014-03-12 20:00:29 -0400
commit55f7a9638ebcd2dfb78394cf396f2edac926baaf (patch)
tree64cca732f0d86f55215e20cd89c3442cb6f45231 /gtkcalls_unix.go
parent1729764db8663b677c438673ab86dcfdb1444f27 (diff)
Changed the way uitask is dispatched on GTK+ to make event handling not a CPU hog.
Diffstat (limited to 'gtkcalls_unix.go')
-rw-r--r--gtkcalls_unix.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index 5a1a1ae..811287b 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -24,12 +24,14 @@ func gtk_init() bool {
return fromgbool(C.gtk_init_check((*C.int)(nil), (***C.char)(nil)))
}
-// the garbage collector has been found to eat my callback functions; this will stop it
-var callbackstore = make([]*func() bool, 0, 50)
+// see our_idle_callback in callbacks_unix.go for details
+type gtkIdleOp struct {
+ what func()
+ done chan struct{}
+}
-func gdk_threads_add_idle(what func() bool) {
- callbackstore = append(callbackstore, &what)
- C.gdk_threads_add_idle(callbacks["idle"], C.gpointer(unsafe.Pointer(&what)))
+func gdk_threads_add_idle(idleop *gtkIdleOp) {
+ C.gdk_threads_add_idle(callbacks["idle"], C.gpointer(unsafe.Pointer(idleop)))
}
func gtk_main() {
@@ -45,6 +47,9 @@ func gtk_window_new() *gtkWidget {
return fromgtkwidget(C.gtk_window_new(0))
}
+// the garbage collector has been found to eat my callback functions; this will stop it
+var callbackstore = make([]*func() bool, 0, 50)
+
func g_signal_connect(obj *gtkWidget, sig string, callback func() bool) {
callbackstore = append(callbackstore, &callback)
ccallback := callbacks[sig]