fix(gtk): bypass fragile SVG recoloring with static palette assets
Some checks failed
Check / eval (push) Failing after 1m22s

GTK's -gtk-recolor proved too fragile across different contexts, failing
to substitute the foreground color even when the SVG path used #000000.
Instead, we now generate two statically colored SVGs (normal + hover)
directly from the Nix palette hex codes, bypassing GTK's SVG recoloring
engine entirely.
This commit is contained in:
2026-07-11 20:54:28 +01:00
parent ebfd344390
commit 40d5a0a925

View File

@@ -43,9 +43,14 @@ let
# Connections" opens a submenu). Same trick adw-gtk3 uses for its # Connections" opens a submenu). Same trick adw-gtk3 uses for its
# check marks: a bundled asset via -gtk-recolor(url(…)), immune to # check marks: a bundled asset via -gtk-recolor(url(…)), immune to
# icon-pack coverage. Shape traced from Adwaita's pan-end-symbolic. # icon-pack coverage. Shape traced from Adwaita's pan-end-symbolic.
panEndSvg = pkgs.writeText "nomarchy-pan-end-symbolic.svg" '' panEndSvg = pkgs.writeText "nomarchy-pan-end.svg" ''
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#000000" d="M 6 4 L 10 8 L 6 12 Z"/> <path fill="#${base16.base05}" d="M 6 4 L 10 8 L 6 12 Z"/>
</svg>
'';
panEndHoverSvg = pkgs.writeText "nomarchy-pan-end-hover.svg" ''
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#${base16.base00}" d="M 6 4 L 10 8 L 6 12 Z"/>
</svg> </svg>
''; '';
in in
@@ -80,19 +85,28 @@ in
menu menuitem:disabled, .menu menuitem:disabled { menu menuitem:disabled, .menu menuitem:disabled {
color: #${base16.base03}; color: #${base16.base03};
} }
/* Submenu disclosure arrows bundled asset, NOT an icon-theme /* Submenu disclosure arrows bundled assets, NOT an icon-theme
lookup: pan-end-symbolic is missing from Papirus and its lookup: pan-end-symbolic is missing from Papirus and its
broken inheritance chain, so -gtk-icontheme() drew nothing. */ broken inheritance chain, so -gtk-icontheme() drew nothing.
menu menuitem arrow, .menu menuitem arrow, Hard-tinted directly from the palette to bypass GTK's fragile
menu menuitem:hover arrow, menu menuitem:selected arrow { -gtk-recolor behavior. */
menu menuitem arrow:dir(ltr), .menu menuitem arrow:dir(ltr),
menu menuitem arrow:dir(rtl), .menu menuitem arrow:dir(rtl),
menu menuitem:hover arrow:dir(ltr), menu menuitem:selected arrow:dir(ltr),
menu menuitem:hover arrow:dir(rtl), menu menuitem:selected arrow:dir(rtl) {
min-width: 16px; min-width: 16px;
min-height: 16px; min-height: 16px;
margin-left: 8px; margin-left: 8px;
color: inherit; color: inherit;
-gtk-icon-source: -gtk-recolor(url("${panEndSvg}"));
} }
menu menuitem:hover arrow, menu menuitem:selected arrow { menu menuitem arrow:dir(ltr), .menu menuitem arrow:dir(ltr),
menu menuitem arrow:dir(rtl), .menu menuitem arrow:dir(rtl) {
-gtk-icon-source: url("file://${panEndSvg}");
}
menu menuitem:hover arrow:dir(ltr), menu menuitem:selected arrow:dir(ltr),
menu menuitem:hover arrow:dir(rtl), menu menuitem:selected arrow:dir(rtl) {
color: #${base16.base00}; color: #${base16.base00};
-gtk-icon-source: url("file://${panEndHoverSvg}");
} }
check, radio { check, radio {
min-width: 14px; min-width: 14px;