diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-30 07:44:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-30 07:44:02 +0800 |
commit | 64c2550b3154df7f2c75dda559d91046cb559ffd (patch) | |
tree | 4dfbaeac371c73b3518566bb0c2e2a141b7d4b49 /ethereal/ui/ui_lib.go | |
parent | 922974c760278b6d49cb6f286b663d60f77d5248 (diff) | |
download | go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.gz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.bz2 go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.lz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.xz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.zst go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.zip |
Split off External applications from main library
External applications now accept containers which function as the
frontend where the ExtApplication functions as the backend. Containers
execute within their own engine and have their own context and are
destroyed when released.
Diffstat (limited to 'ethereal/ui/ui_lib.go')
-rw-r--r-- | ethereal/ui/ui_lib.go | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go index 07cd0ac8a..0feb522bc 100644 --- a/ethereal/ui/ui_lib.go +++ b/ethereal/ui/ui_lib.go @@ -6,9 +6,9 @@ import ( "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" - "github.com/obscuren/mutan" "github.com/ethereum/go-ethereum/utils" "github.com/go-qml/qml" + "github.com/obscuren/mutan" "os" "path" "path/filepath" @@ -53,60 +53,18 @@ func (ui *UiLib) Open(path string) { } func (ui *UiLib) OpenHtml(path string) { - component, err := ui.engine.LoadFile(ui.AssetPath("qml/webapp.qml")) - if err != nil { - ethutil.Config.Log.Debugln(err) + container := NewHtmlApplication(path, ui) + app := NewExtApplication(container, ui) - return - } - win := component.CreateWindow(nil) - if filepath.Ext(path) == "eth" { - fmt.Println("Ethereum package not yet supported") - - return + go app.run() +} - // TODO - ethutil.OpenPackage(path) +func (ui *UiLib) Watch(addr, storageAddr string) { + if len(storageAddr) == 0 { + ui.eth.Reactor().Subscribe("storage:"+string(ethutil.FromHex(addr))+":"+string(ethutil.FromHex(storageAddr)), nil) + } else { + ui.eth.Reactor().Subscribe("object:"+string(ethutil.FromHex(addr)), nil) } - win.Set("url", path) - - webView := win.ObjectByName("webView") - go func() { - blockChan := make(chan ethutil.React, 1) - addrChan := make(chan ethutil.React, 1) - quitChan := make(chan bool) - - go func() { - out: - for { - select { - case <-quitChan: - ui.eth.Reactor().Unsubscribe("newBlock", blockChan) - break out - case block := <-blockChan: - if block, ok := block.Resource.(*ethchain.Block); ok { - b := &QBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())} - webView.Call("onNewBlockCb", b) - } - case stateObject := <-addrChan: - if stateObject, ok := stateObject.Resource.(*ethchain.StateObject); ok { - webView.Call("onObjectChangeCb", NewQStateObject(stateObject)) - } - } - } - - // Clean up - close(blockChan) - close(quitChan) - }() - ui.eth.Reactor().Subscribe("newBlock", blockChan) - ui.eth.Reactor().Subscribe("addressChanged", addrChan) - - win.Show() - win.Wait() - - quitChan <- true - }() } func (ui *UiLib) Muted(content string) { |