Commit 1ebe0d0d authored by Daniel Brötzmann's avatar Daniel Brötzmann

Accounts: Add account colors

parent d0ee3674
......@@ -270,6 +270,7 @@ class Config:
'accounts': ({
'name': [opt_str, '', '', True],
'account_label': [opt_str, '', '', False],
'account_color': [opt_color, 'rgb(85, 85, 85)'],
'hostname': [opt_str, '', '', True],
'anonymous_auth': [opt_bool, False],
'avatar_sha': [opt_str, '', '', False],
......
......@@ -604,6 +604,10 @@ def __init__(self, account):
SettingType.ACCOUNT_CONFIG, 'account_label',
callback=self._on_account_name_change),
Setting(SettingKind.COLOR, _('Color'),
SettingType.ACCOUNT_CONFIG, 'account_color',
desc=_('Recognize your account by color')),
Setting(SettingKind.LOGIN, _('Login'), SettingType.DIALOG,
props={'dialog': LoginDialog}),
......
......@@ -646,6 +646,12 @@ def text_to_color(text):
return nbxmpp.util.text_to_color(text, background)
def get_color_for_account(account: str) -> str:
col_r, col_g, col_b = text_to_color(account)
rgba = Gdk.RGBA(red=col_r, green=col_g, blue=col_b)
return rgba.to_string()
def scale_with_ratio(size, width, height):
if height == width:
return size, size
......
......@@ -106,6 +106,7 @@
from gajim.gtk.util import open_window
from gajim.gtk.util import get_app_window
from gajim.gtk.util import get_app_windows
from gajim.gtk.util import get_color_for_account
from gajim.gtk.const import ControlType
......@@ -1669,6 +1670,8 @@ def create_account(account,
config['name'] = username
config['resource'] = 'gajim.%s' % helpers.get_random_string(8)
config['account_label'] = '%s@%s' % (username, domain)
config['account_color'] = get_color_for_account(
'%s@%s' % (username, domain))
config['hostname'] = domain
config['savepass'] = True
config['password'] = password
......
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