From 08436e1a8dbd9d4166d43fef63d5c956a6e7b850 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 11 Feb 2024 20:24:40 -0600 Subject: [PATCH] move repowindow vars into main struct Signed-off-by: Jeff Carr --- globalDisplayOptions.go | 5 +++-- main.go | 18 ++++++---------- repolist.go | 48 ++++++++++++++++++++--------------------- structs.go | 13 ++++++----- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index 448f742..96171ee 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -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 diff --git a/main.go b/main.go index a585bc7..1692a0f 100644 --- a/main.go +++ b/main.go @@ -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) - -} diff --git a/repolist.go b/repolist.go index ab1aa5f..ef82c26 100644 --- a/repolist.go +++ b/repolist.go @@ -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() }) } diff --git a/structs.go b/structs.go index 0a649ff..2b262dd 100644 --- a/structs.go +++ b/structs.go @@ -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