Commit 3ba1b532 authored by Daniel Brötzmann's avatar Daniel Brötzmann

Avatars: Use css show colors

parent 06563efc
......@@ -28,12 +28,13 @@ from gajim.common import configpaths
from gajim.common.helpers import Singleton
from gajim.common.helpers import get_groupchat_name
from gajim.common.const import AvatarSize
from gajim.common.const import StyleAttr
from gajim.gtk.util import load_pixbuf
from gajim.gtk.util import text_to_color
from gajim.gtk.util import scale_with_ratio
from gajim.gtk.const import SHOW_COLORS
from gajim.gtk.util import get_css_show_class
from gajim.gtk.util import convert_rgb_string_to_float
log = logging.getLogger('gajim.gtk.avatar')
......@@ -108,7 +109,9 @@ def add_status_to_avatar(surface, show):
context.arc(width - clip_size, height - clip_size, clip_size, 0, 2 * pi)
context.fill()
color = SHOW_COLORS[show]
css_color = get_css_show_class(show)
color = convert_rgb_string_to_float(
app.css_config.get_value(css_color, StyleAttr.COLOR))
show_size = width / 6.5
show_radius = show_size * 0.80
context.set_source_rgb(*color)
......
......@@ -91,17 +91,6 @@ class ControlType(Enum):
return self.value
SHOW_COLORS = {
'online': (102/255, 191/255, 16/255),
'offline': (154/255, 154/255, 154/255),
'not in roster': (154/255, 154/255, 154/255),
'chat': (102/255, 191/255, 16/255),
'away': (255/255, 133/255, 51/255),
'dnd': (230/255, 46/255, 0),
'xa': (106/255, 0, 242/255)
}
WINDOW_MODULES = {
'AccountsWindow': 'gajim.gtk.accounts',
'HistorySyncAssistant': 'gajim.gtk.history_sync',
......
......@@ -444,6 +444,13 @@ def convert_rgb_to_hex(rgb_string: str) -> str:
return '#%02x%02x%02x' % (red, green, blue)
@lru_cache(maxsize=1024)
def convert_rgb_string_to_float(rgb_string: str) -> Tuple[float, float, float]:
rgba = Gdk.RGBA()
rgba.parse(rgb_string)
return (rgba.red, rgba.green, rgba.blue)
def get_monitor_scale_factor() -> int:
display = Gdk.Display.get_default()
monitor = display.get_primary_monitor()
......
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