Commit 06563efc authored by Daniel Brötzmann's avatar Daniel Brötzmann

Tooltips: Use css colors

parent 62fd32e3
......@@ -174,12 +174,6 @@ class Config:
'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')],
'tabs_border': [opt_bool, False, _('Show tabbed notebook border in chat windows?')],
'tabs_close_button': [opt_bool, True, _('Show close button in tab?')],
'tooltip_status_online_color': [opt_color, '#73D216'],
'tooltip_status_free_for_chat_color': [opt_color, '#3465A4'],
'tooltip_status_away_color': [opt_color, '#EDD400'],
'tooltip_status_busy_color': [opt_color, '#F57900'],
'tooltip_status_na_color': [opt_color, '#CC0000'],
'tooltip_status_offline_color': [opt_color, '#555753'],
'tooltip_account_name_color': [opt_color, '#888A85'],
'tooltip_idle_color': [opt_color, '#888A85'],
'notification_preview_message': [opt_bool, True, _('Preview new messages in notification popup?')],
......
......@@ -77,3 +77,15 @@
.gajim-notify-other {
color: rgb(255, 255, 255);
}
.gajim-status-online {
color: rgb(102, 191, 16);
}
.gajim-status-away {
color: rgb(255, 133, 51);
}
.gajim-status-dnd {
color: rgb(230, 46, 0);
}
.gajim-status-offline {
color: rgb(154, 154, 154);
}
......@@ -39,6 +39,7 @@ from gajim.common.const import AvatarSize
from gajim.common.const import PEPEventType
from gajim.common.i18n import Q_
from gajim.common.i18n import _
from gajim.gtkgui_helpers import add_css_class
from gajim.gtk.util import get_builder
from gajim.gtk.util import get_icon_name
......@@ -46,6 +47,7 @@ from gajim.gtk.util import format_mood
from gajim.gtk.util import format_activity
from gajim.gtk.util import format_tune
from gajim.gtk.util import format_location
from gajim.gtk.util import get_css_show_class
log = logging.getLogger('gajim.gtk.tooltips')
......@@ -206,7 +208,8 @@ class GCTooltip():
# Status
show = helpers.get_uf_show(contact.show.value)
self._ui.user_show.set_markup(colorize_status(show))
self._ui.user_show.set_text(show)
colorize_status(self._ui.user_show, contact.show)
self._ui.user_show.show()
# JID
......@@ -487,7 +490,8 @@ class RosterTooltip(StatusTable):
else:
show = _('Disconnected')
self._ui.user_show.set_markup(colorize_status(show))
colorize_status(self._ui.user_show, contact.show)
self._ui.user_show.set_text(show)
self._ui.user_show.show()
@staticmethod
......@@ -605,25 +609,9 @@ class FileTransfersTooltip():
return Q_('?transfer status:Not started')
def colorize_status(status):
def colorize_status(widget, show):
"""
Colorize the status message inside the tooltip by it's
semantics. Color palette is the Tango.
Colorize the status message inside the tooltip by it's semantics.
"""
formatted = "<span foreground='%s'>%s</span>"
color = None
if status.startswith(Q_("?user status:Available")):
color = app.config.get('tooltip_status_online_color')
elif status.startswith(_("Free for Chat")):
color = app.config.get('tooltip_status_free_for_chat_color')
elif status.startswith(_("Away")):
color = app.config.get('tooltip_status_away_color')
elif status.startswith(_("Busy")):
color = app.config.get('tooltip_status_busy_color')
elif status.startswith(_("Not Available")):
color = app.config.get('tooltip_status_na_color')
elif status.startswith(_("Offline")):
color = app.config.get('tooltip_status_offline_color')
if color:
status = formatted % (color, status)
return status
css_class = get_css_show_class(show)[14:]
add_css_class(widget, css_class, prefix='gajim-status-')
......@@ -28,6 +28,7 @@ from importlib import import_module
import xml.etree.ElementTree as ET
from pathlib import Path
from functools import wraps
from functools import lru_cache
try:
from PIL import Image
......@@ -652,6 +653,18 @@ def get_color_for_account(account: str) -> str:
return rgba.to_string()
@lru_cache(maxsize=16)
def get_css_show_class(show):
if show in ('online', 'chat'):
return '.gajim-status-online'
if show in ('away', 'xa'):
return '.gajim-status-away'
if show == 'dnd':
return '.gajim-status-dnd'
# 'offline', 'not in roster', 'requested'
return '.gajim-status-offline'
def scale_with_ratio(size, width, height):
if height == width:
return size, size
......
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