summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore14
-rw-r--r--Makefile27
-rw-r--r--README.md6
-rw-r--r--argv.go38
-rw-r--r--debugger.go6
-rw-r--r--main.go10
-rw-r--r--resources/blank.so0
7 files changed, 77 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 1cc9f33..736c3d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
-*
-!.gitignore
-!Makefile
-!*.go
-!LICENSE
+*.swp
+go.mod
+go.sum
+
+/files/*
+/*.deb
+/resources/*
+
+gadgetwindow
diff --git a/Makefile b/Makefile
index 5527cb2..d7fe64f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,19 @@
+VERSION = $(shell git describe --tags)
+
all: build
- reset
+ ./gadgetwindow
+
+build:
+ -rm -f gadgetwindow
+ -rm resources/*.so
+ touch resources/blank.so
+ -cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ # embed the toolkit plugins in the binary
+ GO111MODULE=off go build -v -x \
+ -ldflags "-X main.VERSION=${VERSION}"
+
+install:
+ GO111MODULE=off go install -v -x \
+ -ldflags "-X main.VERSION=${VERSION}"
./gadgetwindow
nocui: build
@@ -18,17 +32,6 @@ debugger: build
reset
./gadgetwindow --debugger
-build:
-ifeq ($(GO111MODULE),)
- @echo
- @echo In GO, to build here you must export GO111MODULE=off
- @echo
- @false
-else
- -rm -f gadgetwindow
- go build -v -x
-endif
-
goimports:
goimports -w *.go
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..600fd6a
--- /dev/null
+++ b/README.md
@@ -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
diff --git a/argv.go b/argv.go
new file mode 100644
index 0000000..44b5b55
--- /dev/null
+++ b/argv.go
@@ -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
+}
diff --git a/debugger.go b/debugger.go
index 116d549..f7a6aca 100644
--- a/debugger.go
+++ b/debugger.go
@@ -5,17 +5,11 @@ package main
*/
import (
- "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
-var args struct {
-}
-
func init() {
- arg.MustParse(&args)
-
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
diff --git a/main.go b/main.go
index 2204571..df6c40f 100644
--- a/main.go
+++ b/main.go
@@ -1,7 +1,8 @@
-// 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"
@@ -9,9 +10,15 @@ 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
@@ -28,6 +35,7 @@ func main() {
log.ShowFlags()
}
myGui = gui.New()
+ myGui.InitEmbed(resources)
myGui.Default()
helloworld()
diff --git a/resources/blank.so b/resources/blank.so
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/resources/blank.so