submit-patchset/main.go

169 lines
4.0 KiB
Go
Raw Normal View History

// This is a simple example
package main
import (
"io/ioutil"
"strings"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/apps/control-panel-dns/smartwindow"
)
var myGui *gui.Node
var allrepos []*repo
type repo struct {
path string
lasttagrev string
lasttag string
tags []string
pLabel *gui.Node // path label
bLabel *gui.Node // branch label
lastLabel *gui.Node // last tagged version label
vLabel *gui.Node // version label
tagsDrop *gui.Node // list of all tags
dirtyLabel *gui.Node // git state (dirty or not?)
masterVersion *gui.Node // the master branch version
develVersion *gui.Node // the devel branch version
jcarrVersion *gui.Node // the jcarr branch version
cButton *gui.Node // commit button
pButton *gui.Node // push button
}
func main() {
myGui = gui.New().Default()
helloworld()
checkrepos()
for _, r := range allrepos {
r.checkoutBranch("master")
r.checkoutBranch("devel")
r.checkoutBranch("jcarr")
}
gui.Watchdog()
}
func addRepo(grid *gui.Node, path string) *repo {
newRepo := new(repo)
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
newRepo.bLabel = grid.NewLabel("")
newRepo.lastLabel = grid.NewLabel("")
newRepo.vLabel = grid.NewLabel("")
newRepo.tagsDrop = grid.NewDropdown("tags")
newRepo.masterVersion = grid.NewLabel("")
newRepo.develVersion = grid.NewLabel("")
newRepo.jcarrVersion = grid.NewLabel("")
newRepo.dirtyLabel = grid.NewLabel("")
newRepo.cButton = grid.NewButton("commit", func () {
log.Println("commit")
})
newRepo.pButton = grid.NewButton("push", func () {
log.Println("push")
})
if path == "" { return newRepo }
allrepos = append(allrepos, newRepo)
return newRepo
}
// This creates a window
func helloworld() {
win := gadgets.NewBasicWindow(myGui, "helloworld golang wit/gui window")
box := win.Box().NewBox("bw vbox", false)
box2 := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("test")
grid := group.NewGrid("test", 11, 1)
grid.NewLabel("go repo")
grid.NewLabel("branch")
grid.NewLabel("last tag")
grid.NewLabel("Version")
grid.NewLabel("tags")
grid.NewLabel("master")
grid.NewLabel("devel")
grid.NewLabel("jcarr")
grid.NewLabel("is dirty?")
grid.NewLabel("commit")
grid.NewLabel("push to")
content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
out := string(content)
out = strings.TrimSpace(out)
lines := strings.Split(out, "\n")
for _, repo := range lines {
log.Warn("repo =", repo)
addRepo(grid, repo)
}
/*
addRepo(grid, "go.wit.com/arg")
addRepo(grid, "go.wit.com/spew")
addRepo(grid, "go.wit.com/shell")
addRepo(grid, "")
addRepo(grid, "go.wit.com/gui/gui")
addRepo(grid, "go.wit.com/gui/widget")
addRepo(grid, "go.wit.com/gui/toolkits")
addRepo(grid, "go.wit.com/gui/debugger")
addRepo(grid, "go.wit.com/gui/gadgets")
addRepo(grid, "go.wit.com/gui/digitalocean")
addRepo(grid, "go.wit.com/gui/cloudflare")
addRepo(grid, "")
addRepo(grid, "go.wit.com/apps/control-panel-vpn")
addRepo(grid, "go.wit.com/apps/control-panel-dns")
addRepo(grid, "go.wit.com/apps/control-panel-digitalocean")
addRepo(grid, "go.wit.com/apps/control-panel-cloudflare")
addRepo(grid, "go.wit.com/apps/myrepos")
*/
box2.NewButton("checkout jcarr (all repos)", func () {
for _, r := range allrepos {
r.checkoutBranch("jcarr")
}
})
box2.NewButton("checkout devel (all repos)", func () {
for _, r := range allrepos {
r.checkoutBranch("devel")
}
})
box2.NewButton("checkout master (all repos)", func () {
for _, r := range allrepos {
r.checkoutBranch("master")
}
})
box2.NewButton("hello", func () {
log.Println("world")
hellosmart()
})
}
// This creates a window
func hellosmart() {
win := smartwindow.New()
win.SetParent(myGui)
win.InitWindow()
win.Title("helloworld golang wit/gui window")
win.Vertical()
win.SetDraw(smartDraw)
win.Make()
win.Box().NewButton("test smartwindow", func () {
log.Println("smart")
})
}
func smartDraw(sw *smartwindow.SmartWindow) {
sw.Box().NewButton("hello", func () {
log.Println("smart")
})
}