我正在使用 Gjs(Gnome JavaScript 绑定)编写一个 gtk+ 应用程序,因为没有可用的文档,我正在阅读 gnome-shell JavaScript 的源代码。在我的应用程序中,我需要访问global.userdatadir
.
我正在尝试将 Shell 对象添加到我的脚本中:
const Shell = imports.gi.Shell;
并运行它#gjs myscript.js
但是当我这样做时它会抛出一个错误说:
JS ERROR: !!! Exception was: Error: Requiring Shell, version none: Typelib file for namespace 'Shell' (any version) not found
JS ERROR: !!! lineNumber = '0'
JS ERROR: !!! fileName = '"gjs_throw"'
JS ERROR: !!! stack = '"("Requiring Shell, version none: Typelib file for namespace 'Shell' (any version) not found")@gjs_throw:0
@manager.js:5
"'
JS ERROR: !!! message = '"Requiring Shell, version none: Typelib file for namespace 'Shell' (any version) not found"'
Error: Requiring Shell, version none: Typelib file for namespace 'Shell' (any version) not found
我无法理解它有什么问题,它与 Gnome-shell 源文件中的完全一样。其他对象都可以使用imports.gi.Gio
, imports.gi.GLib
, 工作正常。
在 Ubuntu 11.10 x64 上工作