|
|
@ -160,12 +160,10 @@ class ElectrumWindow(QMainWindow, PrintError): |
|
|
|
|
|
|
|
# network callbacks |
|
|
|
if self.network: |
|
|
|
self.network.register_callback('updated', lambda: self.need_update.set()) |
|
|
|
self.network.register_callback('new_transaction', self.new_transaction) |
|
|
|
self.register_callback('status', self.update_status) |
|
|
|
self.register_callback('banner', self.console.showMessage) |
|
|
|
self.register_callback('verified', self.history_list.update_item) |
|
|
|
|
|
|
|
self.connect(self, QtCore.SIGNAL('network'), self.on_network_qt) |
|
|
|
interests = ['updated', 'new_transaction', 'status', |
|
|
|
'banner', 'verified'] |
|
|
|
self.network.register_callback(self.on_network, interests) |
|
|
|
# set initial message |
|
|
|
self.console.showMessage(self.network.banner) |
|
|
|
|
|
|
@ -194,11 +192,27 @@ class ElectrumWindow(QMainWindow, PrintError): |
|
|
|
self.show() |
|
|
|
self.raise_() |
|
|
|
|
|
|
|
def register_callback(self, name, method): |
|
|
|
""" run callback in the qt thread """ |
|
|
|
self.connect(self, QtCore.SIGNAL(name), method) |
|
|
|
self.network.register_callback(name, lambda *params: self.emit(QtCore.SIGNAL(name), *params)) |
|
|
|
def on_network(self, event, *args): |
|
|
|
if event == 'updated': |
|
|
|
self.need_update.set() |
|
|
|
elif event == 'new_transaction': |
|
|
|
self.tx_notifications.append(args[0]) |
|
|
|
elif event in ['status', 'banner', 'verified']: |
|
|
|
# Handle in GUI thread |
|
|
|
self.emit(QtCore.SIGNAL('network'), event, *args) |
|
|
|
else: |
|
|
|
self.print_error("unexpected network message:", event, args) |
|
|
|
|
|
|
|
def on_network_qt(self, event, *args): |
|
|
|
# Handle a network message in the GUI thread |
|
|
|
if event == 'status': |
|
|
|
self.update_status() |
|
|
|
elif event == 'banner': |
|
|
|
self.console.showMessage(args[0]) |
|
|
|
elif event == 'verified': |
|
|
|
self.history_list.update_item(*args) |
|
|
|
else: |
|
|
|
self.print_error("unexpected network_qt signal:", event, args) |
|
|
|
|
|
|
|
def fetch_alias(self): |
|
|
|
self.alias_info = None |
|
|
@ -418,10 +432,6 @@ class ElectrumWindow(QMainWindow, PrintError): |
|
|
|
]) |
|
|
|
QMessageBox.information(self, "Electrum - " + _("Reporting Bugs"), msg) |
|
|
|
|
|
|
|
|
|
|
|
def new_transaction(self, tx): |
|
|
|
self.tx_notifications.append(tx) |
|
|
|
|
|
|
|
def notify_transactions(self): |
|
|
|
if not self.network or not self.network.is_connected(): |
|
|
|
return |
|
|
@ -2800,6 +2810,8 @@ class ElectrumWindow(QMainWindow, PrintError): |
|
|
|
NetworkDialog(self.wallet.network, self.config, self).do_exec() |
|
|
|
|
|
|
|
def closeEvent(self, event): |
|
|
|
if self.network: |
|
|
|
self.network.unregister_callback(self.on_network) |
|
|
|
self.config.set_key("is_maximized", self.isMaximized()) |
|
|
|
if not self.isMaximized(): |
|
|
|
g = self.geometry() |
|
|
|