更改 Windows 上的 GTK+3 外观

Change GTK+3 look on Windows

我在 stock Ubuntu 14.04 上开发了一个 GTK3 应用程序,并将其移植到 Windows 没有任何主要 issues.However Ubuntu 上的应用程序的外观完全与 Windows 不同(在 Windows 上更丑陋)。然而,同样使用 GTK 的 GIMP 在 Windows 和 Ubuntu.

上具有一致的外观

我不太熟悉 Ubuntu 如何改变 GTK 应用程序的外观,我想知道我需要为 Windows 上的 GTK 应用程序做些什么才能使它看起来像那个在 Ubuntu?

GIMP 使用 GTK+-2.x。 GTK+-2.x 主题复杂而奇怪。

GTK+-3.0 在所有平台上使用 Adwaita 主题。

您可以安装不同的 GTK+-3.x 主题。

您可以通过编辑 settings.ini 更改当前的 GTK+-3.x 主题,位于(当使用当前的 glib 时)在

  • DLL前缀/share/gtk-3.0/settings.ini
  • DLL前缀/etc/gtk-3.0/settings.ini
  • C:/Documents and Settings/All Users/Application Data/gtk-3.0/settings.ini
  • C:/Documents and Settings/用户名/本地Settings/ApplicationData/gtk-3.0/settings.ini

并将 gtk-theme-name=yourthemename 添加到 [Settings] 部分。

settings.ini 也适用于各种其他设置,请查找!)

GTK+-3.x 主题写在 CSS.

关于主题安装,GTK+-3.22文档是这样说的:

In addition, certain files will be read when GTK+ is initialized. First, the file $XDG_CONFIG_HOME/gtk-3.0/gtk.css is loaded if it exists. Then, GTK+ loads the first existing file among XDG_DATA_HOME/themes/theme-name/gtk-VERSION/gtk.css, $HOME/.themes/theme-name/gtk-VERSION/gtk.css, $XDG_DATA_DIRS/themes/theme-name/gtk-VERSION/gtk.css and DATADIR/share/themes/THEME/gtk-VERSION/gtk.css, where THEME is the name of the current theme (see the #GtkSettings:gtk-theme-name setting), DATADIR is the prefix configured when GTK+ was compiled (unless overridden by the GTK_DATA_PREFIX environment variable), and VERSION is the GTK+ version number. If no file is found for the current version, GTK+ tries older versions all the way back to 3.0.

在 Windows 上,使用当前的 glib,这将转换为(考虑到这里的 3.0 意味着 starting with 3.x and counting all the way down to 3.0):

  • C:/Documents and Settings/用户名/本地Settings/ApplicationData/gtk-3.0/gtk.css

请注意此路径中缺少 themesthemename

  • C:/Documents and Settings/用户名/本地Settings/ApplicationData/themes/主题名/gtk- 3.0/gtk.css /gtk.css
  • C:/Documents and Settings/用户名/.themes/主题名/gtk-3.0/gtk.css
  • C:/Documents and Settings/All Users/Application Data/themes/themename/gtk-3.0/gtk.css
  • C:/Documents and Settings/All Users/Documents/themes/themename/gtk-3.0/gtk.css
  • DLL前缀/share/themes/主题名/gtk-3.0/gtk.css
  • exe前缀/share/themes/主题名/gtk-3.0/gtk.css

您还可以为主题的 dark 变体提供 gtk-dark.css

默认的 Adwaita 主题已嵌入 GTK+ 库中,因此您不会在上面列出的任何目录中找到 Adwaita 主题 css 文件。如果您想查看 Adwaita 的 CSS 代码,您必须下载 GTK+ 源代码 - 主题将在 gtk/theme/ 子目录中。