plugins: on_close method
This commit is contained in:
parent
6770834d06
commit
de964f4033
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue