GTK+可以应用特定的皮肤吗?
我已经开始使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
故意让它变得困难,因为“独特的 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.
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/
您可以使用 GTK2_RC_FILES 环境变量(仅)为您的应用程序分配特殊主题。
例如,您可以像这样创建一个批处理启动程序 (Windows):
或者在 Linux 中(还没有尝试过):
提示:不要相信要设置的 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:
Or in Linux (haven't tried that one):
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).
@gtksharp:
字符串文件名 = @"/usr/valapp/gtkrc3";
Gtk.Rc.AddDefaultFile(文件名);
Gtk.Rc.Parse(文件名);
@gtksharp:
string fileName = @"/usr/valapp/gtkrc3";
Gtk.Rc.AddDefaultFile(fileName);
Gtk.Rc.Parse(fileName);