2014-02-16 14:55:51 -06:00
|
|
|
// +build !windows,!darwin,!plan9
|
|
|
|
|
|
|
|
// 16 february 2014
|
|
|
|
//package ui
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
var uitask chan func()
|
|
|
|
|
|
|
|
func ui(initDone chan error) {
|
|
|
|
runtime.LockOSThread()
|
|
|
|
|
|
|
|
uitask = make(chan func())
|
|
|
|
if gtk_init() != true {
|
|
|
|
initDone <- fmt.Errorf("gtk_init failed (reason unknown; TODO)")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
initDone <- nil
|
|
|
|
|
2014-02-16 16:09:58 -06:00
|
|
|
// thanks to tristan in irc.gimp.net/#gtk
|
|
|
|
gdk_threads_add_idle(func() bool {
|
|
|
|
select {
|
|
|
|
case f := <-uitask:
|
|
|
|
f()
|
|
|
|
default: // do not block
|
|
|
|
}
|
|
|
|
return true // don't destroy the callback
|
|
|
|
})
|
2014-02-16 14:55:51 -06:00
|
|
|
gtk_main()
|
|
|
|
}
|
|
|
|
|
|
|
|
// temporary
|
|
|
|
func MsgBox(string, string, ...interface{}) {}
|
|
|
|
func MsgBoxError(title string, text string, args ...interface{}) {panic(title+"\n"+fmt.Sprintf(text,args...))}
|