diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go index d5dc319..f622739 100644 --- a/gtkcalls_unix.go +++ b/gtkcalls_unix.go @@ -14,9 +14,16 @@ import ( // #include "gtk_unix.h" import "C" -func gtk_init() bool { +func gtk_init() error { + var err *C.GError = nil // redundant in Go, but let's explicitly assign it anyway + + // gtk_init_with_args() gives us error info (thanks chpe in irc.gimp.net/#gtk+) // TODO allow GTK+ standard command-line argument processing - return fromgbool(C.gtk_init_check((*C.int)(nil), (***C.char)(nil))) + result := C.gtk_init_with_args(nil, nil, nil, nil, nil, &err) + if result == C.FALSE { + return fmt.Errorf("%s", fromgstr(err.message)) + } + return nil } func gtk_main() { @@ -71,7 +78,7 @@ var gtkLayoutCSS = []byte(`GtkLayout { `) func makeTransparent(layout *C.GtkWidget) { - var err *C.GError = nil // redundant in Go, but let's explicitly assign it anyway + var err *C.GError = nil provider := C.gtk_css_provider_new() added := C.gtk_css_provider_load_from_data(provider, diff --git a/uitask_unix.go b/uitask_unix.go index 7d68057..ccad346 100644 --- a/uitask_unix.go +++ b/uitask_unix.go @@ -15,8 +15,9 @@ func ui(main func()) error { runtime.LockOSThread() uitask = make(chan func()) - if gtk_init() != true { - return fmt.Errorf("gtk_init failed (reason unknown; TODO)") + err := gtk_init() + if err != nil { + return fmt.Errorf("gtk_init() failed: %v", err) } // thanks to tristan and Daniel_S in irc.gimp.net/#gtk