![]() |
![]() |
![]() |
![]() |
Writing a Nautilus-Python extension is a fairly straight-forward process. One simply imports the Nautilus module from the GObject Introspection repository and creates a class which is derived from a GObject.GObject
and one or more of the Nautilus module’s abstract classes. When an extension derives a class, it becomes a “provider”, telling Nautilus to ask it for information.
There are several types of providers available for extensions to use, all of which will be explained in more detail in later chapters:
Your class can be derived from multiple providers.
Then the script needs to be installed to one of the paths nautilus-python looks for extensions to. That will be nautilus-python/extensions
subdirectory of one of the following data directories:
XDG_DATA_HOME
environment variable , falling back to $HOME
/.local/share
if not setdatadir
configured when building nautilus-python (such as /usr/local/share
)XDG_DATA_DIRS
environment variableAfter that, you will need to (re)start Nautilus, which will loads the nautilus-python C extension, which in turn will load all python extensions it can find.
Do not forget to have the extension class derive from a GObject.GObject
in addition to the standard Nautilus classes.
For now, some Nautilus class constructors require passing named arguments instead of a standard argument list. This requirement may go away at some point.