nautilus 插件开发学习日志

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 的头文件中有定义。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值