aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/gui.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-12 17:02:33 +0800
committerobscuren <geffobscura@gmail.com>2014-08-12 17:02:33 +0800
commitac14f002e6d861ed646fdcc2febb35b2a3ca57aa (patch)
tree064eb84c3796cc124291130e912689052e2297f4 /ethereal/gui.go
parentc59d7a899b0ca121b3f982fa12405629109f1b47 (diff)
downloadgo-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar.gz
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar.bz2
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar.lz
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar.xz
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.tar.zst
go-tangerine-ac14f002e6d861ed646fdcc2febb35b2a3ca57aa.zip
Refactored GUI and added modular/pluginable side bar
Diffstat (limited to 'ethereal/gui.go')
-rw-r--r--ethereal/gui.go42
1 files changed, 28 insertions, 14 deletions
diff --git a/ethereal/gui.go b/ethereal/gui.go
index d2363b5a9..d8ab50ac6 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -31,6 +31,7 @@ type Gui struct {
// QML Engine
engine *qml.Engine
component *qml.Common
+ qmlDone bool
// The ethereum interface
eth *eth.Ethereum
@@ -150,18 +151,16 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
return nil, err
}
- win := gui.createWindow(component)
-
- go func() {
- go gui.setInitialBlockChain()
- gui.loadAddressBook()
- gui.setPeerInfo()
- gui.readPreviousTransactions()
- }()
+ gui.win = gui.createWindow(component)
gui.update()
- return win, nil
+ return gui.win, nil
+}
+
+// The done handler will be called by QML when all views have been loaded
+func (gui *Gui) Done() {
+ gui.qmlDone = true
}
func (gui *Gui) ImportKey(filePath string) {
@@ -230,14 +229,16 @@ type address struct {
}
func (gui *Gui) loadAddressBook() {
- gui.win.Root().Call("clearAddress")
+ view := gui.getObjectByName("infoView")
+ view.Call("clearAddress")
nameReg := ethpub.EthereumConfig(gui.eth.StateManager()).NameReg()
if nameReg != nil {
nameReg.EachStorage(func(name string, value *ethutil.Value) {
if name[0] != 0 {
value.Decode()
- gui.win.Root().Call("addAddress", struct{ Name, Address string }{name, ethutil.Bytes2Hex(value.Bytes())})
+
+ view.Call("addAddress", struct{ Name, Address string }{name, ethutil.Bytes2Hex(value.Bytes())})
}
})
}
@@ -282,7 +283,7 @@ func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
ptx.Sender = s
ptx.Address = r
- gui.win.Root().Call("addTx", window, ptx, inout)
+ gui.getObjectByName("transactionView").Call("addTx", window, ptx, inout)
}
func (gui *Gui) readPreviousTransactions() {
@@ -301,7 +302,7 @@ func (gui *Gui) processBlock(block *ethchain.Block, initial bool) {
b := ethpub.NewPBlock(block)
b.Name = name
- gui.win.Root().Call("addBlock", b, initial)
+ gui.getObjectByName("chainView").Call("addBlock", b, initial)
}
func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
@@ -326,6 +327,17 @@ func (self *Gui) getObjectByName(objectName string) qml.Object {
// Simple go routine function that updates the list of peers in the GUI
func (gui *Gui) update() {
+ // We have to wait for qml to be done loading all the windows.
+ for !gui.qmlDone {
+ time.Sleep(500 * time.Millisecond)
+ }
+
+ go func() {
+ go gui.setInitialBlockChain()
+ gui.loadAddressBook()
+ gui.setPeerInfo()
+ gui.readPreviousTransactions()
+ }()
var (
blockChan = make(chan ethreact.Event, 100)
@@ -514,7 +526,9 @@ func (gui *Gui) Printf(format string, v ...interface{}) {
func (gui *Gui) printLog(s string) {
str := strings.TrimRight(s, "\n")
lines := strings.Split(str, "\n")
+
+ view := gui.getObjectByName("infoView")
for _, line := range lines {
- gui.win.Root().Call("addLog", line)
+ view.Call("addLog", line)
}
}