diff --git a/gajim/gtk/const.py b/gajim/gtk/const.py index bd6d240cd106e3cc4e75d278b230bb4991feb91c..186603dafec05e03925a833aa7bd4ab64114e650 100644 --- a/gajim/gtk/const.py +++ b/gajim/gtk/const.py @@ -58,6 +58,7 @@ class SettingKind(IntEnum): CHANGEPASSWORD = 11 COMBO = 12 CHATSTATE_COMBO = 13 + COLOR = 14 @unique diff --git a/gajim/gtk/settings.py b/gajim/gtk/settings.py index 3ac81d31929d788d437990b3cd53eea520361322..7bd2f21a2f476fca84117df6ad3204a21e6b5550 100644 --- a/gajim/gtk/settings.py +++ b/gajim/gtk/settings.py @@ -88,6 +88,7 @@ def __init__(self, account, extend=None): SettingKind.SPIN: SpinSetting, SettingKind.DIALOG: DialogSetting, SettingKind.ENTRY: EntrySetting, + SettingKind.COLOR: ColorSetting, SettingKind.ACTION: ActionSetting, SettingKind.LOGIN: LoginSetting, SettingKind.FILECHOOSER: FileChooserSetting, @@ -98,7 +99,7 @@ def __init__(self, account, extend=None): SettingKind.CHANGEPASSWORD: ChangePasswordSetting, SettingKind.COMBO: ComboSetting, SettingKind.CHATSTATE_COMBO: ChatstateComboSetting, - } + } if extend is not None: for setting, callback in extend: @@ -336,6 +337,36 @@ def on_row_activated(self): self.entry.grab_focus() +class ColorSetting(GenericSetting): + + __gproperties__ = { + "setting-value": (str, 'Color Value', '', '', + GObject.ParamFlags.READWRITE), + } + + def __init__(self, *args): + GenericSetting.__init__(self, *args) + + rgba = Gdk.RGBA() + rgba.parse(self.setting_value) + self.color_button = Gtk.ColorButton() + self.color_button.set_rgba(rgba) + self.color_button.connect('color-set', self.on_color_set) + self.color_button.set_valign(Gtk.Align.CENTER) + self.color_button.set_halign(Gtk.Align.END) + + self.setting_box.pack_end(self.color_button, True, True, 0) + + self.show_all() + + def on_color_set(self, button): + rgba = button.get_rgba() + self.set_value(rgba.to_string()) + + def on_row_activated(self): + self.color_button.grab_focus() + + class DialogSetting(GenericSetting): __gproperties__ = {