GTK 树视图:选择时禁用突出显示
当为 GtkTreeView 小部件选择一行时,我尝试禁用该行的突出显示(默认为蓝色背景和白色文本颜色)。我尝试更改 STATE_SELECTED
GtkWidget *treev_iew;
GdkColor black;
GdkColor white;
gdk_color_parse ("white", &white);
gdk_color_parse ("black", &black);
...
treeview = gtk_tree_view_new();
...
gtk_widget_modify_text(GTK_WIDGET(tree_view),GTK_STATE_SELECTED,&black);
gtk_widget_modify_bg(GTK_WIDGET(tree_view),GTK_STATE_SELECTED, &white);
...
但这似乎不起作用。 背景变为白色,但字体颜色保持白色(不可读!)。 知道为什么吗?
I try to disable highlight on a row when it is selected for a GtkTreeView widget (default is blue background and white text color). I tried to change the STATE_SELECTED with
GtkWidget *treev_iew;
GdkColor black;
GdkColor white;
gdk_color_parse ("white", &white);
gdk_color_parse ("black", &black);
...
treeview = gtk_tree_view_new();
...
gtk_widget_modify_text(GTK_WIDGET(tree_view),GTK_STATE_SELECTED,&black);
gtk_widget_modify_bg(GTK_WIDGET(tree_view),GTK_STATE_SELECTED, &white);
...
but this doesn't seem to work.
The background changes to white, but the font color stays white (not readable!).
Any idea why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我查看了可用功能的 GTK 小部件定义(仅供参考,我查看的版本是 GTK3,以防您使用不同版本的 GTK)。在那里,它提到函数“gtk_widget_modify_text()”已被弃用,而应使用“gtk_widget_override_color()函数”。您可以尝试该替换。
请注意,从版本 3.16 开始,此函数也已被弃用,但可能仍会使用处理诸如背景颜色、前景色、文本颜色等属性的前进方向是通过在 CSS 中使用 CSS 定义和 CSS 提供程序。希望
有帮助
。
I reviewed the GTK widget definition for available functions (FYI, the version I reviewed was GTK3 in case you are working with a different version of GTK). In there, it mentions that the function "gtk_widget_modify_text()" is deprecated and the "gtk_widget_override_color() function should be used instead. You might try that substitution.
Please note that as of version 3.16, this function is also deprecated but probably will still work. The direction forward for handling attributes such as background colors, foreground colors, text colors, and so forth are through the use CSS definitions coupled with CSS providers within a program.
Hope that helps.
Regards.