From 1179a4cf9e11a41ada5f8dfc006a92c71da3aa8d Mon Sep 17 00:00:00 2001 From: qua-non Date: Tue, 11 Mar 2014 00:18:12 +0530 Subject: [PATCH] manage exchange plugins, make sure ui doesn't stall while saving seed and numerous other small fixes. --- gui/kivy/dialog.py | 4 +- gui/kivy/drawer.py | 15 +- gui/kivy/installwizard.py | 28 ++- gui/kivy/main.kv | 3 +- gui/kivy/main_window.py | 53 +++-- gui/kivy/plugins/exchange_rate.py | 325 ++++++++++++++++++++++-------- lib/util.py | 7 + 7 files changed, 316 insertions(+), 119 deletions(-) diff --git a/gui/kivy/dialog.py b/gui/kivy/dialog.py index 66c42cca5..502c6a92f 100644 --- a/gui/kivy/dialog.py +++ b/gui/kivy/dialog.py @@ -192,7 +192,7 @@ class InfoBubble(Bubble): anim.start(self) - def hide(self, *dt): + def hide(self, now=False): ''' Auto fade out the Bubble ''' def on_stop(*l): @@ -205,6 +205,8 @@ class InfoBubble(Bubble): App.get_running_app().stop() import sys sys.exit() + if now: + return on_stop() anim = Animation(opacity=0, d=.25) anim.bind(on_complete=on_stop) diff --git a/gui/kivy/drawer.py b/gui/kivy/drawer.py index b52062d19..bcf580d0f 100644 --- a/gui/kivy/drawer.py +++ b/gui/kivy/drawer.py @@ -82,11 +82,13 @@ class Drawer(StencilView): if app.ui_mode[0] == 't': return super(Drawer, self).on_touch_down(touch) + state = self.state touch.ud['send_touch_down'] = False + start = 0 if state[0] == 'c' else self._hidden_widget.right drag_area = ((self.width * self.drag_area) if self.state[0] == 'c' else - self._hidden_widget.width) - if touch.x > drag_area: + self.width) + if touch.x not in range(int(start), int(drag_area)): return super(Drawer, self).on_touch_down(touch) self._touch = touch Clock.schedule_once(self._change_touch_mode, @@ -106,8 +108,13 @@ class Drawer(StencilView): if not touch.ud.get('in_drag_area', None): return super(Drawer, self).on_touch_move(touch) - self._overlay_widget.x = min(self._hidden_widget.width, - max(self._overlay_widget.x + touch.dx*2, 0)) + ov = self._overlay_widget + ov.x=min(self._hidden_widget.width, + max(ov.x + touch.dx*2, 0)) + #_anim = Animation(x=x, duration=1/60) + #_anim.cancel_all(ov) + #_anim.start(ov) + if abs(touch.x - touch.ox) < self.scroll_distance: return touch.ud['send_touch_down'] = False diff --git a/gui/kivy/installwizard.py b/gui/kivy/installwizard.py index e0fb6c9a4..41809a8e1 100644 --- a/gui/kivy/installwizard.py +++ b/gui/kivy/installwizard.py @@ -45,10 +45,16 @@ class InstallWizard(Widget): ''' def target(): + # run your threaded function - task() + try: + task() + except Exception as err: + Clock.schedule_once(lambda dt: app.show_error(str(err))) + # on completion hide message - Clock.schedule_once(lambda dt: app.info_bubble.hide()) + Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1) + # call completion routine if on_complete: Clock.schedule_once(lambda dt: on_complete()) @@ -138,14 +144,14 @@ class InstallWizard(Widget): brainwallet = seed - msg2 = _("[color=#414141][b]"+\ + msg2 = _("[color=#414141]"+\ "[b]PLEASE WRITE DOWN YOUR SEED PASS[/b][/color]"+\ "[size=9]\n\n[/size]" +\ "[color=#929292]If you ever forget your pincode, your seed" +\ " phrase will be the [color=#EB984E]"+\ "[b]only way to recover[/b][/color] your wallet. Your " +\ " [color=#EB984E][b]Bitcoins[/b][/color] will otherwise be" +\ - " [color=#EB984E]lost forever![/color]") + " [color=#EB984E][b]lost forever![/b][/color]") if wallet.imported_keys: msg2 += "[b][color=#ff0000ff]" + _("WARNING") + "[/color]:[/b] " +\ @@ -234,13 +240,13 @@ class InstallWizard(Widget): return app.show_error(_('Passwords do not match'), duration=.5) if mode == 'restore': - try: - wallet.save_seed(new_password) - except Exception as err: - app.show_error(str(err)) - return - _dlg.close() - self.load_network(wallet, mode='restore') + def on_complete(*l): + _dlg.close() + self.load_network(wallet, mode='restore') + + self.waiting_dialog(lambda: wallet.save_seed(new_password), + msg=_("saving seed"), + on_complete=on_complete) return if not instance: # create diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv index f559d065b..35bd64af5 100644 --- a/gui/kivy/main.kv +++ b/gui/kivy/main.kv @@ -2,6 +2,7 @@ #:import _ electrum.i18n._ #:import partial functools.partial + # Custom Global Widgets : @@ -27,7 +28,7 @@