From 6acc0b4f8bd793ae394060981ff10c43eab0bed6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 11 Sep 2025 15:26:29 -0500 Subject: mv --- addRepo.go | 95 ---------------------------------------- stateWindow.go | 124 ---------------------------------------------------- windowControlBox.go | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 219 deletions(-) delete mode 100644 addRepo.go delete mode 100644 stateWindow.go create mode 100644 windowControlBox.go diff --git a/addRepo.go b/addRepo.go deleted file mode 100644 index 4a954ad..0000000 --- a/addRepo.go +++ /dev/null @@ -1,95 +0,0 @@ -package main - -/* -func RemoveFirstElement(slice []string) (string, []string) { - if len(slice) == 0 { - return "", slice // Return the original slice if it's empty - } - return slice[0], slice[1:] // Return the slice without the first element -} - -// homeDir, _ := os.UserHomeDir() - -func (c *controlBox) addRepoOld() { - path := strings.Trim(me.goPath, "/") // trim any extranous '/' chars put in the config file by the user - if path == "" { - log.Warn("addRepo() got empty path", path) - return - } - - // if repostatus.VerifyLocalGoRepo(path) { - // log.Verbose("path actually exists", path) - // } else { - // log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path) - // return - // } - - c.pathL = gadgets.NewOneLiner(c.grid, "path") - c.pathL.SetText(path) - c.grid.NextRow() - - c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag") - c.grid.NextRow() - - c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty") - c.grid.NextRow() - - c.currentL = gadgets.NewOneLiner(c.grid, "current") - c.grid.NextRow() - - c.buildDate = gadgets.NewOneLiner(c.grid, "Build Date") - c.grid.NextRow() - - stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC") - c.buildDate.SetText(stamp) - - c.tagDate = gadgets.NewBasicEntry(c.grid, "git tag Date") - c.grid.NextRow() - - var cbname string - var cbversion string - var debversion string - - if me.repo == nil { - cbname = "todo" - cbversion = "todo version" - debversion = "todo deb version" - } else { - cbname = me.repo.GetCurrentBranchName() - cbversion = me.repo.GetCurrentBranchVersion() - debversion = me.repo.DebianCurrentVersion() - } - - if me.repo == nil { - c.dirtyL.SetText("unknown") - } else { - if me.repo.CheckDirty() { - c.dirtyL.SetText("true") - } else { - c.dirtyL.SetText("false") - } - } - - if c.GoPath.String() == "" { - c.GoPath.SetText(me.goPath) - } - - var lasttag string = "unknown" - if me.repo != nil { - lasttag = me.repo.GetLastTagVersion() - if argv.Release { - debversion = me.repo.DebianReleaseVersion() - c.dirtyL.SetText("false") - } - } - - c.Version.SetText(debversion) - - c.lastTag.SetText(lasttag) - c.currentL.SetText(cbname + " " + cbversion) - - tagDate := getDateStamp(lasttag) - c.tagDate.SetText(tagDate) - return -} -*/ diff --git a/stateWindow.go b/stateWindow.go deleted file mode 100644 index c5637a2..0000000 --- a/stateWindow.go +++ /dev/null @@ -1,124 +0,0 @@ -package main - -import ( - "os" - - "go.wit.com/gui" - "go.wit.com/lib/gadgets" - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -// This initializes the first window, a group and a button -// this is terribly old code. redo this all after widgets are switched to protobuf -func makebasicWindow() *gadgets.BasicWindow { - log.Warn("init basicWindow state") - win := gadgets.RawBasicWindow("Create .deb files for GO applications") - win.Make() - win.Custom = func() { - log.Info("got to close") - os.Exit(0) - } - - box1 := win.Box() - // me.cBox = newControl(box1) - newControl(box1) - - vbox := box1.Box().Horizontal() - group1 := vbox.NewGroup("controls").Horizontal() // Vertical() - - group1.NewButton("go build", func() { - shell.Run([]string{"go", "build", "-v", "-x"}) - }) - - group1.NewButton("read control file", func() { - readControlFile(me.repo) - }) - - group1.NewButton("write control file", func() { - writeDebianControlFile(me.repo) - }) - - group1.NewButton("Make .deb", func() { - win.Disable() - if ok, err := buildPackage(me.repo); ok { - log.Info("build worked") - os.Exit(0) - } else { - log.Warn("build failed", err) - } - win.Enable() - }) - - return win -} - -// This initializes the control box -func newControl(parent *gui.Node) *controlBox { - var c *controlBox - c = new(controlBox) - c.group = parent.NewGroup("choices") - c.grid = c.group.NewGrid("gridiron", 8, 1) - - c.Package = gadgets.NewOneLiner(c.grid, "Package") - c.grid.NextRow() - - c.Source = gadgets.NewOneLiner(c.grid, "Source") - c.grid.NextRow() - - c.Version = gadgets.NewOneLiner(c.grid, "Version") - c.grid.NextRow() - - c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture") - c.Architecture.AddText("all") - c.Architecture.AddText("riscv64") - c.Architecture.AddText("amd64") - c.Architecture.AddText("arm64") - c.Architecture.AddText("ppc64") - c.Architecture.AddText("i386") - c.Architecture.AddText("sparc64") - c.Architecture.AddText("alpha") - c.Architecture.SetText("riscv64") - c.grid.NextRow() - - c.InstallPath = gadgets.NewBasicCombobox(c.grid, "Install Path") - c.InstallPath.AddText("/usr/bin") - c.InstallPath.AddText("/usr/local/bin") - c.InstallPath.AddText("/bin") - c.InstallPath.AddText("/opt//bin") - c.InstallPath.SetText("/usr/bin") - c.grid.NextRow() - - c.Maintainer = gadgets.NewOneLiner(c.grid, "Maintainer") - c.grid.NextRow() - - c.Packager = gadgets.NewBasicEntry(c.grid, "Packager") - c.grid.NextRow() - - c.GoPath = gadgets.NewBasicEntry(c.grid, "GoPath") - c.grid.NextRow() - - c.URL = gadgets.NewBasicEntry(c.grid, "URL") - c.grid.NextRow() - - c.Depends = gadgets.NewOneLiner(c.grid, "Depends") - c.grid.NextRow() - - c.BuildDepends = gadgets.NewOneLiner(c.grid, "Build-Depends") - c.grid.NextRow() - - c.Recommends = gadgets.NewOneLiner(c.grid, "Recommends") - c.grid.NextRow() - - c.Conflicts = gadgets.NewBasicEntry(c.grid, "Conflicts") - c.grid.NextRow() - - c.Description = gadgets.NewOneLiner(c.grid, "Description") - c.grid.NextRow() - - return c -} - -func updateControl(c *controlBox) { - c.URL.SetText(me.repo.URL) -} diff --git a/windowControlBox.go b/windowControlBox.go new file mode 100644 index 0000000..c5637a2 --- /dev/null +++ b/windowControlBox.go @@ -0,0 +1,124 @@ +package main + +import ( + "os" + + "go.wit.com/gui" + "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// This initializes the first window, a group and a button +// this is terribly old code. redo this all after widgets are switched to protobuf +func makebasicWindow() *gadgets.BasicWindow { + log.Warn("init basicWindow state") + win := gadgets.RawBasicWindow("Create .deb files for GO applications") + win.Make() + win.Custom = func() { + log.Info("got to close") + os.Exit(0) + } + + box1 := win.Box() + // me.cBox = newControl(box1) + newControl(box1) + + vbox := box1.Box().Horizontal() + group1 := vbox.NewGroup("controls").Horizontal() // Vertical() + + group1.NewButton("go build", func() { + shell.Run([]string{"go", "build", "-v", "-x"}) + }) + + group1.NewButton("read control file", func() { + readControlFile(me.repo) + }) + + group1.NewButton("write control file", func() { + writeDebianControlFile(me.repo) + }) + + group1.NewButton("Make .deb", func() { + win.Disable() + if ok, err := buildPackage(me.repo); ok { + log.Info("build worked") + os.Exit(0) + } else { + log.Warn("build failed", err) + } + win.Enable() + }) + + return win +} + +// This initializes the control box +func newControl(parent *gui.Node) *controlBox { + var c *controlBox + c = new(controlBox) + c.group = parent.NewGroup("choices") + c.grid = c.group.NewGrid("gridiron", 8, 1) + + c.Package = gadgets.NewOneLiner(c.grid, "Package") + c.grid.NextRow() + + c.Source = gadgets.NewOneLiner(c.grid, "Source") + c.grid.NextRow() + + c.Version = gadgets.NewOneLiner(c.grid, "Version") + c.grid.NextRow() + + c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture") + c.Architecture.AddText("all") + c.Architecture.AddText("riscv64") + c.Architecture.AddText("amd64") + c.Architecture.AddText("arm64") + c.Architecture.AddText("ppc64") + c.Architecture.AddText("i386") + c.Architecture.AddText("sparc64") + c.Architecture.AddText("alpha") + c.Architecture.SetText("riscv64") + c.grid.NextRow() + + c.InstallPath = gadgets.NewBasicCombobox(c.grid, "Install Path") + c.InstallPath.AddText("/usr/bin") + c.InstallPath.AddText("/usr/local/bin") + c.InstallPath.AddText("/bin") + c.InstallPath.AddText("/opt//bin") + c.InstallPath.SetText("/usr/bin") + c.grid.NextRow() + + c.Maintainer = gadgets.NewOneLiner(c.grid, "Maintainer") + c.grid.NextRow() + + c.Packager = gadgets.NewBasicEntry(c.grid, "Packager") + c.grid.NextRow() + + c.GoPath = gadgets.NewBasicEntry(c.grid, "GoPath") + c.grid.NextRow() + + c.URL = gadgets.NewBasicEntry(c.grid, "URL") + c.grid.NextRow() + + c.Depends = gadgets.NewOneLiner(c.grid, "Depends") + c.grid.NextRow() + + c.BuildDepends = gadgets.NewOneLiner(c.grid, "Build-Depends") + c.grid.NextRow() + + c.Recommends = gadgets.NewOneLiner(c.grid, "Recommends") + c.grid.NextRow() + + c.Conflicts = gadgets.NewBasicEntry(c.grid, "Conflicts") + c.grid.NextRow() + + c.Description = gadgets.NewOneLiner(c.grid, "Description") + c.grid.NextRow() + + return c +} + +func updateControl(c *controlBox) { + c.URL.SetText(me.repo.URL) +} -- cgit v1.2.3