Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0cf617ef
Commit
0cf617ef
authored
May 20, 2014
by
Maran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented GUI watchers for rapid reload. Implements #46
parent
0ef7f637
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
3 deletions
+69
-3
ext_app.go
ethereal/ui/ext_app.go
+9
-3
html_container.go
ethereal/ui/html_container.go
+60
-0
No files found.
ethereal/ui/ext_app.go
View file @
0cf617ef
...
...
@@ -18,14 +18,16 @@ type AppContainer interface {
NewBlock
(
*
ethchain
.
Block
)
ObjectChanged
(
*
ethchain
.
StateObject
)
StorageChanged
(
*
ethchain
.
StorageState
)
NewWatcher
(
chan
bool
)
}
type
ExtApplication
struct
{
*
ethpub
.
PEthereum
blockChan
chan
ethutil
.
React
changeChan
chan
ethutil
.
React
quitChan
chan
bool
blockChan
chan
ethutil
.
React
changeChan
chan
ethutil
.
React
quitChan
chan
bool
watcherQuitChan
chan
bool
container
AppContainer
lib
*
UiLib
...
...
@@ -38,6 +40,7 @@ func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
make
(
chan
ethutil
.
React
,
1
),
make
(
chan
ethutil
.
React
,
1
),
make
(
chan
bool
),
make
(
chan
bool
),
container
,
lib
,
nil
,
...
...
@@ -66,6 +69,8 @@ func (app *ExtApplication) run() {
reactor
:=
app
.
lib
.
eth
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
app
.
blockChan
)
app
.
container
.
NewWatcher
(
app
.
watcherQuitChan
)
win
:=
app
.
container
.
Window
()
win
.
Show
()
win
.
Wait
()
...
...
@@ -83,6 +88,7 @@ func (app *ExtApplication) stop() {
// Kill the main loop
app
.
quitChan
<-
true
app
.
watcherQuitChan
<-
true
close
(
app
.
blockChan
)
close
(
app
.
quitChan
)
...
...
ethereal/ui/html_container.go
View file @
0cf617ef
...
...
@@ -6,6 +6,12 @@ import (
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
"github.com/howeyc/fsnotify"
"io/ioutil"
"log"
"net/url"
"os"
"path"
"path/filepath"
)
...
...
@@ -15,6 +21,7 @@ type HtmlApplication struct {
engine
*
qml
.
Engine
lib
*
UiLib
path
string
watcher
*
fsnotify
.
Watcher
}
func
NewHtmlApplication
(
path
string
,
lib
*
UiLib
)
*
HtmlApplication
{
...
...
@@ -47,6 +54,59 @@ func (app *HtmlApplication) Create() error {
return
nil
}
func
(
app
*
HtmlApplication
)
RootFolder
()
string
{
folder
,
err
:=
url
.
Parse
(
app
.
path
)
if
err
!=
nil
{
return
""
}
return
path
.
Dir
(
folder
.
RequestURI
())
}
func
(
app
*
HtmlApplication
)
RecursiveFolders
()
[]
os
.
FileInfo
{
files
,
_
:=
ioutil
.
ReadDir
(
app
.
RootFolder
())
var
folders
[]
os
.
FileInfo
for
_
,
file
:=
range
files
{
if
file
.
IsDir
()
{
folders
=
append
(
folders
,
file
)
}
}
return
folders
}
func
(
app
*
HtmlApplication
)
NewWatcher
(
quitChan
chan
bool
)
{
var
err
error
app
.
watcher
,
err
=
fsnotify
.
NewWatcher
()
if
err
!=
nil
{
return
}
err
=
app
.
watcher
.
Watch
(
app
.
RootFolder
())
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
for
_
,
folder
:=
range
app
.
RecursiveFolders
()
{
fullPath
:=
app
.
RootFolder
()
+
"/"
+
folder
.
Name
()
app
.
watcher
.
Watch
(
fullPath
)
}
go
func
()
{
out
:
for
{
select
{
case
<-
quitChan
:
app
.
watcher
.
Close
()
break
out
case
<-
app
.
watcher
.
Event
:
//ethutil.Config.Log.Debugln("Got event:", ev)
app
.
webView
.
Call
(
"reload"
)
case
err
:=
<-
app
.
watcher
.
Error
:
// TODO: Do something here
ethutil
.
Config
.
Log
.
Infoln
(
"Watcher error:"
,
err
)
}
}
}()
}
func
(
app
*
HtmlApplication
)
Engine
()
*
qml
.
Engine
{
return
app
.
engine
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment