2015-12-18 06:03:38 -08:00
|
|
|
from kivy.app import App
|
|
|
|
from kivy.factory import Factory
|
|
|
|
from kivy.properties import ObjectProperty
|
|
|
|
from kivy.lang import Builder
|
|
|
|
|
2016-02-04 01:57:09 -08:00
|
|
|
from electrum_gui.kivy.i18n import _
|
2015-12-18 06:03:38 -08:00
|
|
|
from electrum.util import base_units
|
2015-10-06 00:59:29 -07:00
|
|
|
|
2015-12-18 06:03:38 -08:00
|
|
|
import os
|
|
|
|
from label_dialog import LabelDialog
|
|
|
|
|
|
|
|
Builder.load_string('''
|
|
|
|
#:import os os
|
|
|
|
<WalletDialog@Popup>:
|
2015-12-02 03:11:28 -08:00
|
|
|
title: _('Wallets')
|
|
|
|
id: popup
|
2016-01-18 01:08:21 -08:00
|
|
|
path: ''
|
2015-10-07 04:48:58 -07:00
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
2016-03-06 05:49:50 -08:00
|
|
|
padding: '10dp'
|
2015-12-15 23:57:47 -08:00
|
|
|
FileChooserListView:
|
2015-10-07 04:48:58 -07:00
|
|
|
id: wallet_selector
|
2015-12-20 08:37:07 -08:00
|
|
|
dirselect: False
|
|
|
|
filter_dirs: True
|
|
|
|
filter: '*.*'
|
2016-03-10 01:18:29 -08:00
|
|
|
path: os.path.dirname(app.get_wallet_path())
|
2016-01-19 06:57:11 -08:00
|
|
|
size_hint_y: 0.6
|
2015-12-18 01:53:50 -08:00
|
|
|
Widget
|
|
|
|
size_hint_y: 0.1
|
2015-12-15 23:57:47 -08:00
|
|
|
GridLayout:
|
2015-12-18 01:53:50 -08:00
|
|
|
cols: 2
|
2016-01-19 06:57:11 -08:00
|
|
|
size_hint_y: 0.1
|
2015-12-15 23:57:47 -08:00
|
|
|
Button:
|
2016-01-19 06:57:11 -08:00
|
|
|
size_hint: 0.1, None
|
2015-12-15 23:57:47 -08:00
|
|
|
height: '48dp'
|
2015-12-18 01:53:50 -08:00
|
|
|
text: _('Cancel')
|
2015-12-15 23:57:47 -08:00
|
|
|
on_release:
|
|
|
|
popup.dismiss()
|
2015-12-02 03:11:28 -08:00
|
|
|
Button:
|
2016-01-18 01:08:21 -08:00
|
|
|
id: open_button
|
2016-01-19 06:57:11 -08:00
|
|
|
size_hint: 0.1, None
|
2015-12-02 03:11:28 -08:00
|
|
|
height: '48dp'
|
2016-01-19 06:57:11 -08:00
|
|
|
text: _('Open') if wallet_selector.selection else _('New Wallet')
|
2015-12-02 03:11:28 -08:00
|
|
|
on_release:
|
|
|
|
popup.dismiss()
|
2016-01-18 05:09:48 -08:00
|
|
|
root.new_wallet(app, wallet_selector.path)
|
2015-12-18 06:03:38 -08:00
|
|
|
''')
|
|
|
|
|
|
|
|
class WalletDialog(Factory.Popup):
|
2016-01-18 05:09:48 -08:00
|
|
|
def new_wallet(self, app, dirname):
|
2015-12-18 06:03:38 -08:00
|
|
|
def cb(text):
|
|
|
|
if text:
|
2016-01-18 05:09:48 -08:00
|
|
|
app.load_wallet_by_name(os.path.join(dirname, text))
|
2016-01-19 07:11:23 -08:00
|
|
|
if self.ids.wallet_selector.selection:
|
|
|
|
app.load_wallet_by_name(self.ids.wallet_selector.selection[0])
|
2016-01-18 01:08:21 -08:00
|
|
|
else:
|
|
|
|
d = LabelDialog(_('Enter wallet name'), '', cb)
|
|
|
|
d.open()
|