Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theme and Icons Problem with GTK3 Installed with vcpkg

I am using Visual Studio 2019 on Windows 10 and am trying to use GTK in C++ and installed it using vcpkg.

I've installed GTK using vcpkg according to the guide from GTK. I'm using Visual Studio 2019 and it is able to compile and run the example program here, but there is an issue regarding the theme and icons. According to the installation guide, under the section Building and distributing your application there are some things that must be done to get themes and icons to work.

I've started by downloading the Windows theme the guide suggests and have it in a share directory and then I've created a settings.ini file in an etc directory. It says to place this in the "install directory", which I assume is where Visual Studio is placing the exe for the program. I've tried it in both build and release, in the source files, in the top project directory - all with no success (and I did make sure it is targeting x64).

Just in case I also tried placing these where vcpkg is installed as well as where vcpkg installs gtk. No luck. When the program runs I get the warning

(gtkExample0.exe:16772): Gtk-WARNING **: Could not find the icon 'window-minimize-symbolic-ltr'. 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

So it seems that it is never finding the ssettings.ini file telling it to use the Windows 10 theme. Has anyone had any luck with getting this to work (both from VS2019 debugging runs and in deployment)?


To summarize the files:

share\themes\Windows10\gtk-3.0\gtk-3.20\ (downloaded from suggested GitHub repo)

etc\settings.ini contains:

[Settings]
gtk-theme-name=Windows10
gtk-font-name=Segoe UI 9

I've placed these in

<VS2019Project>\x64\Release,

<VS2019Project>\x64\Debug,

C:<path_to_vcpkg>\vcpkg\packages\gtk_x64-windows,

C:<path_to_vcpkg>\vcpkg\installed\x64-windows

All with no change when running from VS2019 under Release or Debug.

like image 221
ufoxDan Avatar asked Dec 13 '19 00:12

ufoxDan


1 Answers

Theme and icons considered as external resources are not distributed by vcpkg, and the instructions given in the distribution guide from GTK regarding where these resources should be layout on windows 10 are not crystal clear. The problem has also been reported here vcpkg issue#4417.

The solution proposed hereunder is to install all the resources in the <VS2019Project>\x64\Release directory of your VS project where your .exe application lives [This is a local solution the problem. A global approach should consider the setting of some user-defined free desktop environment variables which is not discussed here]. Icons can be picked from an ancillary MSYS2 distribution and the theme as indicated in the GTK Guide. The solution should be replicated for the Debug branch.

  1. Supposing you have MSYS2, install mingw-w64-x86_64-adwaita-icon-theme package with the pacman package manager if not already done on your MSYS2 installation pacman -Syu mingw-w64-x86_64-adwaita-icon-theme.

  2. Copy C:\msys64\mingw64\share\icons to <VS2019Project>\x64\Release\share\icons you should get both hicolor and Adwaita icons as subdirectories of your target dir.

  3. Copy the theme resources downloaded in the source gtk-3.20 directory directly into <VS2019Project>\x64\Release\share\themes\Windows10\gtk-3.0\. Do not locate these resources into a gtk-3.20 subfolder: to understand why consult this article Theme Location [assuming here that no global desktop environment variable has been set].

  4. Create a <VS2019Project>\x64\Release\etc\gtk-3.0 directory, put your settings.ini into it.

  5. Recompile and you should obtain a windows 10 look and feel for your application window.

Gtk Hello

like image 138
Pete Avatar answered Sep 27 '22 22:09

Pete