Exemplo n.º 1
0
Arquivo: gtk.go Projeto: evmar/smash
func (ui *UI) Enqueue(f func()) {
	// Proxy the function to the main thread by using g_idle_add.
	// You'd be tempted to want to pass f to g_idle_add directly, but
	// (a) passing closures into C code is annoying, and (b) we need a
	// reference to the function on the Go side for GC reasons.  So
	// it's easier to just put the function in a channel that pulls it
	// back out on the other thread.
	ui.enqueued <- f
	C.g_idle_add(C.GSourceFunc(C.smash_idle_cb), globalPointerStore.Key(ui))
}
Exemplo n.º 2
0
func issue(f *func()) {
	C.gdk_threads_add_idle(C.GSourceFunc(C.xdoissue), C.gpointer(unsafe.Pointer(f)))
}