aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui_lib.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-28 19:20:47 +0800
committerobscuren <geffobscura@gmail.com>2014-02-28 19:20:47 +0800
commit0adfa489de3fb88c995246d0b70af8bbd06f8db7 (patch)
treeaf34f0c678fc75dda0d186285240beef9aa5b42c /ui/ui_lib.go
parent6db8b5d06a41ef573ec43394a11fd0e668372860 (diff)
parent560a7073f457a32c9d053f1a4b20f76d949f519d (diff)
downloaddexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar.gz
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar.bz2
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar.lz
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar.xz
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.tar.zst
dexon-0adfa489de3fb88c995246d0b70af8bbd06f8db7.zip
Merge branch 'release/0.3.0'
Diffstat (limited to 'ui/ui_lib.go')
-rw-r--r--ui/ui_lib.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/ui/ui_lib.go b/ui/ui_lib.go
new file mode 100644
index 000000000..c956fd032
--- /dev/null
+++ b/ui/ui_lib.go
@@ -0,0 +1,40 @@
+package ethui
+
+import (
+ "github.com/ethereum/eth-go"
+ "github.com/ethereum/eth-go/ethutil"
+ "github.com/niemeyer/qml"
+)
+
+// UI Library that has some basic functionality exposed
+type UiLib struct {
+ engine *qml.Engine
+ eth *eth.Ethereum
+ connected bool
+}
+
+// Opens a QML file (external application)
+func (ui *UiLib) Open(path string) {
+ component, err := ui.engine.LoadFile(path[7:])
+ if err != nil {
+ ethutil.Config.Log.Debugln(err)
+ }
+ win := component.CreateWindow(nil)
+
+ go func() {
+ win.Show()
+ win.Wait()
+ }()
+}
+
+func (ui *UiLib) Connect(button qml.Object) {
+ if !ui.connected {
+ ui.eth.Start()
+ ui.connected = true
+ button.Set("enabled", false)
+ }
+}
+
+func (ui *UiLib) ConnectToPeer(addr string) {
+ ui.eth.ConnectToPeer(addr)
+}