MINOR: rearrange stuff

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-11-04 04:47:46 -05:00
parent af62b0320e
commit 0f8ed0da1f
5 changed files with 127 additions and 8 deletions

5
apt.go
View File

@ -24,6 +24,11 @@ func aptGroup(tab *gui.Node) {
bash("apt -y install apt-file")
bash("apt-file update")
})
n.AddButton("install packages", func (*gui.Node) {
aptPackagesWindow(nil)
})
n.AddButton("install base packages", func (*gui.Node) {
sudo( func() error {
line := "apt install moon-buggy2"

View File

@ -16,7 +16,6 @@ func golangDebug(w *gui.Node) {
gui.Config.Title = "golangDebug Window"
gui.Config.Width = 100
gui.Config.Height = 100
gui.Config.Exit = customExit
w = gui.NewWindow()
}

View File

@ -12,7 +12,6 @@ func updateDNS(w *gui.Node) {
gui.Config.Title = "dns update Window"
gui.Config.Width = 110
gui.Config.Height = 110
gui.Config.Exit = customExit
w = gui.NewWindow()
}

111
window-packages.go Normal file
View File

@ -0,0 +1,111 @@
package main
import "log"
import "os"
import "bufio"
import "strings"
import "errors"
import "git.wit.org/wit/gui"
func aptPackagesWindow(w *gui.Node) {
var aptoutput *gui.Node
var aptNode *gui.Node
var filename string
if (w == nil) {
gui.Config.Title = "apt configuration and package installer"
gui.Config.Width = 1600
gui.Config.Height = 800
gui.Config.Exit = nil
w = gui.NewWindow()
}
tab := w.AddTab("apt", nil)
// populateNEW(tab, "new")
////////////// filename /////////////////////////
gNode := tab.AddGroup("Options")
gNode.AddButton("default packages", func (*gui.Node) {
log.Println("STARTED HOSTNAME")
aptNode.SetText("bin/install-default-packages.sh")
filename = "bin/install-default-packages.sh"
b, _ := packrBox.FindString(filename)
if (aptoutput != nil) {
aptoutput.SetText(b)
}
log.Println("ENDED GetText() HOSTNAME =", filename)
})
gNode.CreateFontButton("fonts")
gNode.AddButton("Configure apt-file", func (*gui.Node) {
log.Println("STARTED HOSTNAME")
aptNode.SetText("bin/apt-file.sh")
filename = "bin/apt-file.sh"
b, _ := packrBox.FindString(filename)
if (aptoutput != nil) {
aptoutput.SetText(b)
}
log.Println("ENDED GetText() HOSTNAME =", filename)
})
var tmp []string
for i, s := range packrBox.List() {
log.Println("i, s =", i, s)
if strings.HasPrefix(s, "bin/") {
tmp = append(tmp, s)
}
}
// panic("junk")
aptNode = gNode.AddComboBox("test", tmp...)
aptNode.SetText(filename)
aptNode.OnChanged = func () {
log.Println("STARTED HOSTNAME")
filename = aptNode.GetText()
b, _ := packrBox.FindString(filename)
if (aptoutput != nil) {
aptoutput.SetText(b)
}
log.Println("ENDED GetText() HOSTNAME =", filename)
}
////////////// connect /////////////////////////
gNode = tab.AddGroup("")
gNode.AddButton("Run Script", func (*gui.Node) {
sudo( func() error {
log.Println("set resolv.conf to",filename)
b, _ := packrBox.FindString(filename)
// spew.Dump(b)
b = aptoutput.GetText()
log.Println("Setting /etc/resolv.conf to:\n\n" + b)
f, err := os.Create("/etc/resolv.conf")
if err != nil {
return errors.New("os.Create() /etc/resolv.conf failed")
}
defer f.Close()
w := bufio.NewWriter(f)
n4, err := w.WriteString(b)
log.Println("n4 =", n4)
w.Flush()
return nil
})
})
gui.Config.Stretchy = true
gNode.AddButton("set output", func (*gui.Node) {
if (aptoutput != nil) {
aptoutput.SetText("wow")
aptoutput.SetMargined(false)
}
})
gNode = tab.AddGroup("")
aptoutput = gNode.MakeGroupEdit("script:")
gui.Config.Stretchy = false
}

View File

@ -16,10 +16,15 @@ func tabResets(w *gui.Node) *gui.Node {
newTab := w.AddTab("tabResets()", nil)
/////////////////////////////////////////////////////////////////////////////
g1 := newTab.AddGroup("reset windows")
g1 := newTab.AddGroup("")
g1.NewLabel("Working Stuff")
g1.AddButton("Configure resolv.conf", func (*gui.Node) {
log.Println("supposed to make the resolv.conf window")
resolvWindow(nil)
})
g1.AddButton("Generic SSH Window", func (*gui.Node) {
sshGenericWindow(nil)
})
@ -28,17 +33,17 @@ func tabResets(w *gui.Node) *gui.Node {
xtermSettings(nil)
})
g1.AddButton("Configure resolv.conf", func (*gui.Node) {
log.Println("supposed to make the resolv.conf window")
resolvWindow(nil)
})
g1.AddButton("update DNS (IPv6)", func (*gui.Node) {
updateDNS(nil)
})
aptGroup(newTab)
// 'stretchy' doesn't work here. this is because it was set on the hbox(?)
// TODO: tear down all the gui elements and recreate them from the node tree
gui.Config.Stretchy = true
newTab.MakeBasicControlsPage("testing stuff")
gui.Config.Stretchy = false
/////////////////////////////////////////////////////////////////////////////
gn := newTab.AddGroup("GO")