Commit d0ee3674 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Settings: Add color setting

parent 24d89658
......@@ -58,6 +58,7 @@ class SettingKind(IntEnum):
CHANGEPASSWORD = 11
COMBO = 12
CHATSTATE_COMBO = 13
COLOR = 14
@unique
......
......@@ -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,
......@@ -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__ = {
......
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