Can someone write down a recipe how I could use my own symbolic icons as part of a theme? My goal is to use icons, that adapt to theme coloring (dark / light).
glib-compile-resourcesto generate a
<?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/org/gjiten/"> <file>data/aaaa-symbolic.svg</file> </gresource> </gresources>
- successfully load and show the svg as icon:
ress = resources_get_resource (); g_resources_register (ress); GtkWidget * icon = gtk_image_new_from_resource ("/org/gjiten/data/aaaa-symbolic.svg");
But this will not load the icon as part of the theme; Therefore the icon will not be theme-aware.
Instead of using
gtk_image_new_from_resource, I tried the following to make the icon part of the theme:
GtkIconTheme * theme = gtk_icon_theme_get_default (); gtk_icon_theme_add_resource_path (theme, "/org/gjiten/data"); // check if icon is available gtk_icon_theme_has_icon (theme, "aaaa"); // make icon usable on UI icon = gtk_image_new_from_icon_name ("aaaa",32); // or something like this: GtkIconInfo * icon_info = gtk_icon_theme_lookup_icon (theme,"aaaa", 32 ,GTK_ICON_LOOKUP_FORCE_SYMBOLIC); GdkPixbuf * pixbuf = gtk_icon_info_load_icon (icon_info, NULL); icon = gtk_image_new_from_pixbuf (pixbuf);
gtk_icon_theme_has_iconwill always return
gtk_image_new_from_icon_namecan’t find the image
Can someone tell me what I am doing wrong?
- GResources: GResource: GIO Reference Manual
- Symbolic icons: Themed Icons - GNOME Developer Documentation documentation