如何访问 GTK/Gnome 上的主题字体和颜色
假设我想编写一个特殊的文本编辑器小部件。
我如何获得文本的默认主题颜色, 选定的文本和背景,这是用户默认的 字体?
我看到 GNOME 确实定义了 5 种特殊的系统字体和默认大小 为此,在 GNOME 外观配置对话框中, 但我在 GTK 文档中没有找到一个单词如何 访问它们(GTK 邮件列表是个笑话:-( )。Windows
和 Cocoa 都给了我几十个系统值。
我找到了 GtkStyle 类,但这似乎不是我需要的。
Lets say i want to write a special text editor widget.
How can i get the default themed colors for texts,
selected text and background and which are the users default
fonts?
I see that GNOME does define 5 special system fonts and default sizes
for this purpose in the GNOME Appearance Configuration dialog,
but i haven't found a single word in the GTK documentation how to
access them (and the GTK mailing list is a joke:-( ).
Windows and Cocoa both give me dozens of system values.
I found the GtkStyle class but this doesn't seem to be what i need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于默认颜色,请使用如下内容:
为
gtk_style_lookup_color()
定义了多个名称。有点不清楚它们到底是在哪里定义的,但是您可以在 GNOME 对话框中定义这些:fg_color
bg_color
base_color
text_color
selected_bg_color
selected_fg_color
tooltip_bg_color
tooltip_fg_color
至于字体和其他系统设置,您需要使用GConf 库来获取这些默认值。 GTK 对它们一无所知,因为它们是 GNOME 桌面的一部分,而不是 GTK。例如,可以在
/desktop/gnome/interface/font_name
键中找到默认字体。如果您安装了 GConf 配置编辑器,您可以浏览这些键以查看哪些键可用;它们都位于/desktop/gnome
下。附言。您在哪个 GTK 邮件列表上询问?我读到的那篇文章似乎不是一个笑话......
For the default colors, use something like this:
There are several names defined for
gtk_style_lookup_color()
. It's a bit unclear where exactly they are defined, but these are the ones you can define in the GNOME dialog:fg_color
bg_color
base_color
text_color
selected_bg_color
selected_fg_color
tooltip_bg_color
tooltip_fg_color
As for the fonts and other system settings, you need to use the GConf library to get these defaults. GTK knows nothing about them, because they're part of the GNOME desktop, not GTK. The default font can be found at the key
/desktop/gnome/interface/font_name
, for example. If you install the GConf configuration editor, you can browse these keys to see which ones are available; they're all under/desktop/gnome
.PS. What GTK mailing list did you ask on? The one I read doesn't seem to be a joke...