diff --git a/gajim/gtk/const.py b/gajim/gtk/const.py index e91fb8093..afd478870 100644 --- a/gajim/gtk/const.py +++ b/gajim/gtk/const.py @@ -55,6 +55,7 @@ class SettingKind(IntEnum): PRIORITY = 9 FILECHOOSER = 10 CHANGEPASSWORD = 11 + COMBO = 12 @unique diff --git a/gajim/gtk/settings.py b/gajim/gtk/settings.py index 992094f54..ac568aa98 100644 --- a/gajim/gtk/settings.py +++ b/gajim/gtk/settings.py @@ -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__ = {