In Stack Overflow, you can add your questions and answers. Well, I had been searching for a long time for this issue, and I’m sure the information is available somewhere, but I failed to find the sources I needed, neither did I did find the error message mentioned anywhere else, so I’m going to describe much of the search here, which is irrelevant for the specific question that still remains, but perhaps helpful for those who are looking for help here. (Feel free to add more clarity on comments in the details.)
I tried many things to use a custom library-icon, but none of the attempts seems to work. I get the following output when running my application:
[1/5] Generating src/clavier-resources_h with a custom command
FAILED: src/clavier-resources.h
/usr/bin/glib-compile-resources ../../../../../../../../../Projets/Clavier/src/clavier.gresource.xml --sourcedir ../../../../../../../../../Projets/Clavier/src --c-name clavier --internal --generate --target src/clavier-resources.h
../../../../../../../../../Projets/Clavier/src/clavier.gresource.xml: Failed to locate “library-symbolic.svg” in any source directory.
[2/5] Generating src/clavier-resources_c with a custom command
FAILED: src/clavier-resources.c
/usr/bin/glib-compile-resources ../../../../../../../../../Projets/Clavier/src/clavier.gresource.xml --sourcedir ../../../../../../../../../Projets/Clavier/src --c-name clavier --internal --generate --target src/clavier-resources.c --dependency-file src/clavier-resources.c.d
../../../../../../../../../Projets/Clavier/src/clavier.gresource.xml: Failed to locate “library-symbolic.svg” in any source directory.
ninja: build stopped: subcommand failed.
I have no clue what to do about it, neither do I find any sources online of people encountering this issue. Yes, I see it doesn’t find my custom library-symbolic.svg
file, but I don’t understand why. I included it in ./data/icons
, ./icons
, .
, ./icons/scalable/actions
. None of it works. The only thing I can do to get rid of this error is including directly it under ./src
. The gresources file looked like this at the time.
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/codeberg/vendillah/Clavier">
<file preprocess="xml-stripblanks">gtk/main-window.ui</file>
<!-- other ui files -->
</gresource>
<gresource prefix="/org/codeberg/vendillah/Clavier/icons">
<file preprocess="xml-stripblanks">library-symbolic.svg</file>
</gresource>
It was a random attempt to put it in the same folder as the gresource file like Epiphany does, and that worked, apparently. This most probably means that the files should be referenced relative to the gresources file.
I did read the documentation about themed icons and don’t see what I’m doing differently. All I learned is that I should use Gtk.IconTheme.get_for_display
apparently, afterwards? Why exactly? Anyway, I did include the following lines in my application class
var theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ());
theme.add_resource_path (".");
and it expectedly, it didn’t change the output I got before, only after I got it running, of course. It resulted in the following lines:
(process:2): Gtk-CRITICAL **: 22:26:29.440: gtk_icon_theme_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(process:2): Gtk-CRITICAL **: 22:26:29.441: gtk_icon_theme_add_resource_path: assertion 'GTK_IS_ICON_THEME (self)' failed
The documentation from ElementaryOS about it got me confused, as it tells me I should have the icons in ./data
, but it uses a prefix=".../com/icons"
(thus, it’s not even reading from data - is the prefix a path at all??).
I actually followed the tutorial by the Icon Library app, which is misleading as from looking there, I get the sense I only have to save the library file under ./data/icons
and add it to my gresource, but that didn’t work without hours of searching and trying.
The end result of what I tried is that the library icon is black in dark mode (i.e. always black). I downloaded the svg from previously mentioned icon library app. Shouldn’t it be colored as it’s a symbolic icon? How can I have the icon be displayed as a white one when dark mode is enabled?