diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-19 19:33:15 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-19 19:34:37 +0800 |
commit | ae1de6593c31fbaa4429588cea2702dd5b01a722 (patch) | |
tree | d19c960d08524f0c5449ba87ab7ef4054b782b32 /mist/qml_container.go | |
parent | 723074e71bbe1638a5cec9b996b1eed07a76fd72 (diff) | |
download | go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar.gz go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar.bz2 go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar.lz go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar.xz go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.tar.zst go-tangerine-ae1de6593c31fbaa4429588cea2702dd5b01a722.zip |
renamed
Diffstat (limited to 'mist/qml_container.go')
-rw-r--r-- | mist/qml_container.go | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/mist/qml_container.go b/mist/qml_container.go new file mode 100644 index 000000000..85bd7c699 --- /dev/null +++ b/mist/qml_container.go @@ -0,0 +1,68 @@ +package main + +import ( + "fmt" + "runtime" + + "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethpipe" + "github.com/ethereum/eth-go/ethstate" + "github.com/ethereum/eth-go/ethutil" + "gopkg.in/qml.v1" +) + +type QmlApplication struct { + win *qml.Window + engine *qml.Engine + lib *UiLib + path string +} + +func NewQmlApplication(path string, lib *UiLib) *QmlApplication { + engine := qml.NewEngine() + return &QmlApplication{engine: engine, path: path, lib: lib} +} + +func (app *QmlApplication) Create() error { + path := string(app.path) + + // For some reason for windows we get /c:/path/to/something, windows doesn't like the first slash but is fine with the others so we are removing it + if app.path[0] == '/' && runtime.GOOS == "windows" { + path = app.path[1:] + } + + component, err := app.engine.LoadFile(path) + if err != nil { + logger.Warnln(err) + } + app.win = component.CreateWindow(nil) + + return nil +} + +func (app *QmlApplication) Destroy() { + app.engine.Destroy() +} + +func (app *QmlApplication) NewWatcher(quitChan chan bool) { +} + +// Events +func (app *QmlApplication) NewBlock(block *ethchain.Block) { + pblock := ðpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())} + app.win.Call("onNewBlockCb", pblock) +} + +func (self *QmlApplication) Messages(msgs ethstate.Messages, id string) { + fmt.Println("IMPLEMENT QML APPLICATION MESSAGES METHOD") +} + +// Getters +func (app *QmlApplication) Engine() *qml.Engine { + return app.engine +} +func (app *QmlApplication) Window() *qml.Window { + return app.win +} + +func (app *QmlApplication) Post(data string, s int) {} |