Replace make_color_string() by Gdk.RGBA method

This commit is contained in:
André Apitzsch 2017-10-07 17:03:31 +02:00
parent 372c1f9941
commit c758da1123
4 changed files with 6 additions and 19 deletions

View File

@ -50,7 +50,7 @@ class Option(IntEnum):
opt_int = [ 'integer', 0 ]
opt_str = [ 'string', 0 ]
opt_bool = [ 'boolean', 0 ]
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()|rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,[01]\.?\d*\)$' ]
opt_one_window_types = ['never', 'always', 'always_with_roster', 'peracct', 'pertype']
opt_show_roster_on_startup = ['always', 'never', 'last_state']
opt_treat_incoming_messages = ['', 'chat', 'normal']

View File

@ -849,7 +849,7 @@ class PreferencesWindow:
def on_preference_widget_color_set(self, widget, text):
color = widget.get_color()
color_string = gtkgui_helpers.make_color_string(color)
color_string = color.to_string()
app.config.set(text, color_string)
self.update_text_tags()
@ -946,8 +946,8 @@ class PreferencesWindow:
Set color value in prefs and update the UI
"""
if state:
color = self.xml.get_object(widget_name).get_color()
color_string = gtkgui_helpers.make_color_string(color)
color = self.xml.get_object(widget_name).get_rgba()
color_string = color.to_string()
else:
color_string = ''
app.config.set(option, color_string)

View File

@ -285,8 +285,8 @@ class GajimThemesWindow:
Set color value in prefs and update the UI
"""
if state:
color = widget.get_color()
color_string = gtkgui_helpers.make_color_string(color)
color = widget.get_rgba()
color_string = color.to_string()
else:
color_string = ''
begin_option = ''

View File

@ -541,19 +541,6 @@ def make_gtk_month_python_month(month):
def make_python_month_gtk_month(month):
return month - 1
def make_color_string(color):
"""
Create #aabbcc color string from gtk color
"""
col = '#'
for i in ('red', 'green', 'blue'):
h = hex(int(getattr(color, i) / (16*16)))
h = h.split('x')[1]
if len(h) == 1:
h = '0' + h
col += h
return col
def make_pixbuf_grayscale(pixbuf):
pixbuf2 = pixbuf.copy()
pixbuf.saturate_and_pixelate(pixbuf2, 0.0, False)