Commit e1ecb5a6 authored by Kirill Unitsaev's avatar Kirill Unitsaev

add accent-color-support patch

parent 4a41f3a9
--- a/src/settings.c 2026-01-29 15:52:59.169527923 +0300
+++ b/src/settings.c 2026-01-29 15:54:44.391646134 +0300
@@ -116,6 +116,50 @@
return g_variant_new_uint32 (hc ? 1 : 0);
}
+static GVariant *
+get_accent_color (void)
+{
+ SettingsBundle *bundle = g_hash_table_lookup (settings, "org.gnome.desktop.interface");
+ g_autofree char *accent = NULL;
+ double r, g, b;
+
+ if (!bundle || !g_settings_schema_has_key (bundle->schema, "accent-color"))
+ {
+ /* Default blue */
+ return g_variant_new ("(ddd)", 0.21, 0.52, 0.89);
+ }
+
+ accent = g_settings_get_string (bundle->settings, "accent-color");
+
+ /* Convert accent color name to RGB values
+ * These values match libadwaita's accent color definitions */
+ if (g_strcmp0 (accent, "blue") == 0)
+ { r = 0.21; g = 0.52; b = 0.89; }
+ else if (g_strcmp0 (accent, "teal") == 0)
+ { r = 0.13; g = 0.59; b = 0.53; }
+ else if (g_strcmp0 (accent, "green") == 0)
+ { r = 0.18; g = 0.62; b = 0.25; }
+ else if (g_strcmp0 (accent, "yellow") == 0)
+ { r = 0.90; g = 0.73; b = 0.00; }
+ else if (g_strcmp0 (accent, "orange") == 0)
+ { r = 0.90; g = 0.45; b = 0.00; }
+ else if (g_strcmp0 (accent, "red") == 0)
+ { r = 0.87; g = 0.16; b = 0.16; }
+ else if (g_strcmp0 (accent, "pink") == 0)
+ { r = 0.85; g = 0.27; b = 0.53; }
+ else if (g_strcmp0 (accent, "purple") == 0)
+ { r = 0.56; g = 0.25; b = 0.68; }
+ else if (g_strcmp0 (accent, "slate") == 0)
+ { r = 0.43; g = 0.43; b = 0.43; }
+ else
+ {
+ /* Default to blue for unknown values */
+ r = 0.21; g = 0.52; b = 0.89;
+ }
+
+ return g_variant_new ("(ddd)", r, g, b);
+}
+
static gboolean
settings_handle_read_all (XdpImplSettings *object,
GDBusMethodInvocation *invocation,
@@ -170,6 +214,7 @@
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert_value (&dict, "color-scheme", get_color_scheme ());
g_variant_dict_insert_value (&dict, "contrast", get_contrast_value ());
+ g_variant_dict_insert_value (&dict, "accent-color", get_accent_color ());
g_variant_builder_add (builder, "{s@a{sv}}", "org.freedesktop.appearance", g_variant_dict_end (&dict));
}
@@ -213,6 +258,12 @@
g_variant_new ("(v)", get_contrast_value ()));
return TRUE;
}
+ else if (strcmp (arg_key, "accent-color") == 0)
+ {
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(v)", get_accent_color ()));
+ return TRUE;
+ }
}
else if (strcmp (arg_namespace, "org.gnome.desktop.interface") == 0 &&
strcmp (arg_key, "enable-animations") == 0)
@@ -294,6 +345,11 @@
"contrast",
g_variant_new ("v", g_variant_new_uint32 (hc ? 1 : 0)));
}
+ if (strcmp (user_data->namespace, "org.gnome.desktop.interface") == 0 &&
+ strcmp (key, "accent-color") == 0)
+ xdp_impl_settings_emit_setting_changed (user_data->self,
+ "org.freedesktop.appearance", key,
+ g_variant_new ("v", get_accent_color ()));
}
static void
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