From b35e793a5dd52cc345747f531653270765454934 Mon Sep 17 00:00:00 2001 From: frosty Date: Mon, 17 Aug 2026 17:58:03 -0400 Subject: Begin work on colourable accounts in message list --- libdino/src/entity/settings.vala | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libdino/src/entity') diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index c71a8e57..1b533667 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -2,6 +2,8 @@ namespace Dino.Entities { public class Settings : Object { + public signal void account_color_changed(Account account, string color); + private Database db; public Settings.from_db(Database db) { @@ -110,6 +112,27 @@ public class Settings : Object { } + + public string get_account_color(Account account) { + string? setting = db.account_settings.get_value(account.id, "conversation-list-color"); + if (setting != null && setting.length > 0) { + return setting; + } + + uint8[] rgb = Xmpp.Xep.ConsistentColor.string_to_rgb(account.bare_jid.to_string()); + return "#%02x%02x%02x".printf(rgb[0], rgb[1], rgb[2]).up(); + } + + public void set_account_color(Account account, string color) { + if (color == get_account_color(account)) return; + + db.account_settings.upsert() + .value(db.account_settings.key, "conversation-list-color", true) + .value(db.account_settings.account_id, account.id, true) + .value(db.account_settings.value, color) + .perform(); + account_color_changed(account, color); + } } } -- cgit v1.3