我正在尝试通过css将键绑定添加到gtk3应用程序中。这就是我到目前为止所做的:
// add style provider
GtkCssProvider *css = gtk_css_provider_new();
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_css_provider_load_from_path(css, "bindings.css", NULL);
这是在前一个代码段中加载的'bindings.css':
@binding-set tree-view-bindings {
bind "j" { "move-cursor" (display-lines, 1) };
bind "k" { "move-cursor" (display-lines, -1) };
bind "slash" { "start-interactive-search" () };
}
GtkTreeView {
color: #F00;
gtk-key-bindings: tree-view-bindings;
}
颜色设置有效,因此不能完全破碎。但没有一个键绑定工作。我错过了什么?
答案 0 :(得分:0)
请原谅我,如果我错了,但我相信你把分号放在了错误的地方:)
@binding-set tree-view-bindings {
bind "j" { "move-cursor" (display-lines, 1); }
bind "k" { "move-cursor" (display-lines, -1); }
bind "slash" { "start-interactive-search" (); }
}
答案 1 :(得分:0)
它对我来说有以下作用:
treeview {
-gtk-key-bindings: tree-view-bindings;
}
所以GtkTreeView
变成了treeview
,而gtk-key-bindings
变成了-gtk-key-bindings
备注:
GTK_DEBUG=interactive