Search code examples
cwindowsgtkcross-platformgtk3

Gtk+ icon missing when running in MS Windows


I have a C/GTK+ application developed on Ubuntu, and I want to cross-compile it so that it runs on MS Windows.

I followed this guide to set up the compiler, and the program was compiled successfully, and it runs on MS Windows.

However, the icons on a Search Entry were missing.

This is what I get when I'm on Ubuntu:

enter image description here

This is what I get when I run the program in MS Windows (or Wine):

enter image description here

In addition, the terminal shows the following:

(main.exe:8): Gtk-WARNING **: Could not find the icon 'edit-find-symbolic'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
    http://icon-theme.freedesktop.org/releases

Question: Is it possible to have the icons showing up in Windows, without the need to install anything on the Windows box? My application aims at being able to run from a USB flash drive without installing anything.

The relevant part of the Glade file I used to create the application, in case it's useful:

          <object class="GtkSearchEntry" id="searchentry1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="primary_icon_name">edit-find-symbolic</property>
            <property name="primary_icon_activatable">False</property>
            <property name="primary_icon_sensitive">False</property>
          </object>

Things I've tried so far: copying edit-find-symbolic.svg to the directory containing main.exe (i.e. together with the dlls); copying the whole directory /usr/share/icons/gnome there. None of these worked.


Update:

In the directory containing main.exe I added a subdirectory share, and in it another subdirectory icons. I placed edit-find-symbolic.svg in this subdirectory. The search icon still looks the same (doesn't work), but the terminal output this time is different:

(main.exe:8): GLib-GIO-CRITICAL **: g_loadable_icon_load: assertion `G_IS_LOADABLE_ICON (icon)' failed

If edit-find-symbolic.svg is not present in this folder, but a folder named hicolor is present, the icon still doesn't work, and this time there isn't any output in the terminal at all.


Solution

  • This is a late reply but I encountered this issue and I have solved it with the following steps:

    SVG icons of the default theme (adwaita) needs to be copyed to a share directory relative to the bin directory bin../share/icons/Adwaita/scalable/* also bin../share/icons/Adwaita/icon-theme.cache and bin../share/icons/Adwaita/index.theme

    After several test, it appears that the following files are also required:

    lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.dll
    lib/gdk-pixbuf-2.0/2.10.0/loaders/loaders.cache
    

    The first line of this loaders.cache file also needs to be edited to "../lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.dll"

    The file tree looks like this:

    bin/gtkapplication.exe
    bin/*.dll
    share/loader.cache
    share/glib-2.0/gschemas.compiled
    share/icons/Adwaita/scalable/*
    share/icons/Adwaita/icon-theme.cache
    share/icons/Adwaita/index.theme
    lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.dll
    lib/gdk-pixbuf-2.0/2.10.0/loaders/loaders.cache
    

    Most up-to-date repository containing GTK+3 Runtime files for Windows (as of 5-23-2019): https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer