From 931e345895e99e9cb058029763e12562cc6d5fba Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 28 Nov 2024 19:57:03 -0600 Subject: [PATCH] testGui example is starting to work --- init.go | 13 ++++++------- testGui/main.go | 26 ++++++++++---------------- testGui/structs.go | 11 +---------- viewAutotypist.go | 45 ++++++++++++++++++++------------------------- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/init.go b/init.go index a5e081d..7ec3cb5 100644 --- a/init.go +++ b/init.go @@ -6,17 +6,15 @@ import ( "go.wit.com/log" ) -func (rl *RepoList) Init(f *forgepb.Forge) { - if rl == nil { - rl = new(RepoList) - } - me = rl +func Init(f *forgepb.Forge, g *gui.Node) *RepoList { + me = new(RepoList) + // todo: this code sucks. fix it soon - me.mainWindow = gui.NewWindow("builds and uploads all the packages") + me.mainWindow = g.NewWindow("builds and uploads all the packages") me.mainbox = me.mainWindow.NewBox("bw hbox", true) // make a window with a table of all the repos - me = AutotypistView(me.mainbox) + me.AutotypistView(me.mainbox) me.Enable() me.forge = f @@ -29,4 +27,5 @@ func (rl *RepoList) Init(f *forgepb.Forge) { } me.Enable() + return me } diff --git a/testGui/main.go b/testGui/main.go index c6880c1..4c55f66 100644 --- a/testGui/main.go +++ b/testGui/main.go @@ -20,27 +20,21 @@ func main() { // load the ~/.config/forge/ config me.forge = forgepb.Init() - if me.forge == nil { - panic("damn it, forge is nil") - } - if me.forge.Config == nil { - panic("damn it config") - } me.forge.ConfigPrintTable() + if err := me.forge.Machine.ConfigLoad(); err != nil { + log.Warn("zoopb.ConfigLoad() failed", err) + os.Exit(-1) + } + me.forge.Machine.InitWit() + // setup the GUI me.myGui = gui.New() me.myGui.Default() - // todo: this code sucks. fix it soon - me.mainWindow = me.myGui.NewWindow("builds and uploads all the packages") - me.mainbox = me.mainWindow.NewBox("bw hbox", true) + me.repoList = repolist.Init(me.forge, me.myGui) - // make a window with a table of all the repos - me.repoList = repolist.AutotypistView(me.mainbox) - me.repoList.Init(me.forge) - - me.Enable() + me.repoList.Enable() failed := make(map[*repolist.RepoRow]string) versions := make(map[*repolist.RepoRow]string) @@ -54,10 +48,10 @@ func main() { var alreadyBuilt bool ver := repo.Status.DebianReleaseVersion() name := me.forge.DebName(repo.GoPath()) - if me.machine.IsInstalled(name) { + if me.forge.Machine.IsInstalled(name) { end += "(installed) " } - if actualp := me.machine.FindVersion(name, ver); actualp != nil { + if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil { end += " (version match) " + actualp.Version + " " + ver + " " alreadyBuilt = true } else { diff --git a/testGui/structs.go b/testGui/structs.go index 2d223bf..a836504 100644 --- a/testGui/structs.go +++ b/testGui/structs.go @@ -5,19 +5,10 @@ import ( "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/repolist" "go.wit.com/lib/protobuf/forgepb" - "go.wit.com/lib/protobuf/zoopb" ) var me *autoType -func (b *autoType) Disable() { - b.mainbox.Disable() -} - -func (b *autoType) Enable() { - b.mainbox.Enable() -} - // this app's variables type autoType struct { // allrepos map[string]*repo @@ -42,7 +33,7 @@ type autoType struct { goSrcPath string // use zookeeper to get the list of installed packages - machine zoopb.Machine + // machine zoopb.Machine // #### autotypist Global Display Options autoHidePerfect *gui.Node diff --git a/viewAutotypist.go b/viewAutotypist.go index 410904a..090b37e 100644 --- a/viewAutotypist.go +++ b/viewAutotypist.go @@ -4,33 +4,28 @@ import "go.wit.com/gui" // This creates a view of the repos // you can only have one at this point -func AutotypistView(parent *gui.Node) *RepoList { - if me != nil { - return me - } - me = new(RepoList) - me.allrepos = make(map[string]*RepoRow) - me.viewName = "autotypist" +func (rl *RepoList) AutotypistView(parent *gui.Node) { + rl.allrepos = make(map[string]*RepoRow) + rl.viewName = "autotypist" - // me.reposbox = gui.RawBox() - me.reposbox = parent + // rl.reposbox = gui.RawBox() + rl.reposbox = parent - me.reposgroup = me.reposbox.NewGroup("my git repositories (configure in ~/.config/autotypist)") - // me.reposgroup.Menu = repolistMenu() // how to do a menu? what should the code look like? - me.reposgrid = me.reposgroup.NewGrid("test", 0, 0) + rl.reposgroup = rl.reposbox.NewGroup("my git repositories (configure in ~/.config/autotypist)") + // rl.reposgroup.Menu = repolistMenu() // how to do a menu? what should the code look like? + rl.reposgrid = rl.reposgroup.NewGrid("test", 0, 0) - me.reposgrid.NewLabel("") // path goes here - me.reposgrid.NewLabel("last tag").SetProgName("last tag") - me.reposgrid.NewLabel("master version") - me.reposgrid.NewLabel("devel version") - me.reposgrid.NewLabel("user version") - me.reposgrid.NewLabel("Status") - me.reposgrid.NewLabel("Current").SetProgName("CurrentName") - me.reposgrid.NewLabel("Version").SetProgName("CurrentVersion") - me.reposgrid.NextRow() + rl.reposgrid.NewLabel("") // path goes here + rl.reposgrid.NewLabel("last tag").SetProgName("last tag") + rl.reposgrid.NewLabel("master version") + rl.reposgrid.NewLabel("devel version") + rl.reposgrid.NewLabel("user version") + rl.reposgrid.NewLabel("Status") + rl.reposgrid.NewLabel("Current").SetProgName("CurrentName") + rl.reposgrid.NewLabel("Version").SetProgName("CurrentVersion") + rl.reposgrid.NextRow() - me.blind = gui.RawBox() - me.shownCount = me.blind.NewLabel("showCount") - me.duration = me.blind.NewLabel("duration") - return me + rl.blind = gui.RawBox() + rl.shownCount = rl.blind.NewLabel("showCount") + rl.duration = rl.blind.NewLabel("duration") }