diff --git a/gui/kivy/uix/dialogs/choice_dialog.py b/gui/kivy/uix/dialogs/choice_dialog.py index 204373f5..dc595abd 100644 --- 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 index cf42df4a..e115f775 100644 --- 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 index 3c6fe9e6..939c1669 100644 --- a/gui/kivy/uix/ui_screens/network.kv +++ b/gui/kivy/uix/ui_screens/network.kv @@ -1,33 +1,57 @@ 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?") + 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.8 + GridLayout: + cols: 3 + Label: + height: '36dp' + size_hint_x: 1 + size_hint_y: None + text: _('Host') + ':' + TextInput: + id: host + height: '36dp' + size_hint_x: 3 + size_hint_y: None + text: '' + 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: + 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: _("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: _("If auto-connect is checked, your history server will be selected automatically.") font_size: '6pt' - Widget: - size_hint: 1, 0.1 - GridLayout: - cols: 2 - Label: - text: _('Server') - Spinner: - id: host - height: '48dp' - size_hint_y: None - text: '' - values: sorted(app.network.get_servers()) - disabled: auto_connect.active + BoxLayout: Label: text: _('Auto-connect') CheckBox: @@ -35,12 +59,6 @@ Popup: size_hint_y: None Widget: size_hint: 1, 0.1 - TopLabel: - text: _("If auto-connect is checked, the address server will be selected automatically.") - font_size: '6pt' - Widget: - size_hint: 1, 0.1 - BoxLayout: Widget: size_hint: 0.5, None