From ee4ccd9b1be300f4e4a0801effeec2cb4a75df04 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 18 Dec 2015 15:03:38 +0100 Subject: [PATCH] kivy: move wallets dialog --- gui/kivy/main_window.py | 12 ++++---- .../wallets.kv => dialogs/wallets.py} | 28 +++++++++++++++++-- gui/kivy/uix/screens.py | 4 +-- gui/kivy/uix/ui_screens/status.kv | 6 ++++ 4 files changed, 40 insertions(+), 10 deletions(-) rename gui/kivy/uix/{ui_screens/wallets.kv => dialogs/wallets.py} (75%) diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py index 757cdc65c..190de363e 100644 --- a/gui/kivy/main_window.py +++ b/gui/kivy/main_window.py @@ -332,10 +332,6 @@ class ElectrumWindow(App): d = LabelDialog(_('Enter wallet name'), '', f) d.open() - def settings_dialog(self): - from uix.dialogs.settings import SettingsDialog - d = SettingsDialog(self) - d.open() def on_stop(self): self.stop_wallet() @@ -395,7 +391,13 @@ class ElectrumWindow(App): def popup_dialog(self, name): if name == 'settings': - self.settings_dialog() + from uix.dialogs.settings import SettingsDialog + d = SettingsDialog(self) + d.open() + elif name == 'wallets': + from uix.dialogs.wallets import WalletDialog + d = WalletDialog() + d.open() else: popup = Builder.load_file('gui/kivy/uix/ui_screens/'+name+'.kv') popup.open() diff --git a/gui/kivy/uix/ui_screens/wallets.kv b/gui/kivy/uix/dialogs/wallets.py similarity index 75% rename from gui/kivy/uix/ui_screens/wallets.kv rename to gui/kivy/uix/dialogs/wallets.py index d96969195..d50b1bd38 100644 --- a/gui/kivy/uix/ui_screens/wallets.kv +++ b/gui/kivy/uix/dialogs/wallets.py @@ -1,6 +1,17 @@ -#:import os os +from kivy.app import App +from kivy.factory import Factory +from kivy.properties import ObjectProperty +from kivy.lang import Builder + +from electrum.i18n import _ +from electrum.util import base_units -Popup: +import os +from label_dialog import LabelDialog + +Builder.load_string(''' +#:import os os +: title: _('Wallets') id: popup path: app.wallet.storage.path @@ -22,7 +33,7 @@ Popup: size_hint_y: None text: os.path.basename(app.wallet.storage.path) on_release: - app.create_wallet_dialog(self) + root.name_dialog() on_text: popup.path = os.path.join(wallet_selector.path, self.text) Widget @@ -35,6 +46,7 @@ Popup: size_hint_y: 0.5 Widget size_hint_y: 0.1 + GridLayout: cols: 2 size_hint_y: None @@ -52,3 +64,13 @@ Popup: on_release: popup.dismiss() app.load_wallet_by_name(popup.path) +''') + +class WalletDialog(Factory.Popup): + def name_dialog(self): + def cb(text): + if text: + self.ids.wallet_name.text = text + d = LabelDialog(_('Enter wallet name'), '', cb) + d.open() + diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py index 73cceef45..9c4a56e78 100644 --- a/gui/kivy/uix/screens.py +++ b/gui/kivy/uix/screens.py @@ -337,7 +337,7 @@ class ReceiveScreen(CScreen): req = self.app.wallet.make_payment_request(addr, amount, message, None) self.app.wallet.add_payment_request(req, self.app.electrum_config) self.app.show_error(_('Request saved')) - self.app.update_screen('requests') + self.app.update_tab('requests') def do_new(self): self.app.receive_address = None @@ -405,7 +405,7 @@ class InvoicesScreen(CScreen): def do_delete(self, obj): self.app.invoices.remove(obj.key) - self.app.update_screen('invoices') + self.app.update_tab('invoices') class RequestsScreen(CScreen): kvname = 'requests' diff --git a/gui/kivy/uix/ui_screens/status.kv b/gui/kivy/uix/ui_screens/status.kv index 4d02f89bc..59e23d93e 100644 --- a/gui/kivy/uix/ui_screens/status.kv +++ b/gui/kivy/uix/ui_screens/status.kv @@ -1,3 +1,5 @@ +#:import os os + Popup: title: "Balance" confirmed: 0 @@ -10,6 +12,10 @@ Popup: spacing: '1dp' GridLayout: cols:2 + Label: + text: _("Wallet:") + Label: + text: os.path.basename(app.wallet.storage.path) Label: text: _("Confirmed:") Label: