Settings: Add ComboSetting
This commit is contained in:
parent
c343746430
commit
e495617d3d
2 changed files with 29 additions and 0 deletions
|
@ -55,6 +55,7 @@ class SettingKind(IntEnum):
|
||||||
PRIORITY = 9
|
PRIORITY = 9
|
||||||
FILECHOOSER = 10
|
FILECHOOSER = 10
|
||||||
CHANGEPASSWORD = 11
|
CHANGEPASSWORD = 11
|
||||||
|
COMBO = 12
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
|
|
|
@ -97,6 +97,7 @@ class SettingsBox(Gtk.ListBox):
|
||||||
SettingKind.PRIORITY: PrioritySetting,
|
SettingKind.PRIORITY: PrioritySetting,
|
||||||
SettingKind.HOSTNAME: CutstomHostnameSetting,
|
SettingKind.HOSTNAME: CutstomHostnameSetting,
|
||||||
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
|
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
|
||||||
|
SettingKind.COMBO: ComboSetting,
|
||||||
}
|
}
|
||||||
|
|
||||||
if extend is not None:
|
if extend is not None:
|
||||||
|
@ -502,6 +503,33 @@ class LoginSetting(DialogSetting):
|
||||||
self.set_activatable(not anonym)
|
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):
|
class ProxyComboSetting(GenericSetting):
|
||||||
|
|
||||||
__gproperties__ = {
|
__gproperties__ = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue