From f7dedc8cb05960134234f242042a4f00d88aaf9e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 3 Jul 2014 10:27:46 -0400 Subject: [PATCH] Added the start() function and fixed compilation errors. Everything seems to work... --- test/main.go | 4 +--- uitask.go | 10 +++++----- uitask_darwin.go | 1 - uitask_unix.go | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/main.go b/test/main.go index 3787d0c..da6a8eb 100644 --- a/test/main.go +++ b/test/main.go @@ -293,7 +293,6 @@ var labelAlignTest = flag.Bool("label", false, "show Label Alignment test window var spacingTest = flag.Bool("spacing", false, "margins and padding on Window") func myMain() { - <-Ready if *spacetest != "" { spaceTest() return @@ -554,8 +553,7 @@ func (handler *dialoghandler) setUpEvents() { func main() { flag.Parse() - go myMain() - err := Go() + err := Go(myMain) if err != nil { panic(err) } diff --git a/uitask.go b/uitask.go index 1da6994..fceab1b 100644 --- a/uitask.go +++ b/uitask.go @@ -6,9 +6,9 @@ import ( "runtime" ) -// Go sets up the UI environment and pulses Ready. +// Go sets up the UI environment. // If initialization fails, Go returns an error and Ready is not pulsed. -// Otherwise, Go does not return to its caller until Stop is pulsed, at which point Go() will return nil. +// Otherwise, Go first runs start(), which should contain code to create the first Window, and then fires up the event loop, not returning to its caller until Stop is pulsed, at which point Go() will return nil. // After Go() returns, you cannot call future ui functions/methods meaningfully. // Pulsing Stop will cause Go() to return immediately; the programmer is responsible for cleaning up (for instance, hiding open Windows) beforehand. // @@ -16,17 +16,17 @@ import ( // // Go() does not process the command line for flags (that is, it does not call flag.Parse()), nor does package ui add any of the underlying toolkit's supported command-line flags. // If you must, and if the toolkit also has environment variable equivalents to these flags (for instance, GTK+), use those instead. -func Go() error { +func Go(start func()) error { runtime.LockOSThread() if err := uiinit(); err != nil { return err } - Ready <- struct{}{} - close(Ready) + start() ui() return nil } +// TODO this needs to be replaced with a function // Stop should be pulsed when you are ready for Go() to return. // Pulsing Stop will cause Go() to return immediately; the programmer is responsible for cleaning up (for instance, hiding open Windows) beforehand. // Do not pulse Stop more than once. diff --git a/uitask_darwin.go b/uitask_darwin.go index d4734d5..d4bc842 100644 --- a/uitask_darwin.go +++ b/uitask_darwin.go @@ -4,7 +4,6 @@ package ui import ( "fmt" - "unsafe" ) // #cgo CFLAGS: -mmacosx-version-min=10.7 -DMACOSX_DEPLOYMENT_TARGET=10.7 diff --git a/uitask_unix.go b/uitask_unix.go index 70fddae..3ea7617 100644 --- a/uitask_unix.go +++ b/uitask_unix.go @@ -6,7 +6,6 @@ package ui import ( "fmt" - "unsafe" ) // #cgo pkg-config: gtk+-3.0