commit 6101abda5dea619ad04b957f376ed7ddda274cb7
parent a8f0e4310f7c7c3e8061fc0e391ce18920f16457
Author: ThomasV <thomasv@gitorious>
Date: Thu, 4 Sep 2014 15:45:03 +0200
call init_qt everytime a plugin is enabled
Diffstat:
4 files changed, 26 insertions(+), 33 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -467,6 +467,9 @@ class ElectrumWindow(QMainWindow):
raise Exception('Unknown base unit')
def update_status(self):
+ if not self.wallet:
+ return
+
if self.network is None or not self.network.is_running():
text = _("Offline")
icon = QIcon(":icons/status_disconnected.png")
@@ -2719,7 +2722,13 @@ class ElectrumWindow(QMainWindow):
w.setLayout(grid)
def do_toggle(cb, p, w):
- r = p.toggle()
+ if p.is_enabled():
+ if p.disable():
+ p.close()
+ else:
+ if p.enable():
+ p.init_qt(self.gui_object)
+ r = p.is_enabled()
cb.setChecked(r)
if w: w.setEnabled(r)
diff --git a/lib/plugins.py b/lib/plugins.py
@@ -79,16 +79,6 @@ class BasePlugin:
def requires_settings(self):
return False
-
- def toggle(self):
- if self.is_enabled():
- if self.disable():
- self.close()
- else:
- if self.enable():
- self.init()
-
- return self.is_enabled()
def enable(self):
self.set_enabled(True)
diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py
@@ -82,10 +82,6 @@ class Plugin(BasePlugin):
return BasePlugin.enable(self)
@hook
- def init_qt(self, gui):
- self.gui = gui
-
- @hook
def load_wallet(self, wallet):
self.wallet = wallet
diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py
@@ -337,6 +337,7 @@ class Plugin(BasePlugin):
BasePlugin.__init__(self,a,b)
self.currencies = [self.fiat_unit()]
self.exchanges = [self.config.get('use_exchange', "Blockchain")]
+ self.exchanger = None
@hook
def init_qt(self, gui):
@@ -344,11 +345,21 @@ class Plugin(BasePlugin):
self.win = self.gui.main_window
self.win.connect(self.win, SIGNAL("refresh_currencies()"), self.win.update_status)
self.btc_rate = Decimal("0.0")
- # Do price discovery
- self.exchanger = Exchanger(self)
- self.exchanger.start()
- self.gui.exchanger = self.exchanger #
- self.add_fiat_edit()
+ if self.exchanger is None:
+ # Do price discovery
+ self.exchanger = Exchanger(self)
+ self.exchanger.start()
+ self.gui.exchanger = self.exchanger #
+ self.add_fiat_edit()
+ self.add_fiat_edit()
+ self.win.update_status()
+
+ def close(self):
+ self.exchanger.stop()
+ self.exchanger = None
+ self.win.tabs.removeTab(1)
+ self.win.tabs.insertTab(1, self.win.create_send_tab(), _('Send'))
+ self.win.update_status()
def set_currencies(self, currency_options):
self.currencies = sorted(currency_options)
@@ -410,19 +421,6 @@ class Plugin(BasePlugin):
return True
- def toggle(self):
- enabled = BasePlugin.toggle(self)
- self.win.update_status()
- self.win.tabs.removeTab(1)
- new_send_tab = self.gui.main_window.create_send_tab()
- self.win.tabs.insertTab(1, new_send_tab, _('Send'))
- if enabled:
- self.add_fiat_edit()
- return enabled
-
-
- def close(self):
- self.exchanger.stop()
def history_tab_update(self):
if self.config.get('history_rates', 'unchecked') == "checked":