guireleaser/main.go

129 lines
3.0 KiB
Go
Raw Normal View History

// This is a simple example
package main
import (
"os/user"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui/gadgets/repostatus"
)
func main() {
myGui = gui.New().Default()
repoworld()
gui.Watchdog()
}
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
newRepo := new(repo)
if repostatus.VerifyLocalGoRepo(path) {
log.Warn("newRepo actually exists", newRepo.getPath())
} else {
log.Warn("newRepo does not exist", newRepo.getPath())
return
}
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
newRepo.bLabel = grid.NewLabel("")
newRepo.lastLabel = grid.NewLabel("")
newRepo.vLabel = grid.NewLabel("")
newRepo.masterVersion = grid.NewLabel("")
newRepo.develVersion = grid.NewLabel("")
newRepo.jcarrVersion = grid.NewLabel("")
newRepo.dirtyLabel = grid.NewLabel("")
newRepo.pButton = grid.NewButton("rescan", func () {
newRepo.newScan()
})
grid.NewButton("Toggle()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
return
}
log.Warn("status window exists. trying Show() here")
newRepo.status.Show()
})
grid.NewButton("TestDraw()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
return
}
log.Warn("status window exists. trying TestDraw() here")
newRepo.status.TestDraw()
})
if path == "" {
newRepo.cButton.Hide()
newRepo.pButton.Hide()
}
newRepo.status = repostatus.New(myGui, newRepo.path)
newRepo.status.SetMasterName(master)
newRepo.status.SetDevelName(devel)
newRepo.status.SetUserName(user)
newRepo.status.Update()
newRepo.newScan()
allrepos = append(allrepos, newRepo)
}
// This creates a window
func repoworld() {
win := gadgets.NewBasicWindow(myGui, "git autotypist. it types faster than you can.")
box := win.Box().NewBox("bw vbox", false)
// box2 := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("go repositories (read from ~/.config/myrepolist)")
grid := group.NewGrid("test", 11, 1)
grid.Margin()
grid.NewLabel("")
grid.NewLabel("branch")
grid.NewLabel("last tag")
grid.NewLabel("Current Version")
// grid.NewLabel("tags")
grid.NewLabel("master")
grid.NewLabel("devel")
grid.NewLabel("user")
grid.NewLabel("Status")
grid.NewLabel("commit")
grid.NewLabel("Toggle()")
grid.NewLabel("Draw()")
repos := myrepolist()
for _, line := range repos {
log.Warn("repo =", line)
path, mbranch, dbranch, ubranch := splitLine(line)
if mbranch == "" { mbranch = "master" }
if dbranch == "" { dbranch = "devel" }
usr, _ := user.Current()
if ubranch == "" { ubranch = usr.Username }
addRepo(grid, path, mbranch, dbranch, ubranch)
}
box2 := win.Box().NewBox("bw vbox", false)
box2.NewButton("grid.Pad()", func () {
grid.Margin()
})
box2.NewButton("status.Update() all", func () {
for _, repo := range allrepos {
repo.status.Update()
}
})
box2.NewButton("rescan all", func () {
for _, repo := range allrepos {
repo.newScan()
}
})
win.Draw()
}