|
|
|
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
|
|
|
|
|
|
|
|
import os
|
|
|
|
from label_dialog import LabelDialog
|
|
|
|
|
|
|
|
Builder.load_string('''
|
|
|
|
#:import os os
|
|
|
|
<WalletDialog@Popup>:
|
|
|
|
title: _('Wallets')
|
|
|
|
id: popup
|
|
|
|
path: ''
|
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
BoxLayout:
|
|
|
|
height: '48dp'
|
|
|
|
size_hint_y: None
|
|
|
|
orientation: 'horizontal'
|
|
|
|
Label:
|
|
|
|
text: _('Current Wallet') + ': '
|
|
|
|
height: '48dp'
|
|
|
|
size_hint_y: None
|
|
|
|
Label:
|
|
|
|
id: wallet_name
|
|
|
|
height: '48dp'
|
|
|
|
size_hint_y: None
|
|
|
|
text: os.path.basename(app.wallet.storage.path)
|
|
|
|
on_text:
|
|
|
|
popup.path = os.path.join(wallet_selector.path, self.text)
|
|
|
|
Widget
|
|
|
|
size_hint_y: None
|
|
|
|
Label:
|
|
|
|
height: '48dp'
|
|
|
|
size_hint_y: None
|
|
|
|
text: _('Wallets')
|
|
|
|
FileChooserListView:
|
|
|
|
id: wallet_selector
|
|
|
|
dirselect: False
|
|
|
|
filter_dirs: True
|
|
|
|
filter: '*.*'
|
|
|
|
path: os.path.dirname(app.wallet.storage.path)
|
|
|
|
on_selection:
|
|
|
|
wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
|
|
|
|
size_hint_y: 0.4
|
|
|
|
Widget
|
|
|
|
size_hint_y: 0.1
|
|
|
|
|
|
|
|
GridLayout:
|
|
|
|
cols: 2
|
|
|
|
size_hint_y: None
|
|
|
|
Button:
|
|
|
|
size_hint: 0.5, None
|
|
|
|
height: '48dp'
|
|
|
|
text: _('Cancel')
|
|
|
|
on_release:
|
|
|
|
popup.dismiss()
|
|
|
|
Button:
|
|
|
|
id: open_button
|
|
|
|
size_hint: 0.5, None
|
|
|
|
height: '48dp'
|
|
|
|
text: _('Open') if popup.path else _('New Wallet')
|
|
|
|
on_release:
|
|
|
|
popup.dismiss()
|
|
|
|
root.new_wallet(app)
|
|
|
|
''')
|
|
|
|
|
|
|
|
class WalletDialog(Factory.Popup):
|
|
|
|
def new_wallet(self, app):
|
|
|
|
def cb(text):
|
|
|
|
if text:
|
|
|
|
app.load_wallet_by_name(text)
|
|
|
|
if self.path:
|
|
|
|
app.load_wallet_by_name(self.path)
|
|
|
|
else:
|
|
|
|
d = LabelDialog(_('Enter wallet name'), '', cb)
|
|
|
|
d.open()
|
|
|
|
|