diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-27 22:24:56 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-27 22:24:56 +0800 |
commit | 1257e8b4b30293784d24011ab6f9d8b4498ecfa4 (patch) | |
tree | 779f8dd12e7a58b2025d5d55431fdccf966756db | |
parent | e65c4ee93e9dad629997c7839df7a8a0e7cff353 (diff) | |
parent | 1323f60c074297c97397d20dd275124da2f5b531 (diff) | |
download | go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar.gz go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar.bz2 go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar.lz go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar.xz go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.tar.zst go-tangerine-1257e8b4b30293784d24011ab6f9d8b4498ecfa4.zip |
Merge branch 'master' into develop
-rw-r--r-- | ethereal/config.go | 2 | ||||
-rw-r--r-- | ethereal/ethereum.go | 4 | ||||
-rw-r--r-- | ethereal/ui/gui.go | 11 | ||||
-rw-r--r-- | ethereal/ui/ui_lib.go | 14 |
4 files changed, 22 insertions, 9 deletions
diff --git a/ethereal/config.go b/ethereal/config.go index a534bb182..ac4484d0b 100644 --- a/ethereal/config.go +++ b/ethereal/config.go @@ -16,6 +16,7 @@ var UseSeed bool var ImportKey string var ExportKey bool var DataDir string +var AssetPath string func Init() { flag.BoolVar(&StartConsole, "c", false, "debug and testing console") @@ -29,6 +30,7 @@ func Init() { flag.StringVar(&DataDir, "dir", ".ethereal", "ethereum data directory") flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)") flag.IntVar(&MaxPeer, "x", 5, "maximum desired peers") + flag.StringVar(&AssetPath, "asset_path", "", "absolute path to GUI assets directory") flag.Parse() } diff --git a/ethereal/ethereum.go b/ethereal/ethereum.go index 618d2b00f..99f3b0b52 100644 --- a/ethereal/ethereum.go +++ b/ethereal/ethereum.go @@ -100,11 +100,11 @@ func main() { os.Exit(0) } - log.Printf("Starting Ethereum v%s\n", ethutil.Config.Ver) + log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver) // Set the max peers ethereum.MaxPeers = MaxPeer gui := ethui.New(ethereum) - gui.Start() + gui.Start(AssetPath) } diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index c8f4bedab..89736ac29 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -53,6 +53,7 @@ type Gui struct { txDb *ethdb.LDBDatabase addr []byte + } // Create GUI, but doesn't start it @@ -71,7 +72,7 @@ func New(ethereum *eth.Ethereum) *Gui { return &Gui{eth: ethereum, lib: lib, txDb: db, addr: addr} } -func (ui *Gui) Start() { +func (ui *Gui) Start(assetPath string) { defer ui.txDb.Close() // Register ethereum functions @@ -89,14 +90,16 @@ func (ui *Gui) Start() { // Expose the eth library and the ui library to QML context.SetVar("eth", ui.lib) - context.SetVar("ui", &UiLib{engine: ui.engine, eth: ui.eth}) + uiLib := NewUiLib(ui.engine, ui.eth, assetPath) + context.SetVar("ui", uiLib) // Load the main QML interface - component, err := ui.engine.LoadFile(AssetPath("qml/wallet.qml")) + component, err := ui.engine.LoadFile(uiLib.AssetPath("qml/wallet.qml")) if err != nil { + ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'") panic(err) } - ui.engine.LoadFile(AssetPath("qml/transactions.qml")) + ui.engine.LoadFile(uiLib.AssetPath("qml/transactions.qml")) ui.win = component.CreateWindow(nil) diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go index 3997191fa..4441a7238 100644 --- a/ethereal/ui/ui_lib.go +++ b/ethereal/ui/ui_lib.go @@ -16,6 +16,14 @@ type UiLib struct { engine *qml.Engine eth *eth.Ethereum connected bool + assetPath string +} + +func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib { + if assetPath == "" { + assetPath = DefaultAssetPath() + } + return &UiLib{engine: engine, eth: eth, assetPath: assetPath} } // Opens a QML file (external application) @@ -45,10 +53,10 @@ func (ui *UiLib) ConnectToPeer(addr string) { } func (ui *UiLib) AssetPath(p string) string { - return AssetPath(p) + return path.Join(ui.assetPath, p) } -func AssetPath(p string) string { +func DefaultAssetPath() string { var base string // If the current working directory is the go-ethereum dir @@ -72,5 +80,5 @@ func AssetPath(p string) string { } } - return path.Join(base, p) + return base } |