Background
My application uses custom icons (pixbuf) on buttons. When the theme is a bright theme, everything looks fine, but when the theme is a dark theme, the icons are pretty useless.
Question
Is there a possibility to tell my application to use a different set of icons depending of the theme is bright or dark?
Perhaps by proper naming, like myicon.png and myicon-dark.png?
Are there any proper means (not hacks) to decide if the theme is dark or light?
OT
Is there anything in the making in this direction(theme brightness-sensing or even automatic application)?
I could imagine this could be a really helpful feature given the current rise of night/dark modes and the distribution of users of light and night themes.
I tried gtk_image_new_from_gicon (g_file_icon_new ( g_file_new_for_path (PIXMAPDIR"/myicon-symbolic.svg")), 32);, but it does not adapt colors. The svg is a black-white image.
Not sure if it works in gtk but I fixed this color problem on a gnome shell extension manually removing all color information from the svg file. After that it followed the fg/bg colors from the system style.
The svg itās ākind ofā a XML file, you can edit it in gedit (or any other text editor).
@ebassi I tried to use gtk_icon_theme_add_resource_path and gtk_image_new_from_icon_name, but I couldnāt even get the icon to show (see below). If thereās any more information on how to get things done, Iād appreciate links.
@PerryWerneck
Very nice trick! Worked for me as well!
However, as ebassi and baedert didnāt point this out, I guess itās rather a bug, than a feature and might be removed later? (maybe a comment from the devs here?)