在Gjs中使用Shell对象 [英] Use of Shell object in Gjs
问题描述
我正在使用Gjs(Gnome JavaScript绑定)编写gtk +应用程序
由于没有可用的文档,因此我正在阅读gnome-shell JavaScript的资源.
在我的应用中,我需要访问global.userdatadir
.
I am writing a gtk+ app using Gjs ( Gnome JavaScript bindings )
As there are no documents available i am reading the sources of gnome-shell JavaScript's .
In my app i need to get access to global.userdatadir
.
我正在尝试将Shell对象添加到我的脚本中:
I am trying to add the Shell object to my script :
const Shell = imports.gi.Shell;
并使用#gjs myscript.js
运行它
但是,当我这样做时,它会向我抛出一个错误:
and run it with #gjs myscript.js
but when i do this it throws me an error saying :
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
正常运行.
I cant understand what's wrong with it , it is exactly as in Gnome-shell source files.
Other objects are fine using imports.gi.Gio
, imports.gi.GLib
, works OK .
在Ubuntu 11.10 x64上工作
Working on Ubuntu 11.10 x64
推荐答案
您无法通过gjs运行gnome-shell扩展,它们必须由gnome-shell本身加载.对于开发而言,这通常意味着将它们放入~/.local/share/gnome-shell/extensions/YOUR-EXTENSION-ID
并重新启动Shell.
You can't run gnome-shell extensions via gjs, they have to be loaded by gnome-shell itself. For development, this usually means putting them in ~/.local/share/gnome-shell/extensions/YOUR-EXTENSION-ID
and restarting the shell.
这篇关于在Gjs中使用Shell对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!