URI: 
       tImproved new_window handling. - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 77a029082aac75264c5851ea7bb3928af4d44e6d
   DIR parent fcc452d7b02759f6eb90f8e90aff5026b8ef04f2
  HTML Author: Neil Booth <kyuupichan@gmail.com>
       Date:   Fri,  4 Sep 2015 09:53:16 +0900
       
       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.
       
       Diffstat:
         M gui/qt/main_window.py               |       2 --
         M lib/plugins.py                      |      14 ++++++++++++--
         M plugins/audio_modem.py              |       4 ----
         M plugins/exchange_rate.py            |       8 ++------
       
       4 files changed, 14 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -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()
   DIR diff --git a/lib/plugins.py b/lib/plugins.py
       t@@ -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
       t@@ -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)
       t@@ -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
        
       t@@ -204,3 +210,7 @@ class BasePlugin:
        
            def settings_dialog(self):
                pass
       +
       +    # Events
       +    def on_new_window(self, window):
       +        pass
   DIR diff --git a/plugins/audio_modem.py b/plugins/audio_modem.py
       t@@ -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
        
   DIR diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py
       t@@ -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):
       t@@ -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)