aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui/html_container.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-30 07:44:02 +0800
committerobscuren <geffobscura@gmail.com>2014-04-30 07:44:02 +0800
commit64c2550b3154df7f2c75dda559d91046cb559ffd (patch)
tree4dfbaeac371c73b3518566bb0c2e2a141b7d4b49 /ethereal/ui/html_container.go
parent922974c760278b6d49cb6f286b663d60f77d5248 (diff)
downloaddexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar
dexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.gz
dexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.bz2
dexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.lz
dexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.xz
dexon-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.zst
dexon-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/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..8e3ef0fc7
--- /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/ethutil"
+ "github.com/go-qml/qml"
+ "math/big"
+ "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 := &QBlock{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", NewQStateObject(stateObject))
+}
+
+func (app *HtmlApplication) StorageChanged(stateObject *ethchain.StateObject, addr []byte, value *big.Int) {
+ app.webView.Call("onStorageChangeCb", nil)
+}
+
+func (app *HtmlApplication) Destroy() {
+ app.engine.Destroy()
+}