diff --git a/doGui.go b/doGui.go index 3b5efa6..e95c054 100644 --- a/doGui.go +++ b/doGui.go @@ -202,26 +202,16 @@ func drawWindow(win *gadgets.GenericWindow) { patches = makePatchsetsWin() }) - /* - // the user mode "hack Window" - var hackWin *gadgets.GenericWindow - gridM.NewButton("Hack Window", func() { - if hackWin != nil { - hackWin.Toggle() - return - } - hackWin = makeHackModeWindow() - }) - */ - - var newWin *gadgets.GenericWindow + var insertWin *gadgets.GenericWindow s := fmt.Sprintf("Repos (%d)", me.forge.Repos.Len()) me.reposWinB = gridM.NewButton(s, func() { - if newWin != nil { - newWin.Toggle() + // if the window exists, just toggle it open or closed + if insertWin != nil { + insertWin.Toggle() return } - newWin = makeReposWindowNew() + + insertWin = makeReposWinNew() }) // var reposWin *gadgets.GenericWindow diff --git a/windowRepos.go b/windowRepos.go deleted file mode 100644 index f7fe477..0000000 --- a/windowRepos.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017-2025 WIT.COM Inc. All rights reserved. -// Use of this source code is governed by the GPL 3.0 - -package main - -// An app to submit patches for the 30 GO GUI repos - -import ( - "sync" - - "go.wit.com/gui" - "go.wit.com/lib/gadgets" - "go.wit.com/lib/protobuf/gitpb" - "go.wit.com/log" -) - -type stdReposTableWin struct { - sync.Mutex - win *gadgets.GenericWindow // the machines gui window - boxTB *gui.Node // the machines gui parent box widget - TB *gitpb.ReposTable // the gui table buffer - pb *gitpb.Repos // the current repos protobuf - update bool // if the window should be updated -} - -func (w *stdReposTableWin) Toggle() { - if w == nil { - return - } - if w.win == nil { - return - } - w.win.Toggle() -} - -func makeReposWindowNew() *gadgets.GenericWindow { - win := gadgets.NewGenericWindow("git repos", "Filter") - win.Custom = func() { - // sets the hidden flag to false so Toggle() works - win.Hide() - } - - hbox := win.Group.Box().Horizontal() - hbox.NewCheckbox("broken") - hbox.NewCheckbox("dirty") - hbox.NewCheckbox("mine") - hbox.NewButton("fix all", func() { - log.Info("try to fix everything here") - }) - - var writeWin *gadgets.GenericWindow - me.repoWritableB = hbox.NewButton("writable", func() { - // if the window exists, just toggle it open or closed - if writeWin != nil { - writeWin.Toggle() - return - } - - // make the window for the first time - found := new(gitpb.Repos) - for repo := range me.forge.Repos.IterByFullPath() { - if me.forge.Config.IsReadOnly(repo.GetGoPath()) { - continue - } - - found.AppendByGoPath(repo) - - } - writeWin, _ = makeWritableWindow(found) - writeWin.Win.Custom = func() { - log.Info("closing window. could do somethine here") - writeWin.Toggle() - } - }) - - t := makeStandardReposGrid(me.forge.Repos) - t.SetParent(win.Bottom) - t.ShowTable() - return win -} diff --git a/windowReposFix.go b/windowReposFix.go index e6d2795..22c00ef 100644 --- a/windowReposFix.go +++ b/windowReposFix.go @@ -22,124 +22,6 @@ func makeReposWin() *stdReposTableWin { rwin.win = win grid := win.Group.RawGrid() - me.repoDirtyB = grid.NewButton("dirty", func() { - doCheckDirtyAndConfigSave() - found := findDirty() - tb, box := makeStandardReposWindow("dirty repos", found) - hbox := box.Box().Horizontal() - hbox.NewButton("commit all", func() { - for repo := range found.IterByFullPath() { - log.Info("do commit here on", repo.GetGoPath()) - } - log.Info("TODO: fix this") - log.Info("run 'forge commit --all'") - }) - hbox.NewButton("update table", func() { - me.forge.PrintHumanTable(found) - found2 := findDirty() - me.forge.PrintHumanTable(found2) - // tb.Update() - // tb.UpdateTable(found2) - }) - hbox.NewButton("delete table", func() { - tb.Delete() - }) - }) - - me.repoAllB = grid.NewButton("All", func() { - me.found = new(gitpb.Repos) - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - me.found.AppendByGoPath(repo) - - } - makeStandardReposWindow("All repos", me.found) - }) - - var insertWin *gadgets.GenericWindow - me.repoWritableB = grid.NewButton("insert test", func() { - // if the window exists, just toggle it open or closed - if insertWin != nil { - insertWin.Toggle() - return - } - - insertWin = makeWindowForPB() - insertWin.Win.Custom = func() { - log.Info("test delete window here") - } - grid := insertWin.Group.RawGrid() - - var t *gitpb.ReposTable - grid.NewButton("dirty", func() { - if t != nil { - t.Delete() - t = nil - } - found := findDirty() - - // display the protobuf - 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("all", func() { - if t != nil { - t.Delete() - t = nil - } - found := new(gitpb.Repos) - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - found.AppendByGoPath(repo) - - } - // display the protobuf - 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() - 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("Configure", func() { - log.Info("add a forge config window here") - }) - win.Top.NewGroup("misc (works in progress)") grid = win.Top.RawGrid() @@ -513,12 +395,6 @@ func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTa return win, t } -func makeWindowForPB() *gadgets.GenericWindow { - win := gadgets.NewGenericWindow("Raw PB View", "Configure") - - return win -} - func addWindowPB(win *gadgets.GenericWindow, pb *gitpb.Repos) *gitpb.ReposTable { t := pb.NewTable("testForgeRepos") t.NewUuid() diff --git a/windowReposNew.go b/windowReposNew.go new file mode 100644 index 0000000..0b7a969 --- /dev/null +++ b/windowReposNew.go @@ -0,0 +1,114 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +// An app to submit patches for the 30 GO GUI repos + +import ( + "sync" + + "go.wit.com/gui" + "go.wit.com/lib/gadgets" + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +type stdReposTableWin struct { + sync.Mutex + win *gadgets.GenericWindow // the machines gui window + boxTB *gui.Node // the machines gui parent box widget + TB *gitpb.ReposTable // the gui table buffer + pb *gitpb.Repos // the current repos protobuf + update bool // if the window should be updated +} + +func (w *stdReposTableWin) Toggle() { + if w == nil { + return + } + if w.win == nil { + return + } + w.win.Toggle() +} + +func makeWindowForPB() *gadgets.GenericWindow { + win := gadgets.NewGenericWindow("Forge Repos Raw Protobuf View", "Filter Git Repositories") + + return win +} + +func makeReposWinNew() *gadgets.GenericWindow { + insertWin := makeWindowForPB() + insertWin.Win.Custom = func() { + log.Info("test delete window here") + } + grid := insertWin.Group.RawGrid() + + var t *gitpb.ReposTable + grid.NewButton("dirty", func() { + if t != nil { + t.Delete() + t = nil + } + found := findDirty() + + // display the protobuf + 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() + 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("all", func() { + if t != nil { + t.Delete() + t = nil + } + found := new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + found.AppendByGoPath(repo) + + } + // display the protobuf + 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()) + }) + + return insertWin +}