From 54c999bc42acccc5d0ef69a6a6d9d607369debf9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 21 Jul 2014 16:08:22 -0400 Subject: [PATCH] Switched from gtk_init() to the version that lets us catch and report any errors it encounters. --- redo/uitask_unix.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/redo/uitask_unix.go b/redo/uitask_unix.go index b1a556e..a17c0a2 100644 --- a/redo/uitask_unix.go +++ b/redo/uitask_unix.go @@ -5,6 +5,7 @@ package ui import ( + "fmt" "unsafe" ) @@ -14,8 +15,14 @@ import ( import "C" func uiinit() error { - // TODO replace with the error-checking version - C.gtk_init(nil, nil) + 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+) + // 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)) + } return nil }