Added the start() function and fixed compilation errors. Everything seems to work...
This commit is contained in:
parent
9eb9aa82c0
commit
f7dedc8cb0
|
@ -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")
|
var spacingTest = flag.Bool("spacing", false, "margins and padding on Window")
|
||||||
|
|
||||||
func myMain() {
|
func myMain() {
|
||||||
<-Ready
|
|
||||||
if *spacetest != "" {
|
if *spacetest != "" {
|
||||||
spaceTest()
|
spaceTest()
|
||||||
return
|
return
|
||||||
|
@ -554,8 +553,7 @@ func (handler *dialoghandler) setUpEvents() {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
go myMain()
|
err := Go(myMain)
|
||||||
err := Go()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
10
uitask.go
10
uitask.go
|
@ -6,9 +6,9 @@ import (
|
||||||
"runtime"
|
"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.
|
// 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.
|
// 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.
|
// 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.
|
// 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.
|
// 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()
|
runtime.LockOSThread()
|
||||||
if err := uiinit(); err != nil {
|
if err := uiinit(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
Ready <- struct{}{}
|
start()
|
||||||
close(Ready)
|
|
||||||
ui()
|
ui()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO this needs to be replaced with a function
|
||||||
// Stop should be pulsed when you are ready for Go() to return.
|
// 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.
|
// 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.
|
// Do not pulse Stop more than once.
|
||||||
|
|
|
@ -4,7 +4,6 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// #cgo CFLAGS: -mmacosx-version-min=10.7 -DMACOSX_DEPLOYMENT_TARGET=10.7
|
// #cgo CFLAGS: -mmacosx-version-min=10.7 -DMACOSX_DEPLOYMENT_TARGET=10.7
|
||||||
|
|
|
@ -6,7 +6,6 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// #cgo pkg-config: gtk+-3.0
|
// #cgo pkg-config: gtk+-3.0
|
||||||
|
|
Loading…
Reference in New Issue