aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-22 08:52:47 +0800
committerobscuren <geffobscura@gmail.com>2014-02-22 08:52:47 +0800
commit2b967558cebcef9d3ef9719cbb28a5e596982a5d (patch)
treee0b45a4d2123c70a9f6216ffb0a493018b06154c /ui
parent3e8b27c9dc78ffeeefae987e67730fae17707df4 (diff)
downloaddexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar.gz
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar.bz2
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar.lz
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar.xz
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.tar.zst
dexon-2b967558cebcef9d3ef9719cbb28a5e596982a5d.zip
Working out UI
Diffstat (limited to 'ui')
-rw-r--r--ui/gui.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/ui/gui.go b/ui/gui.go
index 8f063843c..fad7e9591 100644
--- a/ui/gui.go
+++ b/ui/gui.go
@@ -56,10 +56,12 @@ func (ui *Gui) Start() {
context := ui.engine.Context()
context.SetVar("eth", ui.lib)
- context.SetVar("ui", &UiLib{engine: ui.engine})
+ context.SetVar("ui", &UiLib{engine: ui.engine, eth: ui.eth})
ui.eth.BlockManager.SecondaryBlockProcessor = ui
+ ethutil.Config.Log.AddLogSystem(ui)
+
go ui.setInitialBlockChain()
go ui.updatePeers()
@@ -73,13 +75,23 @@ func (ui *Gui) setInitialBlockChain() {
ui.ProcessBlock(block)
}
- ui.eth.Start()
}
func (ui *Gui) ProcessBlock(block *ethchain.Block) {
ui.win.Root().Call("addBlock", NewBlockFromBlock(block))
}
+func (ui *Gui) Println(v ...interface{}) {
+ str := fmt.Sprintln(v...)
+ // remove last \n
+ ui.win.Root().Call("addLog", str[:len(str)-1])
+}
+
+func (ui *Gui) Printf(format string, v ...interface{}) {
+ str := strings.TrimRight(fmt.Sprintf(format, v...), "\n")
+ ui.win.Root().Call("addLog", str)
+}
+
func (ui *Gui) updatePeers() {
for {
ui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", ui.eth.Peers().Len(), ui.eth.MaxPeers))
@@ -89,6 +101,7 @@ func (ui *Gui) updatePeers() {
type UiLib struct {
engine *qml.Engine
+ eth *eth.Ethereum
}
func (ui *UiLib) Open(path string) {
@@ -104,6 +117,10 @@ func (ui *UiLib) Open(path string) {
}()
}
+func (ui *UiLib) Connect() {
+ ui.eth.Start()
+}
+
type Tester struct {
root qml.Object
}