Commit e495617d authored by Philipp Hörist's avatar Philipp Hörist

Settings: Add ComboSetting

parent c3437464
......@@ -55,6 +55,7 @@ class SettingKind(IntEnum):
PRIORITY = 9
FILECHOOSER = 10
CHANGEPASSWORD = 11
COMBO = 12
@unique
......
......@@ -97,6 +97,7 @@ class SettingsBox(Gtk.ListBox):
SettingKind.PRIORITY: PrioritySetting,
SettingKind.HOSTNAME: CutstomHostnameSetting,
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
SettingKind.COMBO: ComboSetting,
}
if extend is not None:
......@@ -502,6 +503,33 @@ class LoginSetting(DialogSetting):
self.set_activatable(not anonym)
class ComboSetting(GenericSetting):
__gproperties__ = {
"setting-value": (str, 'Proxy', '', '',
GObject.ParamFlags.READWRITE),}
def __init__(self, *args, combo_items):
GenericSetting.__init__(self, *args)
self.combo = Gtk.ComboBoxText()
self.combo.set_valign(Gtk.Align.CENTER)
text_renderer = self.combo.get_cells()[0]
text_renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
for index, value in enumerate(combo_items):
self.combo.append(value, _(value))
if value == self.setting_value or index == 0:
self.combo.set_active(index)
self.combo.connect('changed', self.on_value_change)
self.setting_box.pack_start(self.combo, True, True, 0)
self.show_all()
def on_value_change(self, combo):
self.set_value(combo.get_active_id())
class ProxyComboSetting(GenericSetting):
__gproperties__ = {
......
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