comples and runs after go.wit.com/gui migration

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 12:13:21 -06:00
parent a719d0027f
commit 6a09621efc
15 changed files with 244 additions and 278 deletions

View File

@ -5,8 +5,8 @@ VERSION = $(shell cat resources/VERSION)
# PATH=/usr/bin:$PATH go version # PATH=/usr/bin:$PATH go version
run: new-build run: build
~/go/bin/debian-gui ./wit-debian-gui
new-build: new-build:
# go mod edit -replace go.wit.com/wit/gui=/home/jcarr/go/src/git.wit.org/wit/gui # go mod edit -replace go.wit.com/wit/gui=/home/jcarr/go/src/git.wit.org/wit/gui
@ -21,7 +21,7 @@ new-build:
# to build the old way # to build the old way
build: build:
GO111MODULE="off" go install -ldflags " \ GO111MODULE="off" go build -v -ldflags " \
-X main.GITCOMMIT=${GITCOMMIT} \ -X main.GITCOMMIT=${GITCOMMIT} \
-X main.GOVERSION='${GOVERSION}' \ -X main.GOVERSION='${GOVERSION}' \
-X main.BUILDTIME='${BUILDTIME}' \ -X main.BUILDTIME='${BUILDTIME}' \

23
apt.go
View File

@ -2,13 +2,14 @@ package main
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
) )
func aptGroup(tab *gui.Node) { func aptGroup(box *gui.Node) {
n := tab.AddGroup("apt Resets") n := box.NewGroup("apt Resets")
n.AddButton("update apt-file", func (*gui.Node) { n.NewButton("update apt-file", func () {
// shell.Script("apt -y install apt-file\napt-file update") // shell.Script("apt -y install apt-file\napt-file update")
// xterm("apt -y install apt-file; apt-file update") // xterm("apt -y install apt-file; apt-file update")
// gui.ErrorWindow("test error window", "this is the error") // gui.ErrorWindow("test error window", "this is the error")
@ -17,7 +18,7 @@ func aptGroup(tab *gui.Node) {
return err return err
}) })
if (err != nil) { if (err != nil) {
gui.ErrorWindow("Error", "Failed to run:\napt install moon-buggy") log.Warn("Error", "Failed to run:\napt install moon-buggy")
return return
} }
err = bash("bash -x /tmp/jcarr") err = bash("bash -x /tmp/jcarr")
@ -25,28 +26,28 @@ func aptGroup(tab *gui.Node) {
bash("apt-file update") bash("apt-file update")
}) })
n.AddButton("install packages", func (*gui.Node) { n.NewButton("install packages", func () {
aptPackagesWindow(nil) aptPackagesWindow()
}) })
n.AddButton("install base packages", func (*gui.Node) { n.NewButton("install base packages", func () {
sudo( func() error { sudo( func() error {
line := "apt install moon-buggy2" line := "apt install moon-buggy2"
err := bash(line) err := bash(line)
if (err != nil) { if (err != nil) {
gui.ErrorWindow("Error", "Failed to run:\n" + line) log.Error(err, "Error", "Failed to run:\n" + line)
return err return err
} }
return nil return nil
}) })
}) })
n.AddButton("purge rc-only", func (*gui.Node) { n.NewButton("purge rc-only", func () {
xterm("dpkg -l |grep ^rc | awk '{print $2}' |xargs apt remove --purge -y") xterm("dpkg -l |grep ^rc | awk '{print $2}' |xargs apt remove --purge -y")
}) })
n.AddButton("install defaults", func (*gui.Node) { n.NewButton("install defaults", func () {
xterm("./resources/bin/setup-packages-default") xterm("./resources/bin/setup-packages-default")
}) })
n.AddButton("install kvm", func (*gui.Node) { n.NewButton("install kvm", func () {
xterm("./resources/bin/setup-packages-kvm") xterm("./resources/bin/setup-packages-kvm")
}) })

View File

