commit ba6e9417ed959587368a82d046080ff349472794
parent eda56723440bab66f4f0be1611c9bbf1db88ed16
Author: Amir Taaki <genjix@riseup.net>
Date: Fri, 29 Jun 2012 07:26:52 +0200
spawn both guis at start. clicking expand hides the simple one, shows the expert one.
Diffstat:
4 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/lib/gui_lite.py b/lib/gui_lite.py
@@ -35,19 +35,18 @@ class ElectrumGui:
actuator = MiniActuator(self.wallet)
self.mini = MiniWindow(actuator, self.expand)
driver = MiniDriver(self.wallet, self.mini)
- self.app.exec_()
+
+ timer = Timer()
+ timer.start()
+ self.expert = gui_qt.ElectrumWindow(self.wallet)
+ self.expert.connect_slots(timer)
+ self.expert.update_wallet()
+
+ sys.exit(self.app.exec_())
def expand(self):
self.mini.hide()
- self.actuator = None
- self.mini = None
- self.driver = None
- self.wallet.gui_callback = None
- self.timer = Timer()
- self.timer.start()
- self.gui = gui_qt.ElectrumWindow(self.wallet)
- self.gui.connect_slots(self.timer)
- self.gui.update_wallet()
+ self.expert.show()
class MiniWindow(QDialog):
@@ -306,7 +305,7 @@ class MiniDriver(QObject):
self.wallet = wallet
self.window = window
- self.wallet.gui_callback = self.update_callback
+ self.wallet.register_callback(self.update_callback)
self.state = None
diff --git a/lib/gui_qt.py b/lib/gui_qt.py
@@ -187,7 +187,7 @@ class ElectrumWindow(QMainWindow):
def __init__(self, wallet):
QMainWindow.__init__(self)
self.wallet = wallet
- self.wallet.gui_callback = self.update_callback
+ self.wallet.register_callback(self.update_callback)
self.funds_error = False
self.completions = QStringListModel()
@@ -207,7 +207,6 @@ class ElectrumWindow(QMainWindow):
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.wallet.path
if not self.wallet.seed: title += ' [seedless]'
self.setWindowTitle( title )
- self.show()
QShortcut(QKeySequence("Ctrl+W"), self, self.close)
QShortcut(QKeySequence("Ctrl+Q"), self, self.close)
@@ -1490,5 +1489,6 @@ class ElectrumGui():
w.app = self.app
w.connect_slots(s)
w.update_wallet()
+ w.show()
self.app.exec_()
diff --git a/lib/interface.py b/lib/interface.py
@@ -406,13 +406,13 @@ class WalletSynchronizer(threading.Thread):
self.wallet.was_updated = True
if self.wallet.was_updated:
- self.wallet.gui_callback()
+ self.wallet.trigger_callbacks()
self.wallet.was_updated = False
response = self.interface.responses.get()
self.handle_response(response)
- self.wallet.gui_callback()
+ self.wallet.trigger_callbacks()
if self.loop:
time.sleep(5)
self.init_interface()
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -249,11 +249,11 @@ from interface import DEFAULT_SERVERS
class Wallet:
- def __init__(self, gui_callback = lambda: None):
+ def __init__(self):
self.electrum_version = ELECTRUM_VERSION
self.seed_version = SEED_VERSION
- self.gui_callback = gui_callback
+ self.update_callbacks = []
self.gap_limit = 5 # configuration
self.use_change = True
@@ -299,7 +299,14 @@ class Wallet:
self.pick_random_server()
+ def register_callback(self, update_callback):
+ with self.lock:
+ self.update_callbacks.append(update_callback)
+ def trigger_callbacks(self):
+ with self.lock:
+ callbacks = self.update_callbacks[:]
+ [update() for update in callbacks]
def pick_random_server(self):
self.server = random.choice( DEFAULT_SERVERS ) # random choice when the wallet is created