Commit 2e1252c4 authored by Philipp Hörist's avatar Philipp Hörist

Accounts: Replace ProxyComboSetting with PopoverSetting

parent a3d92681
Pipeline #6263 passed with stages
in 4 minutes and 27 seconds
......@@ -212,7 +212,7 @@ class Settings(Gtk.ScrolledWindow):
for page in self._pages[account]:
if page.name != 'connection':
continue
page.listbox.get_setting('proxy').update_values()
page.update_proxy_entries()
class AccountMenu(Gtk.Box):
......@@ -690,8 +690,11 @@ class ConnectionPage(GenericSettingPage):
def __init__(self, account):
settings = [
Setting(SettingKind.PROXY, _('Proxy'),
SettingType.ACCOUNT_CONFIG, 'proxy', name='proxy'),
Setting(SettingKind.POPOVER, _('Proxy'),
SettingType.ACCOUNT_CONFIG, 'proxy', name='proxy',
props={'entries': self._get_proxies(),
'button-icon-name': 'preferences-system-symbolic',
'button-callback': self._on_proxy_edit}),
Setting(SettingKind.HOSTNAME, _('Hostname'), SettingType.DIALOG,
desc=_('Manually set the hostname for the server'),
......@@ -715,6 +718,20 @@ class ConnectionPage(GenericSettingPage):
]
GenericSettingPage.__init__(self, account, settings)
@staticmethod
def _get_proxies():
proxies = {'': _('No Proxy')}
for proxy in app.settings.get_proxies():
proxies[proxy] = proxy
return proxies
@staticmethod
def _on_proxy_edit(*args):
open_window('ManageProxies')
def update_proxy_entries(self):
self.listbox.get_setting('proxy').update_entries(self._get_proxies())
class AdvancedPage(GenericSettingPage):
......
......@@ -51,7 +51,6 @@ class SettingKind(IntEnum):
LOGIN = 4
DIALOG = 5
CALLBACK = 6
PROXY = 7
HOSTNAME = 8
PRIORITY = 9
FILECHOOSER = 10
......
......@@ -88,7 +88,6 @@ class SettingsBox(Gtk.ListBox):
SettingKind.LOGIN: LoginSetting,
SettingKind.FILECHOOSER: FileChooserSetting,
SettingKind.CALLBACK: CallbackSetting,
SettingKind.PROXY: ProxyComboSetting,
SettingKind.PRIORITY: PrioritySetting,
SettingKind.HOSTNAME: CutstomHostnameSetting,
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
......@@ -654,56 +653,6 @@ class ComboSetting(GenericSetting):
pass
class ProxyComboSetting(GenericSetting):
def __init__(self, *args):
GenericSetting.__init__(self, *args)
self.combo = MaxWidthComboBoxText()
self.combo.set_valign(Gtk.Align.CENTER)
self._signal_id = None
self.update_values()
button = get_image_button(
'preferences-system-symbolic', _('Manage Proxies'))
button.set_action_name('app.manage-proxies')
button.set_valign(Gtk.Align.CENTER)
self.setting_box.pack_start(self.combo, True, True, 0)
self.setting_box.pack_start(button, False, True, 0)
self.show_all()
def _block_signal(self, state):
if state:
if self._signal_id is None:
return
self.combo.disconnect(self._signal_id)
else:
self._signal_id = self.combo.connect('changed',
self.on_value_change)
self.combo.emit('changed')
def update_values(self):
self._block_signal(True)
proxies = app.settings.get_proxies()
proxies.insert(0, _('No Proxy'))
self.combo.remove_all()
for index, value in enumerate(proxies):
self.combo.insert_text(-1, value)
if value == self.setting_value or index == 0:
self.combo.set_active(index)
self._block_signal(False)
def on_value_change(self, combo):
if combo.get_active() == 0:
self.set_value('')
else:
self.set_value(combo.get_active_text())
def on_row_activated(self):
pass
class PrioritySetting(DialogSetting):
def __init__(self, *args, **kwargs):
DialogSetting.__init__(self, *args, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment