2019-05-24 02:53:34 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "time"
|
|
|
|
import "fmt"
|
2019-05-24 11:02:35 -05:00
|
|
|
import "strings"
|
|
|
|
import "os/exec"
|
2019-05-24 13:32:47 -05:00
|
|
|
import "runtime"
|
2019-05-24 02:53:34 -05:00
|
|
|
|
|
|
|
import "github.com/gookit/config"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-24 17:35:41 -05:00
|
|
|
import "github.com/davecgh/go-spew/spew"
|
2019-05-24 02:53:34 -05:00
|
|
|
|
2019-05-24 17:35:41 -05:00
|
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
2019-05-24 02:53:34 -05:00
|
|
|
|
|
|
|
// can not pass any args to this (?)
|
|
|
|
func setupCloudUI() {
|
2019-05-24 13:32:47 -05:00
|
|
|
Data.cloudWindow = ui.NewWindow("Cloud Control Panel", Data.Width, config.Int("height"), false)
|
2019-05-24 02:53:34 -05:00
|
|
|
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
|
|
|
|
ui.Quit()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
ui.OnShouldQuit(func() bool {
|
|
|
|
Data.cloudWindow.Destroy()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
Data.cloudTab = ui.NewTab()
|
|
|
|
Data.cloudWindow.SetChild(Data.cloudTab)
|
|
|
|
Data.cloudWindow.SetMargined(true)
|
|
|
|
|
|
|
|
Data.tabcount = 0
|
|
|
|
Data.cloudTab.Append("Cloud Info", makeCloudInfoBox(nil))
|
|
|
|
Data.cloudTab.SetMargined(Data.tabcount, true)
|
|
|
|
|
|
|
|
Data.cloudWindow.Show()
|
|
|
|
}
|
|
|
|
|
|
|
|
func addTableTab() {
|
|
|
|
var parts []TableColumnData
|
|
|
|
|
|
|
|
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
|
|
|
log.Println(key, foo)
|
|
|
|
|
|
|
|
var b TableColumnData
|
|
|
|
b.CellType = foo
|
|
|
|
b.Heading = fmt.Sprintf("heading%d", key)
|
|
|
|
parts = append(parts, b)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
|
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
|
|
|
AddTableTab(Data.cloudTab, 1, "test seven", 7, parts)
|
|
|
|
}
|
|
|
|
|
2019-05-24 15:23:50 -05:00
|
|
|
func addDebuggingButtons(vbox *ui.Box, custom func(*ButtonMap)) {
|
2019-05-24 02:53:34 -05:00
|
|
|
vbox.Append(ui.NewLabel("Debugging:"), false)
|
|
|
|
|
|
|
|
vbox.Append(ui.NewColorButton(), false)
|
|
|
|
vbox.Append(CreateButton("Add Account", "ADD", custom), false)
|
|
|
|
vbox.Append(CreateButton("Quit", "QUIT", custom), false)
|
|
|
|
|
|
|
|
// ATTEMPT TO ADD THE TABLE HERE
|
|
|
|
add2button := ui.NewButton("Add a Test Table")
|
|
|
|
add2button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("send over socket")
|
|
|
|
addTableTab()
|
|
|
|
})
|
|
|
|
vbox.Append(add2button, false)
|
|
|
|
// ATTEMPT TO ADD THE TABLE HERE END
|
|
|
|
|
|
|
|
vbox.Append(CreateButton("Close GUI", "QUIT", custom), false)
|
|
|
|
vbox.Append(CreateButton("DEBUG goroutines", "DEBUG", custom), false)
|
2019-05-24 17:35:41 -05:00
|
|
|
// vbox.Append(CreateButton("ping", "PING", runPingClick), false)
|
2019-05-24 11:02:35 -05:00
|
|
|
vbox.Append(CreateButton("xterm", "XTERM", runTestExecClick), false)
|
2019-05-24 13:32:47 -05:00
|
|
|
vbox.Append(CreateButton("Load test.json config file", "CONFIG", custom), false)
|
2019-05-24 11:02:35 -05:00
|
|
|
}
|
|
|
|
|
2019-05-24 17:35:41 -05:00
|
|
|
func runPingClick(b *ButtonMap) {
|
|
|
|
log.Println("runPingClick START")
|
|
|
|
spew.Dump(b)
|
|
|
|
var tmp []string
|
|
|
|
tmp = append(tmp, "xterm", "-e", "ping localhost")
|
|
|
|
runCommand(tmp)
|
|
|
|
log.Println("runPingClick END")
|
|
|
|
}
|
|
|
|
|
2019-05-24 15:23:50 -05:00
|
|
|
func runTestExecClick(b *ButtonMap) {
|
2019-05-24 11:02:35 -05:00
|
|
|
log.Println("runTestExecClick START")
|
2019-05-24 13:32:47 -05:00
|
|
|
if runtime.GOOS == "linux" {
|
2019-05-24 17:35:41 -05:00
|
|
|
go runSimpleCommand("xterm -report-fonts")
|
|
|
|
} else if runtime.GOOS == "windows" {
|
|
|
|
go runSimpleCommand("cmd.exe")
|
2019-05-24 13:32:47 -05:00
|
|
|
} else {
|
2019-05-24 17:35:41 -05:00
|
|
|
go runSimpleCommand("xterm")
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
2019-05-24 11:02:35 -05:00
|
|
|
log.Println("runTestExecClick END")
|
|
|
|
}
|
|
|
|
|
2019-05-24 17:35:41 -05:00
|
|
|
func runSimpleCommand(s string) {
|
|
|
|
cmd := strings.TrimSpace(s) // this is like 'chomp' in perl
|
|
|
|
cmdArgs := strings.Fields(cmd)
|
|
|
|
runCommand(cmdArgs)
|
|
|
|
}
|
|
|
|
|
|
|
|
func runCommand(cmdArgs []string) {
|
2019-05-24 11:02:35 -05:00
|
|
|
log.Println("runXterm START")
|
|
|
|
log.Println("runXterm START")
|
|
|
|
log.Println("runXterm START")
|
2019-05-24 17:35:41 -05:00
|
|
|
log.Println("runXterm START", cmdArgs)
|
2019-05-24 11:02:35 -05:00
|
|
|
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
2019-05-24 17:35:41 -05:00
|
|
|
// process := exec.Command("xterm", "-e", "ping localhost")
|
2019-05-24 11:02:35 -05:00
|
|
|
log.Println("runXterm process.Start()")
|
|
|
|
process.Start()
|
|
|
|
log.Println("runXterm process.Wait()")
|
|
|
|
process.Wait()
|
|
|
|
log.Println("runXterm END")
|
|
|
|
log.Println("runXterm END")
|
|
|
|
log.Println("runXterm END")
|
2019-05-24 02:53:34 -05:00
|
|
|
}
|