electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 38d6c18b60989d59eb40db784121635251faff65
parent 51f8816ec776b6e06c826a4cc7afff5c7ea253d0
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 28 Mar 2017 08:53:18 +0200

kivy: allow manual server entry

Diffstat:
Mgui/kivy/uix/dialogs/choice_dialog.py | 2++
Mgui/kivy/uix/dialogs/settings.py | 31++++++++++++++++++++++---------
Mgui/kivy/uix/ui_screens/network.kv | 54++++++++++++++++++++++++++++++++++++------------------
3 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/gui/kivy/uix/dialogs/choice_dialog.py b/gui/kivy/uix/dialogs/choice_dialog.py @@ -53,9 +53,11 @@ class ChoiceDialog(Factory.Popup): for k, v in sorted(choices.items()): l = Label(text=v) l.height = '48dp' + l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' + cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py @@ -92,8 +92,8 @@ Builder.load_string(''' CardSeparator SettingsItem: status: root.network_status() - title: _('Network') + ': ' + self.status - description: _("Network status and server selection.") + title: _('Server') + ': ' + self.status + description: _("Select your history server.") action: partial(root.network_dialog, self) CardSeparator SettingsItem: @@ -236,18 +236,31 @@ class SettingsDialog(Factory.Popup): self._proxy_dialog.open() def network_dialog(self, item, dt): + host, port, protocol, proxy, auto_connect = self.app.network.get_parameters() + servers = self.app.network.get_servers() if self._network_dialog is None: - server, port, protocol, proxy, auto_connect = self.app.network.get_parameters() - def cb(popup): - server = popup.ids.host.text + def cb1(popup): + host = str(popup.ids.host.text) + port = str(popup.ids.port.text) auto_connect = popup.ids.auto_connect.active - self.app.network.set_parameters(server, port, protocol, proxy, auto_connect) + self.app.network.set_parameters(host, port, protocol, proxy, auto_connect) item.status = self.network_status() + def cb2(host): + from electrum.network import DEFAULT_PORTS + pp = servers.get(host, DEFAULT_PORTS) + port = pp.get(protocol, '') + popup.ids.host.text = host + popup.ids.port.text = port + def cb3(): + ChoiceDialog(_('Choose a server'), sorted(servers), popup.ids.host.text, cb2).open() popup = Builder.load_file('gui/kivy/uix/ui_screens/network.kv') - popup.ids.host.text = server - popup.ids.auto_connect.active = auto_connect - popup.on_dismiss = lambda: cb(popup) + popup.ids.chooser.on_release = cb3 + popup.on_dismiss = lambda: cb1(popup) self._network_dialog = popup + + self._network_dialog.ids.auto_connect.active = auto_connect + self._network_dialog.ids.host.text = host + self._network_dialog.ids.port.text = port self._network_dialog.open() def network_status(self): diff --git a/gui/kivy/uix/ui_screens/network.kv b/gui/kivy/uix/ui_screens/network.kv @@ -1,46 +1,64 @@ Popup: id: nd - title: _('Network') + title: _('Server') is_connected: app.network.is_connected() - server: app.network.interface.host BoxLayout: orientation: 'vertical' padding: '10dp' spacing: '10dp' TopLabel: - text: _("Connected to %s.")%root.server if root.is_connected else _("Not connected?") - Widget: - size_hint: 1, 0.1 - TopLabel: - text: _("Electrum retrieves your wallet information from a single server. In addition, it connects to a number of extra nodes, in order to fetch block headers. Block headers are used to verify the information sent by the address server, using Simple Payment Verification (SPV).") + text: _("Electrum retrieves your transaction history from a single server. The history is then checked against blockchain headers sent by other nodes, using Simple Payment Verification (SPV).") font_size: '6pt' Widget: - size_hint: 1, 0.1 + size_hint: 1, 0.8 GridLayout: - cols: 2 + cols: 3 Label: - text: _('Server') - Spinner: + height: '36dp' + size_hint_x: 1 + size_hint_y: None + text: _('Host') + ':' + TextInput: id: host - height: '48dp' + height: '36dp' + size_hint_x: 3 size_hint_y: None text: '' - values: sorted(app.network.get_servers()) + disabled: auto_connect.active + Button: + id: chooser + text:'v' + height: '36dp' + size_hint_x: 0.5 + size_hint_y: None disabled: auto_connect.active Label: - text: _('Auto-connect') - CheckBox: - id: auto_connect + height: '36dp' + size_hint_x: 1 + size_hint_y: None + text: _('Port') + ':' + TextInput: + id: port + input_type: 'number' + height: '36dp' + size_hint_x: 3 size_hint_y: None + text: '' + disabled: auto_connect.active Widget: size_hint: 1, 0.1 TopLabel: - text: _("If auto-connect is checked, the address server will be selected automatically.") + text: _("If auto-connect is checked, your history server will be selected automatically.") font_size: '6pt' + BoxLayout: + Label: + text: _('Auto-connect') + CheckBox: + id: auto_connect + size_hint_y: None Widget: size_hint: 1, 0.1 - BoxLayout: Widget: size_hint: 0.5, None