From 1282c17e8119a2debdfce0448b6c4b909b53f447 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 31 May 2025 16:03:00 -0500 Subject: [PATCH] rearrange main window --- doGui.go | 124 ++++++++++++++++++++++++---------------------- structs.go | 1 - windowReposFix.go | 36 ++------------ windowReposNew.go | 82 +++++++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 95 deletions(-) diff --git a/doGui.go b/doGui.go index e95c054..d8b3538 100644 --- a/doGui.go +++ b/doGui.go @@ -102,16 +102,9 @@ func doGui() { func drawWindow(win *gadgets.GenericWindow) { grid := win.Group.RawGrid() - me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home") + me.goSrcPwd = gadgets.NewOneLiner(grid, "Working Directory") grid.NewLabel("") - var howtoWin *gadgets.GenericWindow - me.demoB = grid.NewButton("Howto", func() { - if howtoWin != nil { - howtoWin.Toggle() - return - } - howtoWin = makeHowtoWin() - }) + grid.NextRow() me.goSrcPwd.SetText(me.forge.GetGoSrc()) @@ -128,59 +121,12 @@ func drawWindow(win *gadgets.GenericWindow) { me.gitAuthor.SetText(author) } - group1 := win.Stack.NewGroup("Forge Mode") - grid = group1.RawGrid() - me.forgeMode = grid.NewLabel("") - me.forgeMode.SetText(me.forge.GetMode()) - - me.newBranch = grid.NewDropdown() - me.newBranch.AddText("master") - me.newBranch.AddText("devel") - me.newBranch.AddText(me.forge.Config.GetUsername()) - me.newBranch.Custom = func() { - me.setBranchB.Disable() - // toggle global values shared by the command line and the gui for doCheckout() - switch me.newBranch.String() { - case "master": - if me.forge.Config.Mode != forgepb.ForgeMode_MASTER { - me.setBranchB.Enable() - } - case "devel": - if me.forge.Config.Mode != forgepb.ForgeMode_DEVEL { - me.setBranchB.Enable() - } - default: - if me.forge.Config.Mode != forgepb.ForgeMode_USER { - me.setBranchB.Enable() - } - } - } - - // select the branch you want to test, build and develop against - // this lets you select your user branch, but, when you are happy - // you can merge everything into the devel branch and make sure it actually - // works. Then, when that is good, merge and version everything in master - me.setBranchB = grid.NewButton("Switch mode", func() { - win.Disable() - defer win.Enable() - - switch me.newBranch.String() { - case "master": - forgeSwitchMode(forgepb.ForgeMode_MASTER) - case "devel": - forgeSwitchMode(forgepb.ForgeMode_DEVEL) - default: - forgeSwitchMode(forgepb.ForgeMode_USER) - } - - me.setBranchB.Disable() - }) - me.setBranchB.Disable() - grid.NextRow() - groupM := win.Stack.NewGroup("Mode Windows") - gridM := groupM.RawGrid() + // groupM := hbox.NewGroup("Windows") + // gridM := groupM.RawGrid() + // hbox := win.Stack.Box().Horizontal() + gridM := win.Stack.RawGrid() var releaseWin *gadgets.GenericWindow gridM.NewButton("Release Window", func() { @@ -251,6 +197,64 @@ func drawWindow(win *gadgets.GenericWindow) { patchesWin = makePatchesWin(notdone) }) + var howtoWin *gadgets.GenericWindow + gridM.NewButton("Howto", func() { + if howtoWin != nil { + howtoWin.Toggle() + return + } + howtoWin = makeHowtoWin() + }) + + group1 := win.Stack.NewGroup("Forge Mode (deprecated)") + grid = group1.RawGrid() + me.forgeMode = grid.NewLabel("") + me.forgeMode.SetText(me.forge.GetMode()) + + me.newBranch = grid.NewDropdown() + me.newBranch.AddText("master") + me.newBranch.AddText("devel") + me.newBranch.AddText(me.forge.Config.GetUsername()) + me.newBranch.Custom = func() { + me.setBranchB.Disable() + // toggle global values shared by the command line and the gui for doCheckout() + switch me.newBranch.String() { + case "master": + if me.forge.Config.Mode != forgepb.ForgeMode_MASTER { + me.setBranchB.Enable() + } + case "devel": + if me.forge.Config.Mode != forgepb.ForgeMode_DEVEL { + me.setBranchB.Enable() + } + default: + if me.forge.Config.Mode != forgepb.ForgeMode_USER { + me.setBranchB.Enable() + } + } + } + + // select the branch you want to test, build and develop against + // this lets you select your user branch, but, when you are happy + // you can merge everything into the devel branch and make sure it actually + // works. Then, when that is good, merge and version everything in master + me.setBranchB = grid.NewButton("Switch mode", func() { + win.Disable() + defer win.Enable() + + switch me.newBranch.String() { + case "master": + forgeSwitchMode(forgepb.ForgeMode_MASTER) + case "devel": + forgeSwitchMode(forgepb.ForgeMode_DEVEL) + default: + forgeSwitchMode(forgepb.ForgeMode_USER) + } + + me.setBranchB.Disable() + }) + me.setBranchB.Disable() + // set the initial button state based on the last // forge mode the user saved in the config file switch me.forge.Config.Mode { diff --git a/structs.go b/structs.go index 100b02e..0470d97 100644 --- a/structs.go +++ b/structs.go @@ -67,7 +67,6 @@ type mainType struct { repoDirtyB *gui.Node // "dirty" repos button repoDevelMergeB *gui.Node // "merge to devel" repos button repoWritableB *gui.Node // "what repos are writable" repos button - demoB *gui.Node // opens the demo // modeReleaseW *gui.Node // opens the release window // modePatchW *gui.Node // opens the patch window // modeUserW *gui.Node // opens the user/hack window diff --git a/windowReposFix.go b/windowReposFix.go index 22c00ef..d7cb964 100644 --- a/windowReposFix.go +++ b/windowReposFix.go @@ -18,13 +18,14 @@ import ( func makeReposWin() *stdReposTableWin { rwin := new(stdReposTableWin) - win := gadgets.NewGenericWindow("git repos", "All about git repos") + win := gadgets.NewGenericWindow("find errors and try to fix them", "types of errors of some sort or another") rwin.win = win grid := win.Group.RawGrid() - win.Top.NewGroup("misc (works in progress)") + // win.Top.NewGroup("misc (works in progress)") - grid = win.Top.RawGrid() + // grid = win.Top.RawGrid() + grid = win.Group.RawGrid() var found *gitpb.Repos var txt string @@ -394,32 +395,3 @@ func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTa t.ShowTable() return win, t } - -func addWindowPB(win *gadgets.GenericWindow, pb *gitpb.Repos) *gitpb.ReposTable { - t := pb.NewTable("testForgeRepos") - t.NewUuid() - tbox := win.Bottom.Box().SetProgName("TBOX") - t.SetParent(tbox) - - sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string { - return r.GetGoPath() - }) - sf.Custom = func(r *gitpb.Repo) { - log.Info("do button click on", r.GetGoPath()) - } - t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time { - return repo.NewestTime() - }) - t.AddMasterVersion() - t.AddDevelVersion() - t.AddUserVersion() - t.AddCurrentBranchName() - t.AddState() - f := func(repo *gitpb.Repo) string { - log.Info("repo =", repo.GetGoPath(), repo.GetCurrentVersion()) - return repo.GetGoPath() - } - t.AddButtonFunc("cur version", f) - t.ShowTable() - return t -} diff --git a/windowReposNew.go b/windowReposNew.go index 0b7a969..994374c 100644 --- a/windowReposNew.go +++ b/windowReposNew.go @@ -7,6 +7,7 @@ package main import ( "sync" + "time" "go.wit.com/gui" "go.wit.com/lib/gadgets" @@ -63,6 +64,54 @@ func makeReposWinNew() *gadgets.GenericWindow { log.Info("table has uuid", t.GetUuid()) }) + grid.NewButton("with patches", func() { + if t != nil { + t.Delete() + t = nil + } + found := new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { + continue + } + found.AppendByGoPath(repo) + } + + // make the window for the first time + t = addWindowPB(insertWin, found) + f := func(repo *gitpb.Repo) { + log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion()) + } + t.Custom(f) + log.Info("table has uuid", t.GetUuid()) + }) + + grid.NewButton("favorites", func() { + if t != nil { + t.Delete() + t = nil + } + found := new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if !me.forge.Config.IsFavorite(repo.GetGoPath()) { + continue + } + found.AppendByGoPath(repo) + } + + // make the window for the first time + t = addWindowPB(insertWin, found) + f := func(repo *gitpb.Repo) { + log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion()) + } + t.Custom(f) + log.Info("table has uuid", t.GetUuid()) + }) + grid.NewButton("writeable", func() { if t != nil { t.Delete() @@ -75,9 +124,7 @@ func makeReposWinNew() *gadgets.GenericWindow { if me.forge.Config.IsReadOnly(repo.GetGoPath()) { continue } - found.AppendByGoPath(repo) - } // make the window for the first time @@ -112,3 +159,34 @@ func makeReposWinNew() *gadgets.GenericWindow { return insertWin } + +func addWindowPB(win *gadgets.GenericWindow, pb *gitpb.Repos) *gitpb.ReposTable { + t := pb.NewTable("testForgeRepos") + t.NewUuid() + tbox := win.Bottom.Box().SetProgName("TBOX") + t.SetParent(tbox) + + sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string { + return r.GetGoPath() + }) + sf.Custom = func(r *gitpb.Repo) { + log.Info("do button click on", r.GetGoPath()) + } + t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time { + return repo.NewestTime() + }) + t.AddMasterVersion() + // hmm := t.AddMasterVersion() + // hmm.SetTitle("Master") + t.AddDevelVersion() + t.AddUserVersion() + t.AddCurrentBranchName() + t.AddState() + f := func(repo *gitpb.Repo) string { + log.Info("repo =", repo.GetGoPath(), repo.GetCurrentVersion()) + return repo.GetGoPath() + } + t.AddButtonFunc("cur version", f) + t.ShowTable() + return t +}