electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c160a99ebcadcf95b04a59f5d43f1dc39e25d594
parent 144f53be1845db3fc839fd0c9509602c6a8f4693
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Sun, 17 Jan 2016 18:16:58 +0900

Add cancel button to trezor dialogs

Diffstat:
Mplugins/trezor/clientbase.py | 12+++++-------
Mplugins/trezor/qt_generic.py | 12++++++------
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/plugins/trezor/clientbase.py b/plugins/trezor/clientbase.py @@ -23,13 +23,7 @@ class GuiMixin(object): def callback_ButtonRequest(self, msg): msg_code = self.msg_code_override or msg.code message = self.messages.get(msg_code, self.messages['default']) - - if msg.code in [3, 8] and hasattr(self, 'cancel'): - cancel_callback = self.cancel - else: - cancel_callback = None - - self.handler.show_message(message % self.device, cancel_callback) + self.handler.show_message(message % self.device, self.cancel) return self.proto.ButtonAck() def callback_PinMatrixRequest(self, msg): @@ -106,6 +100,10 @@ class TrezorClientBase(GuiMixin, PrintError): path.append(abs(int(x)) | prime) return path + def cancel(self): + '''Provided here as in keepkeylib but not trezorlib.''' + self.transport.write(self.proto.Cancel()) + def first_address(self, derivation): return self.address_from_derivation(derivation) diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py @@ -43,8 +43,8 @@ class QtHandler(PrintError): def watching_only_changed(self): self.win.emit(SIGNAL('watching_only_changed')) - def show_message(self, msg, cancel_callback=None): - self.win.emit(SIGNAL('message_dialog'), msg, cancel_callback) + def show_message(self, msg, on_cancel=None): + self.win.emit(SIGNAL('message_dialog'), msg, on_cancel) def show_error(self, msg): self.win.emit(SIGNAL('error_dialog'), msg) @@ -106,17 +106,17 @@ class QtHandler(PrintError): self.word = unicode(text.text()) self.done.set() - def message_dialog(self, msg, cancel_callback): + def message_dialog(self, msg, on_cancel): # Called more than once during signing, to confirm output and fee self.clear_dialog() title = _('Please check your %s device') % self.device self.dialog = dialog = WindowModalDialog(self.top_level_window(), title) l = QLabel(msg) vbox = QVBoxLayout(dialog) - if cancel_callback: - vbox.addLayout(Buttons(CancelButton(dialog))) - dialog.connect(dialog, SIGNAL('rejected()'), cancel_callback) vbox.addWidget(l) + if on_cancel: + dialog.rejected.connect(on_cancel) + vbox.addLayout(Buttons(CancelButton(dialog))) dialog.show() def error_dialog(self, msg):