javascript 如何开始编写 Gnome Shell 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8301643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to start writing Gnome Shell extensions
提问by lzap
I have found it's very hard to find documentation about Gnome Shell Extensions. I found some bits on Gnome Wiki (and it's first-level links), but it's not much:
我发现很难找到有关 Gnome Shell 扩展的文档。我在 Gnome Wiki 上找到了一些内容(它是一级链接),但并不多:
http://live.gnome.org/GnomeShell/Extensions
http://live.gnome.org/GnomeShell/Extensions
The problem here is GJS and it's bindings. Absolutely no documentation, got lot's of SIGSEGVs, binding is just not ready (GLib, Gio and others). The only working one is unofficial documentation generated from GIR for Seed JavaScript implementation:
这里的问题是 GJS 和它的绑定。绝对没有文档,有很多 SIGSEGV,绑定还没有准备好(GLib、Gio 和其他)。唯一的工作是从 GIR 生成的用于 Seed JavaScript 实现的非官方文档:
http://roojs.org/seed/gir-1.2-gtk-2.0/seed/
http://roojs.org/seed/gir-1.2-gtk-2.0/seed/
Where to get more examples? I want read directories, files, spawn processes, open network sockets and do other stuff.
从哪里获得更多示例?我想要读取目录、文件、生成进程、打开网络套接字和做其他事情。
Update: Show me how to read a file line by line in GJS.According Google this is not possible. Thanks.
更新:告诉我如何在 GJS 中逐行读取文件。根据谷歌,这是不可能的。谢谢。
采纳答案by gpoo
GNOME Shell uses GJS, not Seed. There are some differences among both of them, and it might explain why you are having problems.
GNOME Shell 使用GJS,而不是Seed。它们之间存在一些差异,这可能解释了您遇到问题的原因。
With GOBject Introspection you can read the documentation for the original library and adapt the signature of every method/function to the language you are using.
使用 GOBject Introspection,您可以阅读原始库的文档,并使每个方法/函数的签名适应您使用的语言。
In your particular case, for files, networking, etc. you might want to check GIO. You can check the Platform Overviewto check what else is available. You also can check some examples (not extensions, though) in JavaScript.
在您的特定情况下,对于文件、网络等,您可能需要检查GIO。您可以查看平台概述以查看其他可用的内容。您还可以在JavaScript 中检查一些示例(但不是扩展)。
At last but not least, very soon a website with extension will be launched.
最后但并非最不重要的是,很快将推出一个带有扩展程序的网站。
回答by Has QUIT--Anony-Mousse
Well, supposedly, with Gnome3, you have a pretty uniform API across various programming languages, that is generated from the same GIR files. So you should (at least in theory) be able to retrieve all the API - I hope with documentation - from the GObject Introspection. And the other way round, you should be able to transform example code from another language into JavaScript for this API easily.
好吧,据说,使用 Gnome3,您可以在各种编程语言中拥有一个非常统一的 API,该 API 是从相同的 GIR 文件生成的。所以你应该(至少在理论上)能够从 GObject Introspection 中检索所有 API——我希望有文档。反过来,您应该能够轻松地将示例代码从另一种语言转换为该 API 的 JavaScript。
Theoretically. I avoid JavaScript where possible, developing a desktop application in JavaScript is the last I would do.
理论上。我尽可能避免使用 JavaScript,而在 JavaScript 中开发桌面应用程序是我最后会做的。