简体   繁体   English

如何开始编写Gnome Shell扩展

[英]How to start writing Gnome Shell extensions

I have found it's very hard to find documentation about Gnome Shell Extensions. 我发现很难找到有关Gnome Shell Extensions的文档。 I found some bits on Gnome Wiki (and it's first-level links), but it's not much: 我在Gnome Wiki上发现了一些内容(它是第一级链接),但它并不多:

http://live.gnome.org/GnomeShell/Extensions http://live.gnome.org/GnomeShell/Extensions

The problem here is GJS and it's bindings. 这里的问题是GJS和它的绑定。 Absolutely no documentation, got lot's of SIGSEGVs, binding is just not ready (GLib, Gio and others). 绝对没有文档,有很多SIGSEGV,绑定还没准备好(GLib,Gio等)。 The only working one is unofficial documentation generated from GIR for Seed JavaScript implementation: 唯一可行的是从GIR为种子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. 更新:演示如何在GJS中逐行读取文件。 According Google this is not possible. 根据谷歌这是不可能的。 Thanks. 谢谢。

GNOME Shell uses GJS , not Seed . GNOME Shell使用GJS ,而不是Seed There are some differences among both of them, and it might explain why you are having problems. 它们之间存在一些差异,这可能解释了您遇到问题的原因。

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 . 在您的特定情况下,对于文件,网络等,您可能需要检查GIO You can check the Platform Overview to check what else is available. 您可以查看平台概述以查看还有哪些可用。 You also can check some examples (not extensions, though) in JavaScript . 您也可以在JavaScript中查看一些示例(不是扩展名)。

At last but not least, very soon a website with extension will be launched. 最后但并非最不重要的是,很快将推出一个带扩展名的网站。

Well, supposedly, with Gnome3, you have a pretty uniform API across various programming languages, that is generated from the same GIR files. 嗯,据说,使用Gnome3,您可以在各种编程语言中使用相同的GIR文件生成相当统一的API。 So you should (at least in theory) be able to retrieve all the API - I hope with documentation - from the GObject Introspection. 所以你应该(至少在理论上)能够从GObject Introspection中检索所有的API - 我希望有文档。 And the other way round, you should be able to transform example code from another language into JavaScript for this API easily. 反过来说,您应该能够轻松地将示例代码从另一种语言转换为JavaScript。

Theoretically. 理论上。 I avoid JavaScript where possible, developing a desktop application in JavaScript is the last I would do. 我尽可能避免使用JavaScript,用JavaScript开发桌面应用程序是我要做的最后一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM