move repowindow vars into main struct

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-11 20:24:40 -06:00
parent f7e67a8bf6
commit 08436e1a8d
4 changed files with 40 additions and 44 deletions

View File

@ -55,7 +55,7 @@ func globalDisplayOptions(box *gui.Node) {
group1.NewButton("Show Repository Window", func() {
globalDisplaySetRepoState()
reposwin.Toggle()
me.reposwin.Toggle()
})
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
@ -79,7 +79,6 @@ func globalDisplayOptions(box *gui.Node) {
group1.NewButton("make go.work file", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
goSrcDir := me.goSrcPwd.String()
filename := filepath.Join(goSrcDir, "go.work")
@ -101,6 +100,8 @@ func globalDisplayOptions(box *gui.Node) {
}
}
fmt.Fprintln(f, ")")
me.autotypistWindow.Enable()
})
var tagsW *tagWindow

18
main.go
View File

@ -27,7 +27,13 @@ func main() {
// me.myGui.LoadToolkit("nocui")
me.myGui.Default()
autotypistWindow()
me.autotypistWindow = me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
box := me.autotypistWindow.NewBox("bw hbox", true)
globalDisplayOptions(box)
globalBuildOptions(box)
globalResetOptions(box)
repolistWindow()
// process everything on the command line
@ -69,13 +75,3 @@ func main() {
*/
})
}
func autotypistWindow() {
me.autotypistWindow = me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
box := me.autotypistWindow.NewBox("bw hbox", true)
globalDisplayOptions(box)
globalBuildOptions(box)
globalResetOptions(box)
}

View File

@ -134,34 +134,34 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
// This creates a window
func repolistWindow() {
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
reposwin.Make()
me.reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
me.reposwin.Make()
reposbox = reposwin.Box().NewBox("bw vbox", false)
reposwin.Draw()
reposwin.Custom = func() {
me.reposbox = me.reposwin.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
me.reposwin.Custom = func() {
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
log.Warn("Should I do something special here?")
}
repoAllButtons(reposbox)
repoAllButtons(me.reposbox)
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
reposgrid = reposgroup.NewGrid("test", 8, 1)
me.reposgroup = me.reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
me.reposgrid = me.reposgroup.NewGrid("test", 8, 1)
reposgrid.NewLabel("") // path goes here
me.reposgrid.NewLabel("") // path goes here
reposgrid.NewLabel("last tag").SetProgName("last tag")
me.reposgrid.NewLabel("last tag").SetProgName("last tag")
reposgrid.NewLabel("master version")
reposgrid.NewLabel("devel version")
reposgrid.NewLabel("user version")
me.reposgrid.NewLabel("master version")
me.reposgrid.NewLabel("devel version")
me.reposgrid.NewLabel("user version")
reposgrid.NewLabel("Status")
me.reposgrid.NewLabel("Status")
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
me.reposgrid.NewLabel("Current Version").SetProgName("Current Version")
reposgrid.NewLabel("Show()")
me.reposgrid.NewLabel("Show()")
usr, _ := user.Current()
@ -178,7 +178,7 @@ func repolistWindow() {
if ubranch == "" {
ubranch = usr.Username
}
addRepo(reposgrid, path, mbranch, dbranch, ubranch)
addRepo(me.reposgrid, path, mbranch, dbranch, ubranch)
}
// TODO: figure out why this borks everything
@ -191,7 +191,7 @@ func repolistWindow() {
}
*/
reposwin.Toggle()
// reposwin.Toggle()
}
func repoAllButtons(box *gui.Node) {
@ -212,30 +212,30 @@ func repoAllButtons(box *gui.Node) {
box2 := hbox.Box().Vertical()
box2.NewButton("merge all user to devel", func() {
reposwin.Disable()
me.reposwin.Disable()
if !mergeAllUserToDevel() {
return
}
reposwin.Enable()
me.reposwin.Enable()
})
box2.NewButton("merge all devel to main", func() {
reposwin.Disable()
me.reposwin.Disable()
if !mergeAllDevelToMain() {
return
}
reposwin.Enable()
me.reposwin.Enable()
})
box2.NewButton("merge it all", func() {
reposwin.Disable()
me.reposwin.Disable()
if !mergeAllUserToDevel() {
return
}
if !mergeAllDevelToMain() {
return
}
reposwin.Enable()
me.reposwin.Enable()
})
}

View File

@ -1,4 +1,3 @@
// watch all your go git repos
package main
import (
@ -7,20 +6,20 @@ import (
"go.wit.com/lib/gui/repostatus"
)
// the main window nodes
var reposwin *gadgets.BasicWindow
var reposbox *gui.Node
var reposgrid *gui.Node
var reposgroup *gui.Node
var me *autoType
// this app's variables
type autoType struct {
allrepos map[string]*repo
myGui *gui.Node
autotypistWindow *gui.Node
reposwin *gadgets.BasicWindow
reposbox *gui.Node
reposgrid *gui.Node
reposgroup *gui.Node
// #### autotypist Global Display Options
autoHidePerfect *gui.Node
autoHideReadOnly *gui.Node