diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-08-17 17:58:03 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-08-17 17:58:03 -0400 |
| commit | b35e793a5dd52cc345747f531653270765454934 (patch) | |
| tree | 843022cb45dd33c94c750bbee27b89f3d474d558 /libdino | |
| parent | f9e3b8ba7da220746151179ed10a90c2ac215ffc (diff) | |
Begin work on colourable accounts in message list
Diffstat (limited to 'libdino')
| -rw-r--r-- | libdino/src/entity/settings.vala | 23 |
1 files changed, 23 insertions, 0 deletions
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); + } } } |
