Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
db990457e5 | |
|
161f3934ce | |
|
bc01313a04 |
|
@ -1,5 +1,9 @@
|
||||||
*
|
*.swp
|
||||||
!.gitignore
|
go.mod
|
||||||
!Makefile
|
go.sum
|
||||||
!*.go
|
|
||||||
!LICENSE
|
/files/*
|
||||||
|
/*.deb
|
||||||
|
/resources/*
|
||||||
|
|
||||||
|
gadgetwindow
|
||||||
|
|
56
Makefile
56
Makefile
|
@ -1,44 +1,45 @@
|
||||||
|
VERSION = $(shell git describe --tags)
|
||||||
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
reset
|
|
||||||
./gadgetwindow
|
./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
|
nocui: build
|
||||||
reset
|
reset
|
||||||
./gadgetwindow --gui nocui
|
./gadgetwindow --gui nocui
|
||||||
|
|
||||||
gocui: build
|
gocui: build
|
||||||
reset
|
reset
|
||||||
./gadgetwindow --gui gocui >/tmp/gadgetwindow.stderr 2>&1
|
echo "redirecting STDOUT & STDERR to /tmp/gadgetwindow.out"
|
||||||
# ./gadgetwindow --gui gocui --tmp-log
|
./gadgetwindow --gui gocui
|
||||||
|
|
||||||
log:
|
|
||||||
tail -f /tmp/guilogfile /tmp/witgui.* /tmp/gadget*
|
|
||||||
|
|
||||||
test-tmp-log: build
|
|
||||||
./gadgetwindow --gui andlabs --tmp-log
|
|
||||||
|
|
||||||
debugger: build
|
debugger: build
|
||||||
reset
|
reset
|
||||||
./gadgetwindow --debugger
|
./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:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
||||||
|
@ -47,4 +48,3 @@ redomod:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
GO111MODULE= go mod init
|
GO111MODULE= go mod init
|
||||||
GO111MODULE= go mod tidy
|
GO111MODULE= go mod tidy
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# 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
27
args.go
|
@ -1,27 +0,0 @@
|
||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
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
22
main.go
|
@ -1,7 +1,8 @@
|
||||||
// This creates a simple hello world window
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
@ -9,9 +10,15 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// sent via -ldflags
|
||||||
|
var VERSION string
|
||||||
|
|
||||||
// This is the beginning of the binary tree of widgets
|
// This is the beginning of the binary tree of widgets
|
||||||
var myGui *gui.Node
|
var myGui *gui.Node
|
||||||
|
|
||||||
|
//go:embed resources/*
|
||||||
|
var resources embed.FS
|
||||||
|
|
||||||
// this is the primary window. If you close it, the program will exit
|
// this is the primary window. If you close it, the program will exit
|
||||||
var mainWindow *gui.Node
|
var mainWindow *gui.Node
|
||||||
|
|
||||||
|
@ -27,24 +34,13 @@ func main() {
|
||||||
log.SetAll(true)
|
log.SetAll(true)
|
||||||
log.ShowFlags()
|
log.ShowFlags()
|
||||||
}
|
}
|
||||||
if args.TmpLog {
|
|
||||||
// send all log() output to a file in /tmp
|
|
||||||
log.SetTmp()
|
|
||||||
}
|
|
||||||
myGui = gui.New()
|
myGui = gui.New()
|
||||||
|
myGui.InitEmbed(resources)
|
||||||
myGui.Default()
|
myGui.Default()
|
||||||
|
|
||||||
helloworld()
|
helloworld()
|
||||||
basicWindow = makebasicWindow()
|
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
|
// go will sit here until the window exits
|
||||||
gui.Watchdog()
|
gui.Watchdog()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue