2014-07-17 22:50:14 -05:00
|
|
|
// +build !windows,!darwin
|
2014-07-08 15:47:28 -05:00
|
|
|
|
2014-07-07 20:04:44 -05:00
|
|
|
// 7 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
2014-07-21 15:08:22 -05:00
|
|
|
"fmt"
|
2014-07-07 20:04:44 -05:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #cgo pkg-config: gtk+-3.0
|
2014-08-14 09:26:09 -05:00
|
|
|
// #cgo CFLAGS: --std=c99
|
2014-07-07 20:04:44 -05:00
|
|
|
// #include "gtk_unix.h"
|
2014-08-19 12:33:06 -05:00
|
|
|
// extern gboolean xdoissue(gpointer data);
|
2014-07-07 20:04:44 -05:00
|
|
|
import "C"
|
|
|
|
|
|
|
|
func uiinit() error {
|
2014-10-02 09:05:53 -05:00
|
|
|
var err *C.GError = nil // redundant in Go, but let's explicitly assign it anyway
|
2014-07-21 15:08:22 -05:00
|
|
|
|
|
|
|
// gtk_init_with_args() gives us error info (thanks chpe in irc.gimp.net/#gtk+)
|
|
|
|
// don't worry about GTK+'s command-line arguments; they're also available as environment variables (thanks mclasen in irc.gimp.net/#gtk+)
|
|
|
|
result := C.gtk_init_with_args(nil, nil, nil, nil, nil, &err)
|
|
|
|
if result == C.FALSE {
|
|
|
|
return fmt.Errorf("error actually initilaizing GTK+: %s", fromgstr(err.message))
|
|
|
|
}
|
2014-07-07 20:04:44 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func uimsgloop() {
|
|
|
|
C.gtk_main()
|
|
|
|
}
|
|
|
|
|
2014-07-13 19:31:08 -05:00
|
|
|
func uistop() {
|
|
|
|
C.gtk_main_quit()
|
|
|
|
}
|
|
|
|
|
2014-08-11 20:57:20 -05:00
|
|
|
func issue(f *func()) {
|
2014-08-26 14:39:04 -05:00
|
|
|
C.gdk_threads_add_idle(C.GSourceFunc(C.xdoissue), C.gpointer(unsafe.Pointer(f)))
|
2014-07-07 20:04:44 -05:00
|
|
|
}
|
|
|
|
|
2014-08-19 12:33:06 -05:00
|
|
|
//export xdoissue
|
|
|
|
func xdoissue(data C.gpointer) C.gboolean {
|
2014-07-19 08:57:01 -05:00
|
|
|
perform(unsafe.Pointer(data))
|
2014-10-02 09:05:53 -05:00
|
|
|
return C.FALSE // don't repeat
|
2014-07-07 20:04:44 -05:00
|
|
|
}
|
2014-08-19 12:33:06 -05:00
|
|
|
|
|
|
|
//export doissue
|
|
|
|
func doissue(data unsafe.Pointer) {
|
|
|
|
// for the modal queue functions
|
|
|
|
perform(data)
|
|
|
|
}
|