1
0

plugins: remove 'on_new_window' hook

This commit is contained in:
SomberNight
2020-12-08 10:33:43 +01:00
parent 933d8861ce
commit 95b08e9961
3 changed files with 9 additions and 7 deletions

View File

@@ -233,8 +233,6 @@ class ElectrumGui(Logger):
w = ElectrumWindow(self, wallet)
self.windows.append(w)
self.build_tray_menu()
# FIXME: Remove in favour of the load_wallet hook
run_hook('on_new_window', w)
w.warn_if_testnet()
w.warn_if_watching_only()
return w

View File

@@ -38,7 +38,7 @@ from electrum.transaction import Transaction, PartialTransaction, tx_from_any
from electrum.bip32 import BIP32Node
from electrum.plugin import BasePlugin, hook
from electrum.i18n import _
from electrum.wallet import Multisig_Wallet
from electrum.wallet import Multisig_Wallet, Abstract_Wallet
from electrum.util import bh2u, bfh
from electrum.gui.qt.transaction_dialog import show_transaction, TxDialog
@@ -114,10 +114,10 @@ class Plugin(BasePlugin):
return
self._init_qt_received = True
for window in gui.windows:
self.on_new_window(window)
self.load_wallet(window.wallet, window)
@hook
def on_new_window(self, window):
def load_wallet(self, wallet: 'Abstract_Wallet', window: 'ElectrumWindow'):
self.update(window)
@hook

View File

@@ -27,6 +27,7 @@ from functools import partial
import threading
import sys
import os
from typing import TYPE_CHECKING
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import QObject, pyqtSignal
@@ -47,6 +48,10 @@ from electrum.base_wizard import GoBack
from .trustedcoin import TrustedCoinPlugin, server
if TYPE_CHECKING:
from electrum.gui.qt.main_window import ElectrumWindow
from electrum.wallet import Abstract_Wallet
class TOS(QTextEdit):
tos_signal = pyqtSignal()
@@ -84,8 +89,7 @@ class Plugin(TrustedCoinPlugin):
super().__init__(parent, config, name)
@hook
def on_new_window(self, window):
wallet = window.wallet
def load_wallet(self, wallet: 'Abstract_Wallet', window: 'ElectrumWindow'):
if not isinstance(wallet, self.wallet_class):
return
wallet.handler_2fa = HandlerTwoFactor(self, window)