migrate gui/splash.go

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-01 01:19:51 -07:00
parent b7445ffea4
commit d1dafb54dd
2 changed files with 33 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import "github.com/Showmax/go-fqdn"
var GITCOMMIT string // this is passed in as an ldflag
var GOVERSION string // this is passed in as an ldflag
var BUILDTIME string // this is passed in as an ldflag
const VERSION = "0.2"
// use mergo to merge structs
// import "github.com/imdario/mergo"
@ -120,10 +121,6 @@ func main() {
ipAAAA := lookupAAAA(hostname)
gui.Data.IPv6 = ipAAAA
gui.Data.Version = "v0.2"
gui.Data.GitCommit = GITCOMMIT
gui.Data.GoVersion = GOVERSION
gui.Data.Buildtime = BUILDTIME
gui.Data.MouseClick = mainMouseClick
gui.Data.HomeDir = user.HomeDir
@ -144,7 +141,7 @@ func main() {
// make this the main loop in an attempt to figure out the crashes
// do not change this until the GUI is stable
gui.StartNewWindow(config, false, "SPLASH", getNEWTEXT)
gui.StartNewWindow(config, false, "SPLASH", showSplashBox)
}
// This is the handler for all mosue clicks (buttons, areas, etc))

View File

@ -1,5 +1,8 @@
package main
import "log"
import "runtime"
import "git.wit.com/wit/gui"
import "github.com/andlabs/ui"
@ -35,3 +38,31 @@ func getNEWTEXT() *ui.AttributedString {
return aText
}
func showSplashBox(gw *gui.GuiWindow) *gui.GuiBox{
log.Println("ShowSplashBox() START")
text := getNEWTEXT()
box := gui.ShowTextBox(gw, text)
if runtime.GOOS == "linux" {
gui.NewLabel(box,"OS: Linux")
} else if runtime.GOOS == "windows" {
gui.NewLabel(box,"OS: Windows")
} else {
gui.NewLabel(box,"OS: " + runtime.GOOS)
}
gui.NewLabel(box, "Version: " + VERSION)
if (config.Debug) {
gui.NewLabel(box, "git rev-list: " + GITCOMMIT)
gui.NewLabel(box, "go build version: " + GOVERSION)
gui.NewLabel(box, "build date: " + BUILDTIME)
}
okButton := gui.CreateButton(box, nil, nil, "OK", "AREA", nil)
gui.AddButtonToBox(box, okButton)
log.Println("ShowSplashBox() END box =", box)
return box
}