From 64c2550b3154df7f2c75dda559d91046cb559ffd Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 30 Apr 2014 01:44:02 +0200 Subject: 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. --- ethereal/ui/html_container.go | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 ethereal/ui/html_container.go (limited to 'ethereal/ui/html_container.go') 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() +} -- cgit v1.2.3 From 5a692b9f2bf265251b6f1faf171f55489b65b3de Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 2 May 2014 12:08:15 +0200 Subject: Moved API --- ethereal/ui/html_container.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ethereal/ui/html_container.go') diff --git a/ethereal/ui/html_container.go b/ethereal/ui/html_container.go index 8e3ef0fc7..16cc531f2 100644 --- a/ethereal/ui/html_container.go +++ b/ethereal/ui/html_container.go @@ -4,6 +4,7 @@ import ( "errors" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" + "github.com/ethereum/go-ethereum/utils" "github.com/go-qml/qml" "math/big" "path/filepath" @@ -56,12 +57,12 @@ func (app *HtmlApplication) Window() *qml.Window { } func (app *HtmlApplication) NewBlock(block *ethchain.Block) { - b := &QBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())} + b := &utils.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", NewQStateObject(stateObject)) + app.webView.Call("onObjectChangeCb", utils.NewPStateObject(stateObject)) } func (app *HtmlApplication) StorageChanged(stateObject *ethchain.StateObject, addr []byte, value *big.Int) { -- cgit v1.2.3 From ed64434dcc10347ad9846182ece2d71238138de9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 2 May 2014 13:55:58 +0200 Subject: Moved public interface --- ethereal/ui/html_container.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ethereal/ui/html_container.go') diff --git a/ethereal/ui/html_container.go b/ethereal/ui/html_container.go index 16cc531f2..e3e48bfcc 100644 --- a/ethereal/ui/html_container.go +++ b/ethereal/ui/html_container.go @@ -3,8 +3,8 @@ package ethui import ( "errors" "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethutil" - "github.com/ethereum/go-ethereum/utils" "github.com/go-qml/qml" "math/big" "path/filepath" @@ -57,12 +57,12 @@ func (app *HtmlApplication) Window() *qml.Window { } func (app *HtmlApplication) NewBlock(block *ethchain.Block) { - b := &utils.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())} + b := ðpub.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", utils.NewPStateObject(stateObject)) + app.webView.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject)) } func (app *HtmlApplication) StorageChanged(stateObject *ethchain.StateObject, addr []byte, value *big.Int) { -- cgit v1.2.3 From dd45197bcd174e16adc3b738bf390cc3018a5a28 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 5 May 2014 11:56:05 +0200 Subject: Added storage watch --- ethereal/ui/html_container.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ethereal/ui/html_container.go') diff --git a/ethereal/ui/html_container.go b/ethereal/ui/html_container.go index e3e48bfcc..4f12aaaf6 100644 --- a/ethereal/ui/html_container.go +++ b/ethereal/ui/html_container.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethutil" "github.com/go-qml/qml" - "math/big" "path/filepath" ) @@ -65,8 +64,8 @@ func (app *HtmlApplication) ObjectChanged(stateObject *ethchain.StateObject) { app.webView.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject)) } -func (app *HtmlApplication) StorageChanged(stateObject *ethchain.StateObject, addr []byte, value *big.Int) { - app.webView.Call("onStorageChangeCb", nil) +func (app *HtmlApplication) StorageChanged(storageObject *ethchain.StorageState) { + app.webView.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject)) } func (app *HtmlApplication) Destroy() { -- cgit v1.2.3