windows - 在 Windows 上更改 GTK+3 外观

标签 windows user-interface gtk themes

我在现有的 Ubuntu 14.04 上开发了一个 GTK3 应用程序,并将其移植到 Windows 上没有任何重大问题。但是,该应用程序在 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/用户名/Local Settings/Application Data/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 在这里意味着 从 3.x 开始一直计数到 3.0) :

  • C:/Documents and Settings/用户名/Local Settings/Application Data/gtk-3.0/gtk.css

请注意此路径中缺少 themesthemename

  • C:/Documents and Settings/用户名/Local Settings/Application Data/themes/themename/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/主题名/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/ 子目录中。

关于windows - 在 Windows 上更改 GTK+3 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36464010/

相关文章:

windows - 使用 SC 安装 Windows 服务

windows - 如何在 Windows 上调用使用 scan() 的脚本?

c - 如何在 GTK 中进行简单的图形绘制?

vim - 在 gVim 中使用 Vim 警告样式

javascript - Internet Explorer 11 (IE 11) 在 DOMParser 中使用 parseFromString 抛出语法错误

Windows 剪贴板中的 CF_DIB 到 CF_BITMAP

Java GridPane 中间部分问题

Java(GUI)多次添加JButton?

python - 如何验证 tkinter 中的按钮以便该函数只被调用一次?

c++ - 更改带有循环等待图像的进度条