From d0ee367469529925cb48b0fdccc4703df53bb6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= <mailtrash@posteo.de> Date: Sun, 26 Jan 2020 14:40:08 +0100 Subject: [PATCH] Settings: Add color setting --- gajim/gtk/const.py | 1 + gajim/gtk/settings.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gajim/gtk/const.py b/gajim/gtk/const.py index bd6d240cd1..186603dafe 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 3ac81d3192..7bd2f21a2f 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__ = { -- GitLab