diff --git a/apt.go b/apt.go index c7be9e8..1838c52 100644 --- a/apt.go +++ b/apt.go @@ -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" diff --git a/window-debug-golang.go b/window-debug-golang.go index da8dc07..362922e 100644 --- a/window-debug-golang.go +++ b/window-debug-golang.go @@ -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() } diff --git a/window-dns-update.go b/window-dns-update.go index e3d0035..6bc0236 100644 --- a/window-dns-update.go +++ b/window-dns-update.go @@ -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() } diff --git a/window-packages.go b/window-packages.go new file mode 100644 index 0000000..aacd9f0 --- /dev/null +++ b/window-packages.go @@ -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 +} diff --git a/window-resets.go b/window-resets.go index 4e91ce3..763a1ef 100644 --- a/window-resets.go +++ b/window-resets.go @@ -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")