Improved new_window handling.
Remove new_window hook. Plugin informed of all windows via events when first loaded. init_qt no longer needed for exchange_rate plugin.
This commit is contained in:
@@ -182,8 +182,6 @@ class ElectrumWindow(QMainWindow):
|
|||||||
self.fetch_alias()
|
self.fetch_alias()
|
||||||
self.require_fee_update = False
|
self.require_fee_update = False
|
||||||
self.tx_notifications = []
|
self.tx_notifications = []
|
||||||
# hook
|
|
||||||
run_hook('new_window', self)
|
|
||||||
|
|
||||||
def is_hidden(self):
|
def is_hidden(self):
|
||||||
return self.isMinimized() or self.isHidden()
|
return self.isMinimized() or self.isHidden()
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ class Plugins:
|
|||||||
else:
|
else:
|
||||||
p = __import__(full_name, fromlist=['electrum_plugins'])
|
p = __import__(full_name, fromlist=['electrum_plugins'])
|
||||||
plugin = p.Plugin(self, config, name)
|
plugin = p.Plugin(self, config, name)
|
||||||
|
# Inform the plugin of our windows
|
||||||
|
for window in self.windows:
|
||||||
|
plugin.on_new_window(window)
|
||||||
self.plugins[name] = plugin
|
self.plugins[name] = plugin
|
||||||
self.print_error("loaded", name)
|
self.print_error("loaded", name)
|
||||||
return plugin
|
return plugin
|
||||||
@@ -115,8 +118,13 @@ class Plugins:
|
|||||||
x += (lambda: self.wallet_plugin_loader(config, name),)
|
x += (lambda: self.wallet_plugin_loader(config, name),)
|
||||||
wallet.wallet_types.append(x)
|
wallet.wallet_types.append(x)
|
||||||
|
|
||||||
|
def trigger(self, event, *args, **kwargs):
|
||||||
|
for plugin in self.plugins.values():
|
||||||
|
getattr(plugin, event)(*args, **kwargs)
|
||||||
|
|
||||||
def on_new_window(self, window):
|
def on_new_window(self, window):
|
||||||
self.windows.append(window)
|
self.windows.append(window)
|
||||||
|
self.trigger('on_new_window', window)
|
||||||
|
|
||||||
def on_close_window(self, window):
|
def on_close_window(self, window):
|
||||||
self.windows.remove(window)
|
self.windows.remove(window)
|
||||||
@@ -194,8 +202,6 @@ class BasePlugin:
|
|||||||
@hook
|
@hook
|
||||||
def close_wallet(self): pass
|
def close_wallet(self): pass
|
||||||
|
|
||||||
#def init(self): pass
|
|
||||||
|
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
return self.is_available() and self.config.get('use_'+self.name) is True
|
return self.is_available() and self.config.get('use_'+self.name) is True
|
||||||
|
|
||||||
@@ -204,3 +210,7 @@ class BasePlugin:
|
|||||||
|
|
||||||
def settings_dialog(self):
|
def settings_dialog(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Events
|
||||||
|
def on_new_window(self, window):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ class Plugin(BasePlugin):
|
|||||||
'Linux': 'libportaudio.so'
|
'Linux': 'libportaudio.so'
|
||||||
}[platform.system()]
|
}[platform.system()]
|
||||||
|
|
||||||
@hook
|
|
||||||
def init_qt(self, gui):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
return amodem is not None
|
return amodem is not None
|
||||||
|
|
||||||
|
|||||||
@@ -171,10 +171,6 @@ class Plugin(BasePlugin):
|
|||||||
self.btc_rate = Decimal("0.0")
|
self.btc_rate = Decimal("0.0")
|
||||||
self.network = None
|
self.network = None
|
||||||
self.wallet_tx_list = {}
|
self.wallet_tx_list = {}
|
||||||
# For mid-session plugin loads
|
|
||||||
for window in parent.windows:
|
|
||||||
self.new_window(window)
|
|
||||||
self.new_wallets([window.wallet for window in parent.windows])
|
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def set_network(self, network):
|
def set_network(self, network):
|
||||||
@@ -185,14 +181,14 @@ class Plugin(BasePlugin):
|
|||||||
if network:
|
if network:
|
||||||
network.add_job(self.exchanger)
|
network.add_job(self.exchanger)
|
||||||
|
|
||||||
@hook
|
def on_new_window(self, window):
|
||||||
def new_window(self, window):
|
|
||||||
window.connect(window, SIGNAL("refresh_currencies()"),
|
window.connect(window, SIGNAL("refresh_currencies()"),
|
||||||
window.update_status)
|
window.update_status)
|
||||||
window.fx_fields = {}
|
window.fx_fields = {}
|
||||||
self.add_send_edit(window)
|
self.add_send_edit(window)
|
||||||
self.add_receive_edit(window)
|
self.add_receive_edit(window)
|
||||||
window.update_status()
|
window.update_status()
|
||||||
|
self.new_wallets([window.wallet])
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
BasePlugin.close(self)
|
BasePlugin.close(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user