// 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("Show()", func () { if newRepo.status == nil { log.Warn("status window doesn't exist") return } log.Warn("status window exists. trying TestDraw() here") newRepo.status.Show() }) 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() { reposwin = gadgets.NewBasicWindow(myGui, "git autotypist. it types faster than you can.") reposwin.Make() reposbox = reposwin.Box().NewBox("bw vbox", false) reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)") reposgrid = reposgroup.NewGrid("test", 11, 1) reposgrid.NewLabel("") reposgrid.NewLabel("branch") reposgrid.NewLabel("last tag") reposgrid.NewLabel("Current Version") // reposgrid.NewLabel("tags") reposgrid.NewLabel("master") reposgrid.NewLabel("devel") reposgrid.NewLabel("user") reposgrid.NewLabel("Status") reposgrid.NewLabel("commit") reposgrid.NewLabel("Toggle()") reposgrid.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(reposgrid, path, mbranch, dbranch, ubranch) } box2 := reposwin.Box().NewBox("bw vbox", false) box2.NewButton("reposgrid.Margin()", func () { log.Warn("reposgrid.Margin() RUN NOW") reposgrid.Margin() log.Warn("reposgrid.Pad() RUN NOW") reposgrid.Pad() }) box2.NewButton("status.Update() all", func () { for _, repo := range allrepos { repo.status.Update() } }) box2.NewButton("rescan all", func () { for _, repo := range allrepos { repo.newScan() } }) reposwin.Draw() }