GTK+可以应用特定的皮肤吗?

发布于 2024-09-27 17:11:04 字数 135 浏览 6 评论 0原文

我已经开始使用 GTK+ 和 Vala,但很难找到有关创建自定义按钮(外观全新的按钮)的文档。事实上,现在我想起来,每个 GTK+ 应用程序都有独特的外观,这表明它是一个 GTK+ 应用程序。如果我决定使用 GTK+,为我的应用程序创建全新的外观是否困难?

I've started working with GTK+ and Vala and am having a hard time finding documentation on creating custom buttons (totally new looking buttons). In fact now that I think about it, every GTK+ application has that distinct look that gives away that it's a GTK+ app. Is it difficult to create a totally new look for my application if I decide to use GTK+?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

樱娆 2024-10-04 17:11:04

故意让它变得困难,因为“独特的 GTK 外观”就是重点。 GTK 应用程序通常非常重视可用性、可访问性和用户体验。作为应用程序程序员,您应该专注于应用程序的内容,并让用户选择他们喜欢的主题。如果您制作自定义按钮,那么它们可能太窄,无法适合使用其他语言的应用程序的用户的翻译标签。或者也许您的自定义按钮在某人喜欢的窗口背景颜色上看起来非常糟糕。

It's made difficult on purpose, because "that distinct GTK look" is the whole point. GTK applications generally place a lot of value on usability, accessibility, and user experience. You, the application programmer, should concentrate on the content of your application, and let the user choose a theme they like. If you make custom buttons, then they might be too narrow to fit the translated labels for a user using your application in another language. Or maybe your custom buttons look really horrible on someone's preferred window background color.

忘羡 2024-10-04 17:11:04

RC 代码已在 gtk+3 中被替换。它现在支持 css 样式,这可能会满足您的需求。

http://developer.gnome.org/gtk3/3.1/gtk-migration -GtkStyleContext.html

http://thegnomejournal。 wordpress.com/2011/03/15/styling-gtk-with-css/

h te p://kalmbach.wordpress.com/2011/03/12/gtk-3-0-client-side -主题/

RC code has been replaced in gtk+3. It now supports css for styling this may give you what you need.

http://developer.gnome.org/gtk3/3.1/gtk-migrating-GtkStyleContext.html

http://thegnomejournal.wordpress.com/2011/03/15/styling-gtk-with-css/

h te te p://kalmbach.wordpress.com/2011/03/12/gtk-3-0-client-side-theme/

那小子欠揍 2024-10-04 17:11:04

您可以使用 GTK2_RC_FILES 环境变量(仅)为您的应用程序分配特殊主题。

例如,您可以像这样创建一个批处理启动程序 (Windows):

set GTK2_RC_FILES=%GTK_HOME%\share\themes\slickness-black\gtk-2.0\gtkrc
launch.exe

或者在 Linux 中(还没有尝试过):

env GTK2_RC_FILES=/usr/share/themes/slickness-black/gtk-2.0/gtkrc ./launch

提示:不要相信要设置的 GTK_HOME,而是使用 GTK+ 安装的绝对路径。如果您在应用程序中安装特殊主题,则可以使用相对路径(相对于应用程序的安装路径)。然后,您应该确保该主题受到最常见主题引擎之一的支持,因为通常不会安装所有主题引擎(尤其是在 Windows 上,GTK 安装程序一团糟)。

You can use the GTK2_RC_FILES environment variable to assign a special theme to (only) your application.

For example, you can create a batch starter (Windows) like so:

set GTK2_RC_FILES=%GTK_HOME%\share\themes\slickness-black\gtk-2.0\gtkrc
launch.exe

Or in Linux (haven't tried that one):

env GTK2_RC_FILES=/usr/share/themes/slickness-black/gtk-2.0/gtkrc ./launch

Hint: Don't trust in GTK_HOME to be set, rather use the absolute path of the GTK+ installation. If you install a special theme with your application, it might be possible to use a relative path (relative to the installation path of your app). Then you should make sure that the theme is supported by one of the most common theme engines because usually not all of them are installed (especially on Windows, where GTK installers are a mess).

ぶ宁プ宁ぶ 2024-10-04 17:11:04

@gtksharp:

字符串文件名 = @"/usr/valapp/gtkrc3";
Gtk.Rc.AddDefaultFile(文件名);
Gtk.Rc.Parse(文件名);

@gtksharp:

string fileName = @"/usr/valapp/gtkrc3";
Gtk.Rc.AddDefaultFile(fileName);
Gtk.Rc.Parse(fileName);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文