2024-01-09 01:16:00 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-13 23:27:46 -06:00
|
|
|
"os/user"
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
"go.wit.com/gui/gui"
|
|
|
|
"go.wit.com/gui/gadgets"
|
2024-01-12 23:21:05 -06:00
|
|
|
"go.wit.com/gui/gadgets/repostatus"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
myGui = gui.New().Default()
|
|
|
|
|
2024-01-10 19:44:38 -06:00
|
|
|
repoworld()
|
2024-01-13 21:39:44 -06:00
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
gui.Watchdog()
|
|
|
|
}
|
|
|
|
|
2024-01-13 23:27:46 -06:00
|
|
|
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo := new(repo)
|
|
|
|
|
2024-01-13 21:39:44 -06:00
|
|
|
if repostatus.VerifyLocalGoRepo(path) {
|
|
|
|
log.Warn("newRepo actually exists", newRepo.getPath())
|
|
|
|
} else {
|
|
|
|
log.Warn("newRepo does not exist", newRepo.getPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo.path = path
|
|
|
|
newRepo.pLabel = grid.NewLabel(path)
|
2024-01-09 08:35:07 -06:00
|
|
|
newRepo.bLabel = grid.NewLabel("")
|
|
|
|
newRepo.lastLabel = grid.NewLabel("")
|
|
|
|
newRepo.vLabel = grid.NewLabel("")
|
2024-01-09 09:56:33 -06:00
|
|
|
|
|
|
|
newRepo.masterVersion = grid.NewLabel("")
|
|
|
|
newRepo.develVersion = grid.NewLabel("")
|
|
|
|
newRepo.jcarrVersion = grid.NewLabel("")
|
|
|
|
newRepo.dirtyLabel = grid.NewLabel("")
|
2024-01-09 02:22:01 -06:00
|
|
|
|
2024-01-11 15:57:08 -06:00
|
|
|
newRepo.pButton = grid.NewButton("rescan", func () {
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.newScan()
|
|
|
|
})
|
|
|
|
|
|
|
|
grid.NewButton("Toggle()", func () {
|
|
|
|
if newRepo.status == nil {
|
|
|
|
log.Warn("status window doesn't exist")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Warn("status window exists. trying Update() here")
|
|
|
|
newRepo.status.Toggle()
|
|
|
|
})
|
|
|
|
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()
|
2024-01-09 02:00:51 -06:00
|
|
|
})
|
2024-01-10 19:44:38 -06:00
|
|
|
if path == "" {
|
|
|
|
newRepo.cButton.Hide()
|
|
|
|
newRepo.pButton.Hide()
|
|
|
|
}
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.status = repostatus.New(myGui, newRepo.path)
|
|
|
|
newRepo.status.Horizontal()
|
|
|
|
newRepo.status.Make()
|
|
|
|
newRepo.status.Make2()
|
2024-01-13 23:27:46 -06:00
|
|
|
newRepo.status.SetMasterName(master)
|
|
|
|
newRepo.status.SetDevelName(devel)
|
|
|
|
newRepo.status.SetUserName(user)
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.status.Update()
|
|
|
|
newRepo.newScan()
|
2024-01-09 02:22:01 -06:00
|
|
|
allrepos = append(allrepos, newRepo)
|
2024-01-09 02:00:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
// This creates a window
|
2024-01-10 19:44:38 -06:00
|
|
|
func repoworld() {
|
|
|
|
win := gadgets.NewBasicWindow(myGui, "git autotypist. it types faster than you can.")
|
2024-01-09 01:16:00 -06:00
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
box := win.Box().NewBox("bw vbox", false)
|
2024-01-11 15:57:08 -06:00
|
|
|
// box2 := win.Box().NewBox("bw vbox", false)
|
2024-01-10 19:44:38 -06:00
|
|
|
group := box.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
2024-01-09 09:56:33 -06:00
|
|
|
grid := group.NewGrid("test", 11, 1)
|
2024-01-09 02:00:51 -06:00
|
|
|
|
2024-01-10 19:44:38 -06:00
|
|
|
grid.NewLabel("")
|
2024-01-09 08:35:07 -06:00
|
|
|
grid.NewLabel("branch")
|
|
|
|
grid.NewLabel("last tag")
|
2024-01-13 21:39:44 -06:00
|
|
|
grid.NewLabel("Current Version")
|
|
|
|
// grid.NewLabel("tags")
|
2024-01-09 09:56:33 -06:00
|
|
|
grid.NewLabel("master")
|
|
|
|
grid.NewLabel("devel")
|
2024-01-13 23:27:46 -06:00
|
|
|
grid.NewLabel("user")
|
2024-01-10 19:44:38 -06:00
|
|
|
grid.NewLabel("Status")
|
2024-01-09 02:00:51 -06:00
|
|
|
grid.NewLabel("commit")
|
2024-01-13 21:39:44 -06:00
|
|
|
grid.NewLabel("Toggle()")
|
|
|
|
grid.NewLabel("Draw()")
|
2024-01-09 02:00:51 -06:00
|
|
|
|
2024-01-09 10:41:35 -06:00
|
|
|
repos := myrepolist()
|
2024-01-13 23:27:46 -06:00
|
|
|
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)
|
2024-01-09 10:21:58 -06:00
|
|
|
}
|
2024-01-09 11:55:18 -06:00
|
|
|
|
2024-01-11 15:57:08 -06:00
|
|
|
win.Draw()
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|