GUI: show error windows

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-11-03 22:41:01 -05:00
parent 25fb41e9be
commit 6c5e59073b
3 changed files with 9 additions and 5 deletions

5
apt.go
View File

@ -11,13 +11,14 @@ func aptGroup(tab *gui.Node) {
n.AddButton("update apt-file", func (*gui.Node) { n.AddButton("update apt-file", func (*gui.Node) {
// 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")
n.ErrorWindow("test error window", "this is the error") // gui.ErrorWindow("test error window", "this is the error")
err := sudo( func() error { err := sudo( func() error {
err := bash("apt install moon-buggy") err := bash("apt install moon-buggy")
return err return err
}) })
if (err != nil) { if (err != nil) {
panic("bash failed") gui.ErrorWindow("Error", "Failed to run:\napt install moon-buggy")
return
} }
err = bash("bash -x /tmp/jcarr") err = bash("bash -x /tmp/jcarr")
bash("apt -y install apt-file") bash("apt -y install apt-file")

5
os.go
View File

@ -8,6 +8,7 @@ import "io/ioutil"
import "errors" import "errors"
import "bufio" import "bufio"
import "git.wit.org/wit/gui"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
/* /*
@ -135,8 +136,10 @@ func bash(cmdline string) error {
func sudo(f func() error) error { func sudo(f func() error) error {
uid := os.Getuid() uid := os.Getuid()
log.Println("You must be root to do this. uid =", uid) e := "You must be root to do this."
log.Println(e, "uid =", uid)
if (uid != 0) { if (uid != 0) {
gui.ErrorWindow("Permissions Failed", e)
return errors.New("not root") return errors.New("not root")
} }
err := f() err := f()

View File

@ -7,7 +7,7 @@ import "strings"
import "errors" import "errors"
import "git.wit.org/wit/gui" import "git.wit.org/wit/gui"
var filename string = "" var filename string = "resolv-1-1-1-1.conf"
func resolvWindow(w *gui.Node) { func resolvWindow(w *gui.Node) {
if (w == nil) { if (w == nil) {
@ -35,7 +35,7 @@ func resolvWindow(w *gui.Node) {
resolvNode := gNode.AddComboBox("test", tmp...) resolvNode := gNode.AddComboBox("test", tmp...)
resolvNode.SetText("resolv-1-1-1-1.conf") resolvNode.SetText(filename)
resolvNode.OnChanged = func () { resolvNode.OnChanged = func () {
log.Println("STARTED HOSTNAME") log.Println("STARTED HOSTNAME")
filename = resolvNode.GetText() filename = resolvNode.GetText()