Navigation: Nautilus / Development |
Extensions
Contents
In this page we'll look at what exactly a Nautilus extension is (the interface etc.). Extensions allow you to go beyond the standard shell script interface and implement do things like add emblems, context menuitems, additional list columns and property pages. For an extensive introduction next to this article see Nautilus Extensions.
The basics of a Nautilus extension
A Nautilus extension can implement a couple of providers (interfaces), namely:
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.
Each of these providers come with their own set of functions one has to implement which in turn Nautilus will call to get 'things done'. We'll take a look specifically at NautilusInfoProvider.
NautilusInfoProvider
When implementing the NautilusInfoProvider interface one has to implement the update_file_info function.
- TODO: write something about when update_file_info is exactly called and the relation with invalidate_extension_info on a GnomeVFSFileInfo.
Example extensions
These are a couple of simple examples from the nautilus-python repository.
background-image allows to set the background image
block-size-column get the block size
md5sum-property-page displays the MD5Sum in the property page
open-terminal provides 'Open Terminal Here' and 'Open Terminal'
Installing extensions
Python extensions go in ~/.nautilus/python-extensions or /usr/lib/nautilus/extensions-2.0/python
C extensions are compiled into a shared library and go in /usr/lib/nautilus/extensions-2.0/
See also
Presentation from Dave Camp at GUADEC (Kristiansand, Norway). Archived video stream (dead), paper, slides
The liblicense tutorial. Walks you through the creation of an extension that adds emblems representing the chosen Creative Commons license (NautilusInfoProvider) and an associated property page to pick a license (NautilusPropertyPageProvider).
