diff --git a/gajim/common/config.py b/gajim/common/config.py index 63ead1963f0c54b7cd0847ea096340bfe03fab60..92c9a96c8842d1efda38ffff3d98dda9c10ee1d5 100644 --- a/gajim/common/config.py +++ b/gajim/common/config.py @@ -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?')], diff --git a/gajim/data/style/default.css b/gajim/data/style/default.css index f7f89098185ca49e99d42bd3fb9fef7239d9cc54..5d4606143fc66661e6755e427fcd7bc6e4996298 100644 --- a/gajim/data/style/default.css +++ b/gajim/data/style/default.css @@ -77,3 +77,15 @@ .gajim-notify-ft-complete { .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); +} diff --git a/gajim/gtk/tooltips.py b/gajim/gtk/tooltips.py index 8e7165c36d501b9b77ac44dddfbb15fdc8983a92..8fcd58de7db7382efee28c27ffb31634db28f007 100644 --- a/gajim/gtk/tooltips.py +++ b/gajim/gtk/tooltips.py @@ -39,6 +39,7 @@ 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_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 @@ def _populate_grid(self, contact): # 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 @@ def _set_idle_time(self, contact): 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 @@ def _get_current_status(file_props): 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-') diff --git a/gajim/gtk/util.py b/gajim/gtk/util.py index 5480a01821f403707dfa2bce0c3764e37bbd06f0..0f7d1e0c339a3b8d84752e0fb35c78bcc1b70470 100644 --- a/gajim/gtk/util.py +++ b/gajim/gtk/util.py @@ -28,6 +28,7 @@ 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