Get URIs working properly for multiple windows
This commit is contained in:
parent
4655c5f565
commit
27917af2bf
13
electrum
13
electrum
|
@ -20,7 +20,6 @@
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -298,7 +297,7 @@ class ClientThread(util.DaemonThread):
|
||||||
if self.server.gui:
|
if self.server.gui:
|
||||||
if hasattr(server.gui, 'new_window'):
|
if hasattr(server.gui, 'new_window'):
|
||||||
path = config.get_wallet_path()
|
path = config.get_wallet_path()
|
||||||
self.server.gui.new_window(path)
|
self.server.gui.new_window(path, config.get('url'))
|
||||||
response = "ok"
|
response = "ok"
|
||||||
else:
|
else:
|
||||||
response = "error: current GUI does not support multiple windows"
|
response = "error: current GUI does not support multiple windows"
|
||||||
|
@ -482,16 +481,6 @@ if __name__ == '__main__':
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
cmd_name = config.get('cmd')
|
cmd_name = config.get('cmd')
|
||||||
|
|
||||||
# check url
|
|
||||||
url = config.get('url')
|
|
||||||
if url:
|
|
||||||
if os.path.exists(url):
|
|
||||||
# assume this is a payment request
|
|
||||||
url = "bitcoin:?r=file://"+ os.path.join(os.getcwd(), url)
|
|
||||||
if not re.match('^bitcoin:', url):
|
|
||||||
print_stderr('unknown command:', url)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# initialize plugins.
|
# initialize plugins.
|
||||||
plugins = None
|
plugins = None
|
||||||
if not is_android:
|
if not is_android:
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os
|
||||||
|
import re
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -199,13 +200,13 @@ class ElectrumGui:
|
||||||
return
|
return
|
||||||
wallet = wizard.run(action, wallet_type)
|
wallet = wizard.run(action, wallet_type)
|
||||||
if wallet:
|
if wallet:
|
||||||
self.start_new_window(full_path)
|
self.start_new_window(full_path, None)
|
||||||
|
|
||||||
def new_window(self, path):
|
def new_window(self, path, uri):
|
||||||
# Use a signal as can be called from daemon thread
|
# Use a signal as can be called from daemon thread
|
||||||
self.app.emit(SIGNAL('new_window'), path)
|
self.app.emit(SIGNAL('new_window'), path, uri)
|
||||||
|
|
||||||
def start_new_window(self, path):
|
def start_new_window(self, path, uri):
|
||||||
for w in self.windows:
|
for w in self.windows:
|
||||||
if w.wallet.storage.path == path:
|
if w.wallet.storage.path == path:
|
||||||
w.bring_to_top()
|
w.bring_to_top()
|
||||||
|
@ -228,9 +229,17 @@ class ElectrumGui:
|
||||||
self.windows.append(w)
|
self.windows.append(w)
|
||||||
self.build_tray_menu()
|
self.build_tray_menu()
|
||||||
|
|
||||||
url = self.config.get('url')
|
if uri:
|
||||||
if url:
|
print "URI: ", uri
|
||||||
w.pay_to_URI(url)
|
if os.path.exists(uri):
|
||||||
|
# assume this is a payment request
|
||||||
|
uri = "bitcoin:?r=file://"+ os.path.join(os.getcwd(), uri)
|
||||||
|
if re.match('^bitcoin:', uri):
|
||||||
|
w.pay_to_URI(uri)
|
||||||
|
else:
|
||||||
|
QMessageBox.critical(None, "Error",
|
||||||
|
_("bad bitcoin URI: %s") % uri)
|
||||||
|
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def close_window(self, window):
|
def close_window(self, window):
|
||||||
|
@ -246,7 +255,8 @@ class ElectrumGui:
|
||||||
self.config.cmdline_options['default_wallet_path'] = last_wallet
|
self.config.cmdline_options['default_wallet_path'] = last_wallet
|
||||||
|
|
||||||
# main window
|
# main window
|
||||||
self.main_window = self.start_new_window(self.config.get_wallet_path())
|
self.main_window = self.start_new_window(self.config.get_wallet_path(),
|
||||||
|
self.config.get('url'))
|
||||||
if not self.main_window:
|
if not self.main_window:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue