diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-28 19:20:47 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-28 19:20:47 +0800 |
commit | 0adfa489de3fb88c995246d0b70af8bbd06f8db7 (patch) | |
tree | af34f0c678fc75dda0d186285240beef9aa5b42c /ui/ui_lib.go | |
parent | 6db8b5d06a41ef573ec43394a11fd0e668372860 (diff) | |
parent | 560a7073f457a32c9d053f1a4b20f76d949f519d (diff) | |
download | dexon-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.go | 40 |
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) +} |