electrum

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

commit e542b24bc671e79ca57880eb1afef495bf46a192
parent b07d3466c01e6ca83490b1573cb936ca2a36b663
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 27 Aug 2016 12:13:01 +0200

Remove dynamic classes in trezor compatible plugins.
This is unecessarily complex, and can be achieved by inheritance.

Diffstat:
Mplugins/keepkey/qt.py | 4++--
Mplugins/trezor/qt.py | 4++--
Mplugins/trezor/qt_generic.py | 12+++++-------
3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/plugins/keepkey/qt.py b/plugins/keepkey/qt.py @@ -1,8 +1,8 @@ -from ..trezor.qt_generic import qt_plugin_class +from ..trezor.qt_generic import QtPlugin from keepkey import KeepKeyPlugin -class Plugin(qt_plugin_class(KeepKeyPlugin)): +class Plugin(KeepKeyPlugin, QtPlugin): icon_paired = ":icons/keepkey.png" icon_unpaired = ":icons/keepkey_unpaired.png" diff --git a/plugins/trezor/qt.py b/plugins/trezor/qt.py @@ -1,8 +1,8 @@ -from ..trezor.qt_generic import qt_plugin_class +from ..trezor.qt_generic import QtPlugin from trezor import TrezorPlugin -class Plugin(qt_plugin_class(TrezorPlugin)): +class Plugin(TrezorPlugin, QtPlugin): icon_unpaired = ":icons/trezor_unpaired.png" icon_paired = ":icons/trezor.png" diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py @@ -178,9 +178,7 @@ class QtHandler(QtHandlerBase): -def qt_plugin_class(base_plugin_class): - - class QtPlugin(base_plugin_class): +class QtPlugin(object): # Derived classes must provide the following class-static variables: # icon_file # pin_matrix_widget_class @@ -194,8 +192,8 @@ def qt_plugin_class(base_plugin_class): if type(keystore) != self.keystore_class: continue tooltip = self.device + ' ' + (keystore.label or '') - button = StatusBarButton(QIcon(self.icon_unpaired), tooltip, - partial(self.settings_dialog, window, keystore)) + cb = lambda: self.show_settings_dialog(window, keystore) + button = StatusBarButton(QIcon(self.icon_unpaired), tooltip, cb) window.statusBar().addPermanentWidget(button) handler = self.create_handler(window) handler.button = button @@ -223,7 +221,7 @@ def qt_plugin_class(base_plugin_class): keystore.thread.add(partial(self.show_address, wallet, addrs[0])) menu.addAction(_("Show on %s") % self.device, show_address) - def settings_dialog(self, window, keystore): + def show_settings_dialog(self, window, keystore): device_id = self.choose_device(window, keystore) if device_id: SettingsDialog(window, self, device_id).exec_() @@ -321,7 +319,7 @@ def qt_plugin_class(base_plugin_class): return (item, unicode(name.text()), pin, cb_phrase.isChecked()) - return QtPlugin + class SettingsDialog(WindowModalDialog):