aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui/html_container.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-05 21:56:05 +0800
committerobscuren <geffobscura@gmail.com>2014-05-05 21:56:05 +0800
commita77dcd10414e94fbd255931b0a539bbfefd91f56 (patch)
tree5c804987152d89c4915a433bb79fcb7b95c6364c /ethereal/ui/html_container.go
parent1323f60c074297c97397d20dd275124da2f5b531 (diff)
parent70221c36e381e98bf3e92913f48fb94d18da8ef5 (diff)
downloadgo-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar.gz
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar.bz2
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar.lz
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar.xz
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.tar.zst
go-tangerine-fa3703ee8ac138165c08ee40929220c30baf794b.zip
Merge branch 'release/poc5-rc1'poc5-rc1
Diffstat (limited to 'ethereal/ui/html_container.go')
-rw-r--r--ethereal/ui/html_container.go73
1 files changed, 73 insertions, 0 deletions
diff --git a/ethereal/ui/html_container.go b/ethereal/ui/html_container.go
new file mode 100644
index 000000000..4f12aaaf6
--- /dev/null
+++ b/ethereal/ui/html_container.go
@@ -0,0 +1,73 @@
+package ethui
+
+import (
+ "errors"
+ "github.com/ethereum/eth-go/ethchain"
+ "github.com/ethereum/eth-go/ethpub"
+ "github.com/ethereum/eth-go/ethutil"
+ "github.com/go-qml/qml"
+ "path/filepath"
+)
+
+type HtmlApplication struct {
+ win *qml.Window
+ webView qml.Object
+ engine *qml.Engine
+ lib *UiLib
+ path string
+}
+
+func NewHtmlApplication(path string, lib *UiLib) *HtmlApplication {
+ engine := qml.NewEngine()
+
+ return &HtmlApplication{engine: engine, lib: lib, path: path}
+
+}
+
+func (app *HtmlApplication) Create() error {
+ component, err := app.engine.LoadFile(app.lib.AssetPath("qml/webapp.qml"))
+ if err != nil {
+ return err
+ }
+
+ if filepath.Ext(app.path) == "eth" {
+ return errors.New("Ethereum package not yet supported")
+
+ // TODO
+ ethutil.OpenPackage(app.path)
+ }
+
+ win := component.CreateWindow(nil)
+ win.Set("url", app.path)
+ webView := win.ObjectByName("webView")
+
+ app.win = win
+ app.webView = webView
+
+ return nil
+}
+
+func (app *HtmlApplication) Engine() *qml.Engine {
+ return app.engine
+}
+
+func (app *HtmlApplication) Window() *qml.Window {
+ return app.win
+}
+
+func (app *HtmlApplication) NewBlock(block *ethchain.Block) {
+ b := &ethpub.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
+ app.webView.Call("onNewBlockCb", b)
+}
+
+func (app *HtmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
+ app.webView.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
+}
+
+func (app *HtmlApplication) StorageChanged(storageObject *ethchain.StorageState) {
+ app.webView.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
+}
+
+func (app *HtmlApplication) Destroy() {
+ app.engine.Destroy()
+}