Browse Source

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.
283
Neil Booth 10 years ago
parent
commit
77a029082a
  1. 2
      gui/qt/main_window.py
  2. 14
      lib/plugins.py
  3. 4
      plugins/audio_modem.py
  4. 8
      plugins/exchange_rate.py

2
gui/qt/main_window.py

@ -182,8 +182,6 @@ class ElectrumWindow(QMainWindow):
self.fetch_alias()
self.require_fee_update = False
self.tx_notifications = []
# hook
run_hook('new_window', self)
def is_hidden(self):
return self.isMinimized() or self.isHidden()

14
lib/plugins.py

@ -69,6 +69,9 @@ class Plugins:
else:
p = __import__(full_name, fromlist=['electrum_plugins'])
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.print_error("loaded", name)
return plugin
@ -115,8 +118,13 @@ class Plugins:
x += (lambda: self.wallet_plugin_loader(config, name),)
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):
self.windows.append(window)
self.trigger('on_new_window', window)
def on_close_window(self, window):
self.windows.remove(window)
@ -194,8 +202,6 @@ class BasePlugin:
@hook
def close_wallet(self): pass
#def init(self): pass
def is_enabled(self):
return self.is_available() and self.config.get('use_'+self.name) is True
@ -204,3 +210,7 @@ class BasePlugin:
def settings_dialog(self):
pass
# Events
def on_new_window(self, window):
pass

4
plugins/audio_modem.py

@ -35,10 +35,6 @@ class Plugin(BasePlugin):
'Linux': 'libportaudio.so'
}[platform.system()]
@hook
def init_qt(self, gui):
pass
def is_available(self):
return amodem is not None

8
plugins/exchange_rate.py

@ -171,10 +171,6 @@ class Plugin(BasePlugin):
self.btc_rate = Decimal("0.0")
self.network = None
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
def set_network(self, network):
@ -185,14 +181,14 @@ class Plugin(BasePlugin):
if network:
network.add_job(self.exchanger)
@hook
def new_window(self, window):
def on_new_window(self, window):
window.connect(window, SIGNAL("refresh_currencies()"),
window.update_status)
window.fx_fields = {}
self.add_send_edit(window)
self.add_receive_edit(window)
window.update_status()
self.new_wallets([window.wallet])
def close(self):
BasePlugin.close(self)

Loading…
Cancel
Save