@ -40,7 +40,7 @@ func newMmakeButtonValues(name string, custom func(*gui.Node)) *myButtonInfo {
} }
func makeXtermButton(n *gui.Node, name string, action string, custom string) *gui.Node { func makeXtermButton(n *gui.Node, name string, action string, custom string) *gui.Node {
n.AddButton(name, func (*gui.Node) { n.NewButton(name, func () {
log.Println("xterm cmd=", custom) log.Println("xterm cmd=", custom)
xterm(custom) xterm(custom)
}) })

40
main.go
View File

@ -1,11 +1,12 @@
package main package main
import ( import (
"log"
"os" "os"
"time" "time"
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"github.com/gobuffalo/packr" "github.com/gobuffalo/packr"
) )
@ -29,7 +30,9 @@ var debugTest bool = false
// var xterm = []string{"nohup", "xterm", "-geometry", geom} // var xterm = []string{"nohup", "xterm", "-geometry", geom}
var useFirefox bool = true var useFirefox bool = true
var firefox = []string{"firefox", "--new-window"} var firefox = []string{"firefox", "--new-window"}
var packrBox packr.Box var packrBox *packr.Box
var myGui *gui.Node
func customExit(n *gui.Node) { func customExit(n *gui.Node) {
log.Println("Should Exit Here") log.Println("Should Exit Here")
@ -61,38 +64,23 @@ func main() {
// runs the GO profiler in a goroutine // runs the GO profiler in a goroutine
go pprofMain() go pprofMain()
go gui.Main(initGUI) myGui = gui.New().Default()
log.Warn("Starting window")
gadgets.NewBasicWindow(myGui, "Debian SID Mate Control Panel " + VERSION)
tabResets()
windowAddWWW()
golangDebug()
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
gui.Queue(delayedTabs) delayedTabs()
go systrayMain() go systrayMain()
watchWindows() watchWindows()
} }
// only os.Exit() on close of the main Window
// TODO: Change to only exit from systray(?)
func initGUI() {
g := &gui.GuiConfig{
Exit: customExit,
Stretchy: false,
}
log.Println("g =", g)
gui.Config.Exit = customExit
gui.Config.Stretchy = false
mainWindow(nil)
gui.Config.Exit = nil
}
func delayedTabs() { func delayedTabs() {
log.Println("delayedTabs() could have added a tab here\n") log.Println("delayedTabs() could have added a tab here\n")
// jcarrWindow.AddTab("delayed tab", nil) // jcarrWindow.AddTab("delayed tab", nil)
} }
func normalWindowClose(n *gui.Node) {
log.Println("TODO: close this window correctly and empty the node")
n.Dump()
name := n.Name
// TODO: this is probably some sort of terrible and wrong memory leak
delete(gui.Data.NodeMap, name)
}

22
os.go
View File

@ -1,15 +1,17 @@
package main package main
import "log" import (
import "strings" "strings"
import "os" "os"
import "os/exec" "os/exec"
import "io/ioutil" "io/ioutil"
import "errors" "errors"
import "bufio" "bufio"
import "go.wit.com/gui/gui" "go.wit.com/log"
import "github.com/davecgh/go-spew/spew" // "go.wit.com/gui/gui"
"github.com/davecgh/go-spew/spew"
)
func runSimpleCommand(s string) { func runSimpleCommand(s string) {
cmd := strings.TrimSpace(s) // this is like 'chomp' in perl cmd := strings.TrimSpace(s) // this is like 'chomp' in perl
@ -128,7 +130,7 @@ func sudo(f func() error) error {
e := "You must be root to do this." e := "You must be root to do this."
log.Println(e, "uid =", uid) log.Println(e, "uid =", uid)
if (uid != 0) { if (uid != 0) {
gui.ErrorWindow("Permissions Failed", e) log.Warn("Permissions Failed", e)
return errors.New("not root") return errors.New("not root")
} }
err := f() err := f()

View File

@ -1,15 +1,19 @@
package main package main
import "fmt" import (
import "os" "fmt"
import "io/ioutil" "os"
import "log" "io/ioutil"
import "time" "log"
"time"
// "go.wit.com/gui/gui"
"go.wit.com/gui/debugger"
"github.com/davecgh/go-spew/spew"
"github.com/getlantern/systray"
import "go.wit.com/gui/gui"
import "github.com/davecgh/go-spew/spew"
import "github.com/getlantern/systray"
// "github.com/skratchdot/open-golang/open" // "github.com/skratchdot/open-golang/open"
)
func systrayMain() { func systrayMain() {
onExit := func() { onExit := func() {
@ -45,7 +49,6 @@ func onReady() {
}() }()
*/ */
var c = 0
// We can manipulate the systray in other goroutines // We can manipulate the systray in other goroutines
go func() { go func() {
systray.SetIcon(myIcon) systray.SetIcon(myIcon)
@ -91,16 +94,11 @@ func onReady() {
log.Println("CHECKED END") log.Println("CHECKED END")
case <-mDump.ClickedCh: case <-mDump.ClickedCh:
log.Println("START") log.Println("START")
gui.Config.Width = 800 debugger.DebugWindow(myGui)
gui.Config.Height = 300
gui.Queue(gui.DebugWindow)
log.Println("END") log.Println("END")
case <-mShow.ClickedCh: case <-mShow.ClickedCh:
log.Println("START Show()") log.Println("START Show()")
gui.Config.Width = 640 + c*20 debugger.DebugWindow(myGui)
c = c + 1
gui.Config.Height = 480
gui.Queue(gui.DebugWindow)
log.Println("END") log.Println("END")
case <-mHide.ClickedCh: case <-mHide.ClickedCh:
log.Println("START Hide()") log.Println("START Hide()")

View File

@ -2,66 +2,66 @@ package main
import ( import (
// "bufio" // "bufio"
"log"
"os" "os"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"runtime/pprof" "runtime/pprof"
"go.wit.com/log"
// "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
import "go.wit.com/gui/gui"
func golangDebug(w *gui.Node) { var langWin *gadgets.BasicWindow
gui.Config.Stretchy = false
if (w == nil) { func golangDebug() {
gui.Config.Title = "golangDebug Window" if langWin != nil {
gui.Config.Width = 100 langWin.Toggle()
gui.Config.Height = 100 return
w = gui.NewWindow()
} }
langWin = gadgets.NewBasicWindow(myGui, "golangDebug")
tab := w.AddTab("golangDebug()", nil)
/////////////////////////////// Column DEBUG GOLANG ////////////////////// /////////////////////////////// Column DEBUG GOLANG //////////////////////
gNode := tab.AddGroup("golang") gNode := langWin.Box().NewGroup("golang")
gNode.AddButton("runtime.Stack() dump", func (*gui.Node) { gNode.NewButton("runtime.Stack() dump", func () {
log.Println("\tSTART") log.Println("\tSTART")
buf := make([]byte, 1<<16) buf := make([]byte, 1<<16)
runtime.Stack(buf, true) runtime.Stack(buf, true)
log.Printf("%s", buf) log.Printf("%s", buf)
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("dumpModuleInfo", func (*gui.Node) { gNode.NewButton("dumpModuleInfo", func () {
log.Println("\tSTART") log.Println("\tSTART")
dumpModuleInfo() dumpModuleInfo()
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("debug.PrintStack", func (*gui.Node) { gNode.NewButton("debug.PrintStack", func () {
log.Println("\tSTART") log.Println("\tSTART")
debug.PrintStack() debug.PrintStack()
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("pprof.Lookup goroutine", func (*gui.Node) { gNode.NewButton("pprof.Lookup goroutine", func () {
log.Println("\tSTART") log.Println("\tSTART")
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1) pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("pprof.Lookup", func (*gui.Node) { gNode.NewButton("pprof.Lookup", func () {
log.Println("\tSTART") log.Println("\tSTART")
pprof.Lookup("heap").WriteTo(os.Stdout, 1) pprof.Lookup("heap").WriteTo(os.Stdout, 1)
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("pprof.Lookup block", func (*gui.Node) { gNode.NewButton("pprof.Lookup block", func () {
log.Println("\tSTART") log.Println("\tSTART")
pprof.Lookup("block").WriteTo(os.Stdout, 1) pprof.Lookup("block").WriteTo(os.Stdout, 1)
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("pprof.Lookup threadcreate", func (*gui.Node) { gNode.NewButton("pprof.Lookup threadcreate", func () {
log.Println("\tSTART") log.Println("\tSTART")
pprof.Lookup("threadcreate").WriteTo(os.Stdout, 1) pprof.Lookup("threadcreate").WriteTo(os.Stdout, 1)
log.Println("\tEND") log.Println("\tEND")
}) })
gNode.AddButton("runtime.ReadMemStats", func (*gui.Node) { gNode.NewButton("runtime.ReadMemStats", func () {
var s runtime.MemStats var s runtime.MemStats
runtime.ReadMemStats(&s) runtime.ReadMemStats(&s)
log.Printf("alloc: %v bytes\n", s.Alloc) log.Printf("alloc: %v bytes\n", s.Alloc)

View File

@ -1,36 +1,33 @@
package main package main
// import "os" import (
// import "log" "go.wit.com/gui/gui"
// import "strconv" "go.wit.com/gui/gadgets"
// import "io/ioutil" )
// import "bufio"
import "go.wit.com/gui/gui" var upDNSwin *gadgets.BasicWindow
func updateDNS(w *gui.Node) { func updateDNS(w *gui.Node) {
if (w == nil) { if (upDNSwin != nil) {
gui.Config.Title = "dns update Window" upDNSwin.Toggle()
gui.Config.Width = 110 return
gui.Config.Height = 110
w = gui.NewWindow()
} }
tab := w.AddTab("updateDNS()", nil) upDNSwin = gadgets.NewBasicWindow(w, "dns update Window")
// populateNEW(tab, "new")
////////////// filename ///////////////////////// ////////////// filename /////////////////////////
gNode := tab.AddGroup("eth0 update") gNode := upDNSwin.Box().NewGroup("eth0 update")
// fontsize := "16" // fontsize := "16"
dnsNode := gNode.AddComboBox("8", dnsNode := gNode.NewCombobox("size")
"16", dnsNode.AddText("8")
"24") dnsNode.AddText("16")
dnsNode.AddText("24")
dnsNode.SetText("12") dnsNode.SetText("12")
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode = tab.AddGroup("Update") gNode = upDNSwin.Box().NewGroup("Update")
gNode.AddButton("setup .Xresources", func (*gui.Node) { gNode.NewButton("setup .Xresources", func () {
}) })
} }

View File

@ -1,26 +0,0 @@
package main
import (
// "log"
"go.wit.com/gui/gui"
)
func mainWindow(w *gui.Node) *gui.Node {
if w == nil {
gui.Config.Title = "Debian SID Mate Control Panel " + VERSION
gui.Config.Width = 101
gui.Config.Height = 101
w = gui.NewWindow()
}
// newTab := w.AddTab("Main Tab", nil)
tabResets(w)
windowAddWWW(w)
golangDebug(w)
return w
}

View File

@ -8,28 +8,26 @@ import (
"strings" "strings"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
func aptPackagesWindow(w *gui.Node) { var aptWin *gadgets.BasicWindow
func aptPackagesWindow() {
var aptoutput *gui.Node var aptoutput *gui.Node
var aptNode *gui.Node var aptNode *gui.Node
var filename string var filename string
if w == nil { if aptWin != nil {
gui.Config.Title = "apt configuration and package installer" aptWin.Toggle()
gui.Config.Width = 1600 return
gui.Config.Height = 800
gui.Config.Exit = nil
w = gui.NewWindow()
} }
aptWin = gadgets.NewBasicWindow(myGui, "apt configuration and package installer")
tab := w.AddTab("apt", nil)
// populateNEW(tab, "new")
////////////// filename ///////////////////////// ////////////// filename /////////////////////////
gNode := tab.AddGroup("Options") gNode := aptWin.Box().NewGroup("Options")
gNode.AddButton("default packages", func(*gui.Node) { gNode.NewButton("default packages", func() {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
aptNode.SetText("bin/install-default-packages.sh") aptNode.SetText("bin/install-default-packages.sh")
filename = "bin/install-default-packages.sh" filename = "bin/install-default-packages.sh"
@ -40,9 +38,9 @@ func aptPackagesWindow(w *gui.Node) {
log.Println("ENDED GetText() HOSTNAME =", filename) log.Println("ENDED GetText() HOSTNAME =", filename)
}) })
gNode.CreateFontButton("fonts") // gNode.CreateFontButton("fonts")
gNode.AddButton("Configure apt-file", func(*gui.Node) { gNode.NewButton("Configure apt-file", func() {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
aptNode.SetText("bin/apt-file.sh") aptNode.SetText("bin/apt-file.sh")
filename = "bin/apt-file.sh" filename = "bin/apt-file.sh"
@ -62,10 +60,13 @@ func aptPackagesWindow(w *gui.Node) {
} }
// panic("junk") // panic("junk")
aptNode = gNode.AddComboBox("test", tmp...) aptNode = gNode.NewCombobox("test")
for _, thing := range tmp {
aptNode.AddText(thing)
}
aptNode.SetText(filename) aptNode.SetText(filename)
aptNode.OnChanged = func() { aptNode.Custom = func() {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
filename = aptNode.GetText() filename = aptNode.GetText()
b, _ := packrBox.FindString(filename) b, _ := packrBox.FindString(filename)
@ -76,9 +77,9 @@ func aptPackagesWindow(w *gui.Node) {
} }
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode = tab.AddGroup("") gNode = aptWin.Box().NewGroup("")
gNode.AddButton("Run Script", func(*gui.Node) { gNode.NewButton("Run Script", func() {
sudo(func() error { sudo(func() error {
log.Println("set resolv.conf to", filename) log.Println("set resolv.conf to", filename)
b, _ := packrBox.FindString(filename) b, _ := packrBox.FindString(filename)
@ -100,15 +101,15 @@ func aptPackagesWindow(w *gui.Node) {
}) })
}) })
gui.Config.Stretchy = true // gui.Config.Stretchy = true
gNode.AddButton("set output", func(*gui.Node) { gNode.NewButton("set output", func() {
if aptoutput != nil { if aptoutput != nil {
aptoutput.SetText("wow") aptoutput.SetText("wow")
aptoutput.SetMargined(false) aptoutput.Margin()
} }
}) })
gNode = tab.AddGroup("") gNode = aptWin.Box().NewGroup("")
aptoutput = gNode.MakeGroupEdit("script:") // aptoutput = gNode.MakeGroupEdit("script:")
gui.Config.Stretchy = false // gui.Config.Stretchy = false
} }

View File

@ -1,66 +1,61 @@
package main package main
import ( import (
"log" "go.wit.com/log"
"go.wit.com/gui/gadgets"
"go.wit.com/gui/gui"
) )
func tabResets(w *gui.Node) *gui.Node { var tabWin *gadgets.BasicWindow
if w == nil {
gui.Config.Title = "resets window"
gui.Config.Width = 240
gui.Config.Height = 280
gui.Config.Exit = customExit
w = gui.NewWindow()
}
newTab := w.AddTab("tabResets()", nil) func tabResets() {
if tabWin != nil {
tabWin.Toggle()
return
}
tabWin = gadgets.NewBasicWindow(myGui, "resets window")
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
g1 := newTab.AddGroup("") g1 := tabWin.Box().NewGroup("")
g1.NewLabel("Working Stuff") g1.NewLabel("Working Stuff")
g1.AddButton("Configure resolv.conf", func(*gui.Node) { g1.NewButton("Configure resolv.conf", func() {
log.Println("supposed to make the resolv.conf window") log.Println("supposed to make the resolv.conf window")
resolvWindow(nil) resolvWindow()
}) })
g1.AddButton("Generic SSH Window", func(*gui.Node) { g1.NewButton("Generic SSH Window", func() {
sshGenericWindow(nil) sshGenericWindow()
}) })
g1.AddButton("Configure xterm", func(*gui.Node) { g1.NewButton("Configure xterm", func() {
xtermSettings(nil) xtermSettings(nil)
}) })
g1.AddButton("update DNS (IPv6)", func(*gui.Node) { g1.NewButton("update DNS (IPv6)", func() {
updateDNS(nil) updateDNS(nil)
}) })
aptGroup(newTab) aptGroup(tabWin.Box())
// 'stretchy' doesn't work here. this is because it was set on the hbox(?) // '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 // TODO: tear down all the gui elements and recreate them from the node tree
gui.Config.Stretchy = true // tabWin.Box().MakeBasicControlsPage("testing stuff")
newTab.MakeBasicControlsPage("testing stuff")
gui.Config.Stretchy = false
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
gn := newTab.AddGroup("GO") gn := tabWin.Box().NewGroup("GO")
gn.AddButton("go install golang.org/x/tools/gopls@latest", func(*gui.Node) { gn.NewButton("go install golang.org/x/tools/gopls@latest", func() {
xterm("go install golang.org/x/tools/gopls@latest") xterm("go install golang.org/x/tools/gopls@latest")
}) })
g := newTab.AddGroup("VIM") g := tabWin.Box().NewGroup("VIM")
g.AddButton("vim-go clone", func(*gui.Node) { g.NewButton("vim-go clone", func() {
xterm("git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go") xterm("git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go")
}) })
g.AddButton("vim-go vimrc settings", func(*gui.Node) { g.NewButton("vim-go vimrc settings", func() {
log.Println("echo", "let g:go_def_mode='gopls'\nlet g:go_info_mode='gopls'") log.Println("echo", "let g:go_def_mode='gopls'\nlet g:go_info_mode='gopls'")
// xterm("echo", "let g:go_def_mode='gopls'\nlet g:go_info_mode='gopls'") // xterm("echo", "let g:go_def_mode='gopls'\nlet g:go_info_mode='gopls'")
}) })
return newTab return
} }

View File

@ -1,29 +1,30 @@
package main package main
import "log" import (
import "os" "os"
import "bufio" "bufio"
import "strings" "strings"
import "errors" "errors"
import "go.wit.com/gui/gui"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
var filename string = "resolv-1-1-1-1.conf" var filename string = "resolv-1-1-1-1.conf"
var generaloutput *gui.Node var generaloutput *gui.Node
func resolvWindow(w *gui.Node) { var resWin *gadgets.BasicWindow
if (w == nil) {
gui.Config.Title = "resolv.conf Window"
gui.Config.Width = 1000
gui.Config.Height = 400
gui.Config.Exit = nil
w = gui.NewWindow()
}
tab := w.AddTab("resolv.conf Tab", nil) func resolvWindow() {
// populateNEW(tab, "new") if (resWin != nil) {
resWin.Toggle()
return
}
resWin = gadgets.NewBasicWindow(myGui,"resolv.conf Window")
////////////// filename ///////////////////////// ////////////// filename /////////////////////////
gNode := tab.AddGroup("filename") gNode := resWin.Box().NewGroup("filename")
var tmp []string var tmp []string
for i, s := range packrBox.List() { for i, s := range packrBox.List() {
@ -34,10 +35,13 @@ func resolvWindow(w *gui.Node) {
} }
// panic("junk") // panic("junk")
resolvNode := gNode.AddComboBox("test", tmp...) resolvNode := gNode.NewCombobox("test")
for _, thing := range tmp {
resolvNode.AddText(thing)
}
resolvNode.SetText(filename) resolvNode.SetText(filename)
resolvNode.OnChanged = func () { resolvNode.Custom = func () {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
filename = resolvNode.GetText() filename = resolvNode.GetText()
b, _ := packrBox.FindString(filename) b, _ := packrBox.FindString(filename)
@ -48,9 +52,9 @@ func resolvWindow(w *gui.Node) {
} }
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode = tab.AddGroup("") gNode = resWin.Box().NewGroup("")
gNode.AddButton("Update /etc/resolv.conf", func (*gui.Node) { gNode.NewButton("Update /etc/resolv.conf", func () {
sudo( func() error { sudo( func() error {
log.Println("set resolv.conf to",filename) log.Println("set resolv.conf to",filename)
b, _ := packrBox.FindString(filename) b, _ := packrBox.FindString(filename)
@ -71,24 +75,23 @@ func resolvWindow(w *gui.Node) {
return nil return nil
}) })
}) })
gNode.AddButton("test ping ipv4", func (*gui.Node) { gNode.NewButton("test ping ipv4", func () {
bash("ping -c 3 -4 google.com") bash("ping -c 3 -4 google.com")
}) })
gNode.AddButton("test ping ipv6", func (*gui.Node) { gNode.NewButton("test ping ipv6", func () {
bash("ping -c 3 -6 google.com") bash("ping -c 3 -6 google.com")
}) })
gui.Config.Stretchy = true gNode.NewButton("set output", func () {
gNode.AddButton("set output", func (*gui.Node) {
if (generaloutput != nil) { if (generaloutput != nil) {
generaloutput.SetText("wow") generaloutput.SetText("wow")
generaloutput.SetMargined(false) generaloutput.Margin()
} }
}) })
gui.Config.Stretchy = false
gui.Config.Stretchy = true gNode = resWin.Box().NewGroup("Update")
gNode = tab.AddGroup("Update") gNode.NewButton("MakeGroupEdit()", func () {
generaloutput = gNode.MakeGroupEdit("resolv.conf:") log.Warn("recreate a gadget for editing the resolv.conf")
gui.Config.Stretchy = false //generaloutput = gNode.MakeGroupEdit("resolv.conf:")
})
} }

View File

@ -1,33 +1,32 @@
package main package main
import "log" import (
import "os/user" "os/user"
// import "reflect"
import "go.wit.com/gui/gui" "go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
var userNode *gui.Node var userNode *gui.Node
var sshWin *gadgets.BasicWindow
func sshGenericWindow(w *gui.Node) { func sshGenericWindow() {
if (w == nil) { if (sshWin != nil) {
gui.Config.Title = "sshWindow" sshWin.Toggle()
gui.Config.Width = 101 return
gui.Config.Height = 131
gui.Config.Exit = customExit
w = gui.NewWindow()
} }
sshWin = gadgets.NewBasicWindow(myGui, "sshWindow")
tab := w.AddTab("sshWindow()", nil)
// populateNEW(tab, "new")
////////////// username ///////////////////////// ////////////// username /////////////////////////
gNode := tab.AddGroup("username") gNode := sshWin.Box().NewGroup("username")
userNode = gNode.AddComboBox("username", userNode = gNode.NewCombobox("username")
"root", userNode.AddText("root")
"jcarr", userNode.AddText("jcarr")
"hugo") userNode.AddText("hugo")
userNode.OnChanged = func () { userNode.Custom = func () {
username = userNode.GetText() username = userNode.GetText()
log.Println("SETTING: username=", username) log.Println("SETTING: username=", username)
userNode.Dump() userNode.Dump()
@ -40,14 +39,14 @@ func sshGenericWindow(w *gui.Node) {
// panic("blah") // panic("blah")
////////////// hostname ///////////////////////// ////////////// hostname /////////////////////////
gNode = tab.AddGroup("homename") gNode = sshWin.Box().NewGroup("homename")
hostNode := gNode.AddComboBox("hostname", hostNode := gNode.NewCombobox("hostname")
"www", hostNode.AddText("www")
"mirrors", hostNode.AddText("mirrors")
"git") hostNode.AddText("git")
hostNode.OnChanged = func () { hostNode.Custom = func () {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
hostname = hostNode.GetText() hostname = hostNode.GetText()
log.Println("ENDED GetText() HOSTNAME") log.Println("ENDED GetText() HOSTNAME")
@ -56,9 +55,9 @@ func sshGenericWindow(w *gui.Node) {
hostNode.SetText("mirrors") hostNode.SetText("mirrors")
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode = tab.AddGroup("connect") gNode = sshWin.Box().NewGroup("connect")
gNode.AddButton("connect", func (*gui.Node) { gNode.NewButton("connect", func () {
cmd := "ssh -v " + username + "@" + hostname cmd := "ssh -v " + username + "@" + hostname
log.Println("xterm cmd=", cmd) log.Println("xterm cmd=", cmd)
xterm(cmd) xterm(cmd)

View File

@ -1,20 +1,22 @@
package main package main
import "log" import (
import "go.wit.com/gui/gui" "go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
func windowAddWWW(w *gui.Node) { var webWin *gadgets.BasicWindow
if (w == nil) {
gui.Config.Title = "webpages" func windowAddWWW() {
gui.Config.Width = 102 if (webWin != nil) {
gui.Config.Height = 102 webWin.Toggle()
w = gui.NewWindow() return
} }
webWin = gadgets.NewBasicWindow(myGui, "webpages")
tab := w.AddTab("http", nil)
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode := tab.AddGroup("www") gNode := webWin.Box().NewGroup("www")
firefoxButton(gNode, "git", "https://git.wit.org/") firefoxButton(gNode, "git", "https://git.wit.org/")
firefoxButton(gNode, "mirrors", "https://mirrors.wit.org/") firefoxButton(gNode, "mirrors", "https://mirrors.wit.org/")
firefoxButton(gNode, "IPv6-Only ping", "http://ping.wit.org/") firefoxButton(gNode, "IPv6-Only ping", "http://ping.wit.org/")
@ -23,7 +25,7 @@ func windowAddWWW(w *gui.Node) {
} }
func firefoxButton (n *gui.Node, name string, url string) { func firefoxButton (n *gui.Node, name string, url string) {
n.AddButton(name, func (*gui.Node) { n.NewButton(name, func () {
log.Println("button clicked: trying to open url") log.Println("button clicked: trying to open url")
var tmp []string var tmp []string
tmp = append(tmp, "nohup") tmp = append(tmp, "nohup")

View File

@ -1,37 +1,43 @@
package main package main
import "log" import (
// import "strconv" "io/ioutil"
import "io/ioutil"
import "go.wit.com/gui/gui" "go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
var fontNode *gui.Node var fontNode *gui.Node
var fontsize string = "" var fontsize string = ""
func xtermSettings(w *gui.Node) { var xtermWin *gadgets.BasicWindow
if (w == nil) {
gui.Config.Title = "Configure xterm"
gui.Config.Width = 105
gui.Config.Height = 105
gui.Config.Exit = normalWindowClose
w = gui.NewWindow()
}
tab := w.AddTab("xtermSettings()", nil) func xtermSettings(w *gui.Node) {
if (xtermWin != nil) {
xtermWin.Toggle()
return
}
xtermWin = gadgets.NewBasicWindow(myGui, "Configure xterm")
// Select your fontsize // Select your fontsize
gNode := tab.AddGroup("fontsize") gNode := xtermWin.Box().NewGroup("fontsize")
fontsize = "16" fontsize = "16"
fontNode = gNode.AddComboBox("fontsize", "8", "12", "16", "24", "32") fontNode = gNode.NewCombobox("fontsize")
fontNode.OnChanged = func () { fontNode.AddText("8")
fontNode.AddText("12")
fontNode.AddText("16")
fontNode.AddText("24")
fontNode.AddText("32")
fontNode.Custom = func () {
fontsize = fontNode.GetText() fontsize = fontNode.GetText()
} }
fontNode.SetText(fontsize) fontNode.SetText(fontsize)
////////////// connect ///////////////////////// ////////////// connect /////////////////////////
gNode = tab.AddGroup("Update") gNode = xtermWin.Box().NewGroup("Update")
gNode.AddButton("setup .Xresources", func (*gui.Node) { gNode.NewButton("setup .Xresources", func () {
log.Println("fontsize =", fontsize) log.Println("fontsize =", fontsize)
// write out .Xresources file // write out .Xresources file
@ -46,12 +52,12 @@ func xtermSettings(w *gui.Node) {
log.Println("button click end") log.Println("button click end")
}) })
gNode.AddButton("test xterm", func (*gui.Node) { gNode.NewButton("test xterm", func () {
cmd := "xterm" cmd := "xterm"
xterm(cmd) xterm(cmd)
}) })
gNode.AddButton("fontNode.GetText()", func (*gui.Node) { gNode.NewButton("fontNode.GetText()", func () {
if (fontNode != nil) { if (fontNode != nil) {
fontsize = fontNode.GetText() fontsize = fontNode.GetText()
log.Println("set fontsize =", fontsize) log.Println("set fontsize =", fontsize)