URI: 
       tkivy: simplify currency dialog - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 1f350c31ddc909052bfd6f66ee5d97337aa9ce18
   DIR parent 132fca86b2c4fd594bdfa8ec47987d9a9625c3f3
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Tue, 24 Jan 2017 10:45:49 +0100
       
       kivy: simplify currency dialog
       
       Diffstat:
         M gui/kivy/uix/dialogs/fx_dialog.py   |      29 +++++++++--------------------
         M gui/kivy/uix/dialogs/settings.py    |       2 +-
         M gui/qt/main_window.py               |       2 +-
         M lib/exchange_rate.py                |       4 ++--
       
       4 files changed, 13 insertions(+), 24 deletions(-)
       ---
   DIR diff --git a/gui/kivy/uix/dialogs/fx_dialog.py b/gui/kivy/uix/dialogs/fx_dialog.py
       t@@ -11,16 +11,6 @@ Builder.load_string('''
            pos_hint: {'top':0.9}
            BoxLayout:
                orientation: 'vertical'
       -        BoxLayout:
       -            orientation: 'horizontal'
       -            size_hint: 1, 0.1
       -            Label:
       -                text: _('Enable')
       -                height: '48dp'
       -            CheckBox:
       -                height: '48dp'
       -                id: enabled
       -                on_active: popup.on_active(self.active)
        
                Widget:
                    size_hint: 1, 0.1
       t@@ -76,7 +66,7 @@ from kivy.uix.checkbox import CheckBox
        from kivy.uix.widget import Widget
        from kivy.clock import Clock
        
       -from electrum.plugins import run_hook
       +from electrum_gui.kivy.i18n import _
        from functools import partial
        
        class FxDialog(Factory.Popup):
       t@@ -87,11 +77,8 @@ class FxDialog(Factory.Popup):
                self.config = config
                self.callback = callback
                self.fx = self.app.fx
       -        self.ids.enabled.active = self.fx.is_enabled()
       -
       -    def on_active(self, b):
       -        self.fx.set_enabled(b)
       -        Clock.schedule_once(lambda dt: self.add_currencies())
       +        self.fx.set_history_config(True)
       +        self.add_currencies()
        
            def add_exchanges(self):
                exchanges = sorted(self.fx.get_exchanges_by_ccy(self.fx.get_currency(), True)) if self.fx.is_enabled() else []
       t@@ -107,14 +94,16 @@ class FxDialog(Factory.Popup):
                    self.fx.set_exchange(text)
        
            def add_currencies(self):
       -        currencies = sorted(self.fx.get_currencies()) if self.fx else []
       -        my_ccy = self.fx.get_currency() if self.fx.is_enabled() else ''
       +        currencies = [_('None')] + self.fx.get_currencies(True)
       +        my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None')
                self.ids.ccy.values = currencies
                self.ids.ccy.text = my_ccy
        
            def on_currency(self, ccy):
       -        if ccy:
       -            if self.fx.is_enabled() and ccy != self.fx.get_currency():
       +        b = (ccy != _('None'))
       +        self.fx.set_enabled(b)
       +        if b:
       +            if ccy != self.fx.get_currency():
                        self.fx.set_currency(ccy)
                    self.app.fiat_unit = ccy
                Clock.schedule_once(lambda dt: self.add_exchanges())
   DIR diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py
       t@@ -246,7 +246,7 @@ class SettingsDialog(Factory.Popup):
                    ccy = fx.get_currency()
                    return '%s [%s]' %(ccy, source)
                else:
       -            return 'Disabled'
       +            return _('None')
        
            def fx_dialog(self, label, dt):
                if self._fx_dialog is None:
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -2578,7 +2578,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                ex_combo = QComboBox()
        
                def update_currencies():
       -            currencies = sorted(self.fx.get_currencies())
       +            currencies = sorted(self.fx.get_currencies(self.fx.get_history_config()))
                    ccy_combo.clear()
                    ccy_combo.addItems([_('None')] + currencies)
                    if self.fx.is_enabled():
   DIR diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py
       t@@ -333,8 +333,8 @@ class FxThread(ThreadJob):
                self.hist_checkbox = None
                self.set_exchange(self.config_exchange())
        
       -    def get_currencies(self):
       -        d = get_exchanges_by_ccy(False)
       +    def get_currencies(self, h):
       +        d = get_exchanges_by_ccy(h)
                return sorted(d.keys())
        
            def get_exchanges_by_ccy(self, ccy, h):