![]() |
![]() |
![]() |
![]() |
Totem is extensible by means of small, dynamically-loadable plugins, which add functionality wanted by some but not others.
Totem plugins can either be installed in the system path
(e.g. /usr/lib/totem/plugins/
), or in a user's home directory
(e.g. ~/.local/share/totem/plugins/
). In either case, each plugin resides in a
subdirectory named after the plugin itself.
In addition, each plugin needs a .plugin
index file, residing inside the plugin
directory. This gives the code name of the plugin, as well as some metadata about the plugin such as its human-readable
name, description and author.
Example 1. Example Plugin Directory
A system-installed plugin called subtitle-downloader
would reside in
/usr/lib/totem/plugins/subtitle-downloader
, and would (at a
minimum) have the following files:
subtitle-downloader.plugin
libsubtitle-downloader.so
If installed in a user's home directory, it would reside in
~/.local/share/totem/plugins/subtitle-downloader
and have the same
files.
.plugin
FileThe file should use the following template:
[Plugin] Module=plugin-name
IAge=plugin interface age (starting at 1)
Builtin=Name=
true
orfalse
Human-Readable Plugin Name
Description=Simple sentence describing the plugin's functionality.
Authors=Plugin Author Name
Copyright=Copyright ©year
Copyright Holder
Website=http://plugin/website/
Most of the values in the template are fairly self-explanatory. One thing to note is that the plugin name should be
in lowercase, and contain no spaces. The plugin interface age should start at 1
, and only be
incremented when the binary interface of the plugin (as used by Totem) changes. If the plugin does not have its own
website, Totem's website (https://wiki.gnome.org/Apps/Videos
) can be used.
The library file containing the plugin's code should be named
lib
(for C, or other compiled language, plugins) or
plugin-name
.so
(for Python plugins).pluginname
.py
Writing a plugin in C is a matter of creating a new GObject which inherits
from PeasExtensionBase and which implements
PeasActivatable. The following code will create a simple plugin
called foobar
:
Once resources have been created, and the plugin has been connected to Totem's UI in the impl_activate
function, the plugin is free to go about its tasks as appropriate. If the user deactivates the plugin, or Totem decides
to deactivate it, the impl_deactivate
will be called. The plugin should free any resources
grabbed or allocated in the impl_activate
function, and remove itself from the Totem
interface.
Note that plugins can be activated and deactivated (e.g. from Totem's plugin manager) many times during one Totem session,
so the impl_activate
and impl_deactivate
functions must be able to cope with
this.
Any of the API documented in the rest of the Totem API reference can be used by plugins. Python plugins are written in the same way as C plugins, and are similarly implemented as classes derived from PeasExtensionBase and implementing PeasActivatable.