Gradience
Gradience copied to clipboard
bug: Preset color formatting & references not handled properly
Is there an existing issue for this?
- [X] I have searched the existing issues
What happened?
Most color presets include colors referenced by other colors or are not in the form of hexadecimal notation. I'm concerned plugins (and future ones) may expect hexadecimal notation in ~/.config/gtk-3.0
either/or ~/.config/gtk-4.0
and not handle other formats. Both plugins and Gradience cannot handle GTK color references.
GTK color references seem to be non standard and not work with Firefox GNOME Theme plugin. Color presets containing color references will have a label inserted instead of the intended color. This results in broken colors. Gradience will display color references as text only or completely transparent. When Gradience is restarted after applying the preset, toggling text values to affected colors will display #00000000
. Applying again seems to remove some variables from the CSS files, ruining them.
In Gradience To Qt Theme Converter, this python script expects only 6 digit hexadecimal notation. It errors on most presets because it does not have a practical module to handle other formats. If adding it as a plugin is planned ("plug: Qt Apps Integrator"), this issue would additionally need to be addressed.
To Reproduce
- Apply One Dark or Yaru Dark preset
Any others may work fine as well
Expected behavior
Both Gradience and plugins should be made to handle references and colors regardless of format. Gradience should display these problematic colors properly without being invisible
and also edit referenced colors properly. Gradience should also handle these colors after restarting the application.
OS
Fedora Linux 36 (Workstation Edition)
Version
0.3.1
Installation method
Flatpak from Flathub
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
The solution will be to only save as hexadecimal
I feel doing that would potentially lose features in the process. Gradience already saves colors with rgb(r,g,b) / rgba(r,g,b,a) formatting alongside hexadecimal. Using references is useful in organizing colors and having a minimal palette albeit Gradience has no idea how to use it. GTK does though. GTK supports color expressions, which Gradience could utilize for themes based on a single color. Currently, Gradience does not use GTK CSS to its full potential.
Gradience and plugins could benefit from an extra python module that finds colors from references in a file then converts colors from their various formats to hexadecimal. Webcolors 1.3 might be a good module as a starting point. I'm not familiar with python packages, so there might be better alternatives.
This issue has been partially fixed by PR https://github.com/GradienceTeam/Gradience/pull/694, and now, because of the issues with some presets in PR https://github.com/GradienceTeam/Gradience/pull/679, I'm creating a new helper function that will convert GTK color variables to proper color codes. Both of those helper functions will be available for plugins to use.