nautilus 插件开发学习日志

来源:互联网 发布:new balance淘宝店贴吧 编辑:程序博客网 时间:2024/04/29 14:44

nautilus 是 gnome 桌面的文件管理器。 它提供了扩展方法,允许开发人员对其进行功能扩充,具有很大的灵活性。

然而 nautilus 没有附带详细的插件开发文档,所以有此一帖。

有几个可以参考的网址:

http://live.gnome.org/Nautilus/Development/Extensions

http://www.campd.org/stuff/docs/extending-nautilus/NautilusExtensions.html

http://taschenorakel.de/svn/repos/bulldozer/trunk/documentation/NautilusExtensions.html (有用)


nautilus 插件可以对 nautilus 的 标记、上下文菜单、详细视图下的一个列,文件属性页 进行扩充。

一个 nautilus 插件可以实现多个接口:

  • NautilusInfoProvider: Information providers are used to add data to a NautilusFileInfo object and keep it up to date.

  • NautilusColumnProvider: Column providers add information to display in the list and icon views.

  • NautilusMenuProvider: Menu providers add menu items. Menu items can be added in three places: Per-file (shown in the file's context menu and the Edit menu), per-folder (shown in the background context menu and the File menu), and the toolbar.

  • NautilusPropertyPageProvider: Property providers add a property page to the file properties dialog.

nautilus 插件可以用两种语言编写: python 和 C

  • Python 编写的插件要放在 ~/.nautilus/python-extensions 或者 /usr/lib/nautilus/extensions-2.0/python 目录。

  • C 编写的插件编译为共享库之后,放在 /usr/lib/nautilus/extensions-2.0/ 目录。


以下内容讲述nautilus插件代码的编写(C语言):

1、实现3个回调函数,这3个函数负责插件整体的初始化和销毁工作:

#include <glib-object.h>// gcc -shared -fPIC -o test.so test.c `pkg-config --cflags --libs glib-2.0`void nautilus_module_initialize (GTypeModule *module) {// 初始化工作}void nautilus_module_shutdown (void) {// 清理工作}void nautilus_module_list_types (const GType **types, int *num_types) {// 暂时没有理解这个函数的作用}

2、在实现上面的 nautilus_module_initialize() 函数的时候,一般需要注册一些回调函数,

这些函数的原型在 nautilus-extension 的头文件中有定义。



原创粉丝点击