我正在尝试通过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;
}
颜色设置可用,因此它不完全损坏。但是没有任何键绑定起作用。我缺少了什么?
-gtk-key-bindings
而不是gtk-key-bindings
。 - eyelash