How does one make GTK3 look native on Windows 7?

css, gtk3, themes, vala

Solution

It worked by calling in the code, before displaying the main application window with show_all () :

Gtk.Settings.get_default ().gtk_theme_name = "win32";

When using a custom theme, the location of the theme should be: "YourApplicationExecutable\share\themes\ThemeFolder" as per described in the accepted answer of How to get native windows decorations on GTK3 on Windows 7+ and MSYS2

and the name set with gtk_theme_name in the code should be the name of the folder containing the theme.

Note that the method get_default () gets you the default GDK screen. If you want more control over specific widgets, use instead the method get_settings () over the specific widget that you want to change the theme for.

Sources:

How to get native windows decorations on GTK3 on Windows 7+ and MSYS2

https://valadoc.org/gtk+-3.0/Gtk.CssProvider.html

https://valadoc.org/gtk+-3.0/Gtk.Settings.html

Problem

I am trying to make my GTK3 application look native on Windows 7. I tried the answer in the following question How to get native windows decorations on GTK3 on Windows 7+ and MSYS2 But it doesn't work. My GTK3 version on windows is 3.22 and I am using the Vala language. Tried with GTK3 version 3.20 to no avail either. I also tried changing the background color of the application in the code itself with the CssProvider and it works in Ubuntu, but not in Windows. In Windows, the application theme and all CSS manual settings are ignored. Is there any way to achieve this? Thanks.

Original source

Related problems