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

18
main.go
View File

@ -27,7 +27,13 @@ func main() {
// me.myGui.LoadToolkit("nocui") // me.myGui.LoadToolkit("nocui")
me.myGui.Default() 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() repolistWindow()
// process everything on the command line // 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 // This creates a window
func repolistWindow() { func repolistWindow() {
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/") me.reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
reposwin.Make() me.reposwin.Make()
reposbox = reposwin.Box().NewBox("bw vbox", false) me.reposbox = me.reposwin.Box().NewBox("bw vbox", false)
reposwin.Draw() // me.reposwin.Draw()
reposwin.Custom = func() { me.reposwin.Custom = func() {
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close") log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
log.Warn("Should I do something special here?") log.Warn("Should I do something special here?")
} }
repoAllButtons(reposbox) repoAllButtons(me.reposbox)
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)") me.reposgroup = me.reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
reposgrid = reposgroup.NewGrid("test", 8, 1) 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") me.reposgrid.NewLabel("master version")
reposgrid.NewLabel("devel version") me.reposgrid.NewLabel("devel version")
reposgrid.NewLabel("user 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() usr, _ := user.Current()
@ -178,7 +178,7 @@ func repolistWindow() {
if ubranch == "" { if ubranch == "" {
ubranch = usr.Username ubranch = usr.Username
} }
addRepo(reposgrid, path, mbranch, dbranch, ubranch) addRepo(me.reposgrid, path, mbranch, dbranch, ubranch)
} }
// TODO: figure out why this borks everything // TODO: figure out why this borks everything
@ -191,7 +191,7 @@ func repolistWindow() {
} }
*/ */
reposwin.Toggle() // reposwin.Toggle()
} }
func repoAllButtons(box *gui.Node) { func repoAllButtons(box *gui.Node) {
@ -212,30 +212,30 @@ func repoAllButtons(box *gui.Node) {
box2 := hbox.Box().Vertical() box2 := hbox.Box().Vertical()
box2.NewButton("merge all user to devel", func() { box2.NewButton("merge all user to devel", func() {
reposwin.Disable() me.reposwin.Disable()
if !mergeAllUserToDevel() { if !mergeAllUserToDevel() {
return return
} }
reposwin.Enable() me.reposwin.Enable()
}) })
box2.NewButton("merge all devel to main", func() { box2.NewButton("merge all devel to main", func() {
reposwin.Disable() me.reposwin.Disable()
if !mergeAllDevelToMain() { if !mergeAllDevelToMain() {
return return
} }
reposwin.Enable() me.reposwin.Enable()
}) })
box2.NewButton("merge it all", func() { box2.NewButton("merge it all", func() {
reposwin.Disable() me.reposwin.Disable()
if !mergeAllUserToDevel() { if !mergeAllUserToDevel() {
return return
} }
if !mergeAllDevelToMain() { if !mergeAllDevelToMain() {
return return
} }
reposwin.Enable() me.reposwin.Enable()
}) })
} }

View File

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