2024-01-09 01:16:00 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-09 10:21:58 -06:00
|
|
|
"io/ioutil"
|
|
|
|
"strings"
|
|
|
|
|
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"
|
|
|
|
"go.wit.com/apps/control-panel-dns/smartwindow"
|
2024-01-09 11:55:18 -06:00
|
|
|
"go.wit.com/apps/myrepos/repostatus"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var myGui *gui.Node
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
var allrepos []*repo
|
|
|
|
|
|
|
|
type repo struct {
|
|
|
|
path string
|
2024-01-09 08:35:07 -06:00
|
|
|
lasttagrev string
|
|
|
|
lasttag string
|
|
|
|
tags []string
|
2024-01-09 02:22:01 -06:00
|
|
|
|
|
|
|
pLabel *gui.Node // path label
|
|
|
|
bLabel *gui.Node // branch label
|
2024-01-09 08:35:07 -06:00
|
|
|
lastLabel *gui.Node // last tagged version label
|
2024-01-09 02:22:01 -06:00
|
|
|
vLabel *gui.Node // version label
|
2024-01-09 08:41:32 -06:00
|
|
|
tagsDrop *gui.Node // list of all tags
|
2024-01-09 09:56:33 -06:00
|
|
|
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
|
2024-01-09 02:22:01 -06:00
|
|
|
|
|
|
|
cButton *gui.Node // commit button
|
|
|
|
pButton *gui.Node // push button
|
2024-01-09 11:55:18 -06:00
|
|
|
|
|
|
|
status *repostatus.RepoStatus
|
2024-01-09 02:22:01 -06:00
|
|
|
}
|
|
|
|
|
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-09 09:56:33 -06:00
|
|
|
checkrepos()
|
2024-01-09 01:16:00 -06:00
|
|
|
gui.Watchdog()
|
|
|
|
}
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
func addRepo(grid *gui.Node, path string) *repo {
|
|
|
|
newRepo := new(repo)
|
|
|
|
|
|
|
|
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 10:21:58 -06:00
|
|
|
newRepo.tagsDrop = grid.NewDropdown("tags")
|
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-09 11:55:18 -06:00
|
|
|
newRepo.cButton = grid.NewButton("status", func () {
|
|
|
|
log.Println("repo status for", newRepo.path)
|
2024-01-10 19:44:38 -06:00
|
|
|
newRepo.scan()
|
2024-01-09 11:55:18 -06:00
|
|
|
if newRepo.status == nil {
|
|
|
|
newRepo.status = repostatus.New(myGui, newRepo.path)
|
|
|
|
newRepo.status.InitWindow()
|
|
|
|
newRepo.status.Make()
|
|
|
|
newRepo.status.Draw()
|
|
|
|
newRepo.status.Draw2()
|
|
|
|
}
|
|
|
|
newRepo.status.Toggle()
|
2024-01-09 02:00:51 -06:00
|
|
|
})
|
2024-01-09 08:35:07 -06:00
|
|
|
newRepo.pButton = grid.NewButton("push", func () {
|
2024-01-10 19:44:38 -06:00
|
|
|
newRepo.scan()
|
2024-01-09 02:00:51 -06:00
|
|
|
})
|
2024-01-10 19:44:38 -06:00
|
|
|
if path == "" {
|
|
|
|
newRepo.cButton.Hide()
|
|
|
|
newRepo.pButton.Hide()
|
|
|
|
return newRepo
|
|
|
|
}
|
2024-01-09 02:22:01 -06:00
|
|
|
allrepos = append(allrepos, newRepo)
|
|
|
|
return 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-09 09:35:54 -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-09 02:00:51 -06:00
|
|
|
grid.NewLabel("Version")
|
2024-01-09 09:56:33 -06:00
|
|
|
grid.NewLabel("tags")
|
|
|
|
grid.NewLabel("master")
|
|
|
|
grid.NewLabel("devel")
|
|
|
|
grid.NewLabel("jcarr")
|
2024-01-10 19:44:38 -06:00
|
|
|
grid.NewLabel("Status")
|
2024-01-09 02:00:51 -06:00
|
|
|
grid.NewLabel("commit")
|
|
|
|
grid.NewLabel("push to")
|
|
|
|
|
2024-01-09 10:41:35 -06:00
|
|
|
repos := myrepolist()
|
|
|
|
for _, repo := range repos {
|
2024-01-09 10:21:58 -06:00
|
|
|
log.Warn("repo =", repo)
|
|
|
|
addRepo(grid, repo)
|
|
|
|
}
|
2024-01-09 11:55:18 -06:00
|
|
|
|
|
|
|
var mystatus *repostatus.RepoStatus
|
|
|
|
box2.NewButton("repostatus()", func () {
|
|
|
|
if mystatus == nil {
|
|
|
|
mystatus = repostatus.New(myGui, "go.wit.com/gui/gui")
|
|
|
|
mystatus.InitWindow()
|
|
|
|
mystatus.Make()
|
|
|
|
mystatus.Draw()
|
|
|
|
mystatus.Draw2()
|
|
|
|
}
|
|
|
|
mystatus.Toggle()
|
|
|
|
})
|
2024-01-09 09:35:54 -06:00
|
|
|
box2.NewButton("hello", func () {
|
2024-01-09 01:16:00 -06:00
|
|
|
log.Println("world")
|
|
|
|
hellosmart()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// This creates a window
|
|
|
|
func hellosmart() {
|
|
|
|
win := smartwindow.New()
|
|
|
|
win.SetParent(myGui)
|
|
|
|
win.InitWindow()
|
2024-01-10 19:44:38 -06:00
|
|
|
win.Title("hellosmart test")
|
2024-01-09 01:16:00 -06:00
|
|
|
win.Vertical()
|
|
|
|
win.SetDraw(smartDraw)
|
|
|
|
win.Make()
|
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
win.Box().NewButton("test smartwindow", func () {
|
2024-01-09 01:16:00 -06:00
|
|
|
log.Println("smart")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func smartDraw(sw *smartwindow.SmartWindow) {
|
|
|
|
sw.Box().NewButton("hello", func () {
|
|
|
|
log.Println("smart")
|
|
|
|
})
|
|
|
|
}
|
2024-01-09 10:41:35 -06:00
|
|
|
|
|
|
|
func myrepolist() []string {
|
|
|
|
content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
|
|
|
|
out := string(content)
|
|
|
|
out = strings.TrimSpace(out)
|
|
|
|
lines := strings.Split(out, "\n")
|
|
|
|
return lines
|
|
|
|
}
|