Compare commits

..

No commits in common. "master" and "v0.20.2" have entirely different histories.

8 changed files with 73 additions and 110 deletions

14
.gitignore vendored
View File

@ -1,9 +1,5 @@
*.swp
go.mod
go.sum
/files/*
/*.deb
/resources/*
gadgetwindow
*
!.gitignore
!Makefile
!*.go
!LICENSE

View File

@ -1,45 +1,44 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: build
reset
./gadgetwindow
build:
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose:
GO111MODULE=off go build -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
clean:
-rm -f gadgetwindow
-rm resources/*.so
touch resources/blank.so
# embed the toolkit plugins in the binary
embed:
-rm resources/*.so
touch resources/blank.so
cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
nocui: build
reset
./gadgetwindow --gui nocui
gocui: build
reset
echo "redirecting STDOUT & STDERR to /tmp/gadgetwindow.out"
./gadgetwindow --gui gocui
./gadgetwindow --gui gocui >/tmp/gadgetwindow.stderr 2>&1
# ./gadgetwindow --gui gocui --tmp-log
log:
tail -f /tmp/guilogfile /tmp/witgui.* /tmp/gadget*
test-tmp-log: build
./gadgetwindow --gui andlabs --tmp-log
debugger: build
reset
./gadgetwindow --debugger
build:
ifeq ($(GO111MODULE),)
echo no. you must use GO111MODULE here
false
else
-rm -f gadgetwindow
go build -v -x
endif
stderr: build
echo "writing to /tmp/gadgetwindow.stderr"
./gadgetwindow >/tmp/gadgetwindow.stderr 2>&1
push:
git add --all
git commit -a
git push
goimports:
goimports -w *.go
@ -48,3 +47,4 @@ redomod:
goimports -w *.go
GO111MODULE= go mod init
GO111MODULE= go mod tidy

View File

@ -1,6 +0,0 @@
# gadgetwindow
This simple 'gui' demo also embedds the plugins into the binary
## Install go-glone
go build go.wit.com/apps/gadgetwindow@latest

27
args.go Normal file
View File

@ -0,0 +1,27 @@
package main
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
var args struct {
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
} else {
log.Info("cmd line --debugger == false")
}
}

38
argv.go
View File

@ -1,38 +0,0 @@
package main
import (
"os"
"github.com/alexflint/go-arg"
)
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
var argv args
type args struct {
Demo string `arg:"positional" help:"this is just a demo"`
}
func (a args) Description() string {
return `
This basicwindow example demonstrates multiple windows
`
}
func init() {
pp := arg.MustParse(&argv)
// for very new users or users unfamilar with the command line, this may help them
if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
}
func (args) Version() string {
return "basicwindow " + VERSION
}

View File

@ -1,20 +0,0 @@
package main
/*
enables GUI options and the debugger in your application
*/
import (
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
func init() {
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

22
main.go
View File

@ -1,8 +1,7 @@
// This creates a simple hello world window
package main
import (
"embed"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gadgets"
@ -10,15 +9,9 @@ import (
"go.wit.com/log"
)
// sent via -ldflags
var VERSION string
// This is the beginning of the binary tree of widgets
var myGui *gui.Node
//go:embed resources/*
var resources embed.FS
// this is the primary window. If you close it, the program will exit
var mainWindow *gui.Node
@ -34,13 +27,24 @@ func main() {
log.SetAll(true)
log.ShowFlags()
}
if args.TmpLog {
// send all log() output to a file in /tmp
log.SetTmp()
}
myGui = gui.New()
myGui.InitEmbed(resources)
myGui.Default()
helloworld()
basicWindow = makebasicWindow()
// run the debugger if triggered from the commandline
if debugger.ArgDebug() {
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
// go will sit here until the window exits
gui.Watchdog()
}

View File