electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit de964f40336a51dc5e1e9c149c55fc37e8608393
parent 6770834d0648c195f065331e6a4bf481e8610683
Author: ThomasV <thomasv@electrum.org>
Date:   Wed,  9 Dec 2015 09:41:24 +0100

plugins: on_close method

Diffstat:
Mgui/kivy/main_window.py | 30++++--------------------------
Mlib/plugins.py | 4++++
Mplugins/exchange_rate/exchange_rate.py | 1-
Mplugins/exchange_rate/kivy.py | 20++++++++++++++++----
Mplugins/exchange_rate/qt.py | 4+---
5 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -79,7 +79,7 @@ class ElectrumWindow(App): context = StringProperty('') context_action = lambda x: None - status = StringProperty(_('Not Connected')) + status = StringProperty('') fiat_unit = StringProperty('') def decimal_point(self): @@ -224,6 +224,7 @@ class ElectrumWindow(App): def show_plugins(self, plugins_list): def on_active(sw, value): self.plugins.toggle_enabled(self.electrum_config, sw.name) + run_hook('init_kivy', self) for item in self.plugins.descriptions: if 'kivy' not in item.get('available_for', []): continue @@ -424,13 +425,8 @@ class ElectrumWindow(App): def update_status(self, *dt): if not self.wallet: return - - unconfirmed = '' - quote_text = '' - if self.network is None or not self.network.is_running(): - text = _("Offline") - + self.status = _("Offline") elif self.network.is_connected(): server_height = self.network.get_server_height() server_lag = self.network.get_local_height() - server_height @@ -440,29 +436,11 @@ class ElectrumWindow(App): self.status = _("Server lagging (%d blocks)"%server_lag) else: c, u, x = self.wallet.get_account_balance(self.current_account) - text = self.format_amount(c) - if u: - unconfirmed = " [%s unconfirmed]" %( self.format_amount(u, True).strip()) - if x: - unmatured = " [%s unmatured]"%(self.format_amount(x, True).strip()) - #quote_text = self.create_quote_text(Decimal(c+u+x)/100000000, mode='symbol') or '' + text = self.format_amount(c+x+u) self.status = text.strip() + ' ' + self.base_unit else: self.status = _("Not connected") - return - - print self.root.manager.ids - - #try: - status_card = self.root.main_screen.ids.tabs.ids.\ - screen_dashboard.ids.status_card - #except AttributeError: - # return - - status_card.quote_text = quote_text.strip() - status_card.uncomfirmed = unconfirmed.strip() - def get_max_amount(self): inputs = self.wallet.get_spendable_coins(None) diff --git a/lib/plugins.py b/lib/plugins.py @@ -187,6 +187,10 @@ class BasePlugin(PrintError): l.remove((self, getattr(self, k))) hooks[k] = l self.parent.close_plugin(self) + self.on_close() + + def on_close(self): + pass def requires_settings(self): return False diff --git a/plugins/exchange_rate/exchange_rate.py b/plugins/exchange_rate/exchange_rate.py @@ -288,7 +288,6 @@ class FxPlugin(BasePlugin, ThreadJob): def show_history(self): return self.config_history() and self.exchange.history_ccys() - def set_exchange(self, name): class_ = self.exchanges.get(name) or self.exchanges.values()[0] name = class_.__name__ diff --git a/plugins/exchange_rate/kivy.py b/plugins/exchange_rate/kivy.py @@ -2,14 +2,26 @@ from exchange_rate import FxPlugin from electrum.plugins import hook class Plugin(FxPlugin): - @hook - def load_wallet(self, wallet, window): - self.window = window def on_quotes(self): self.print_error("on quotes", self.ccy) - self.window.fiat_unit = self.ccy def on_history(self): self.print_error("on history") self.window.history_screen.update() + + def on_close(self): + self.print_error("on close") + self.window.fiat_unit = '' + self.window.history_screen.update() + + @hook + def init_kivy(self, window): + self.window = window + self.window.fiat_unit = self.ccy + self.window.history_screen.update() + + @hook + def load_wallet(self, wallet, window): + self.window = window + self.window.fiat_unit = self.ccy diff --git a/plugins/exchange_rate/qt.py b/plugins/exchange_rate/qt.py @@ -49,9 +49,7 @@ class Plugin(FxPlugin): def do_clear(self, window): window.fiat_send_e.setText('') - def close(self): - # Get rid of hooks before updating status bars. - FxPlugin.close(self) + def on_close(self): self.app.emit(SIGNAL('close_fx_plugin')) def restore_window(self, window):