This file is indexed.

/usr/share/gtk-doc/html/totem/totem-plugins.html is in totem-common 3.0.1-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Writing Totem Plugins</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Totem Reference Manual">
<link rel="up" href="tutorials.html" title="Tutorials">
<link rel="prev" href="tutorials.html" title="Tutorials">
<link rel="next" href="core-api.html" title="Core API">
<meta name="generator" content="GTK-Doc V1.17.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="tutorials.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="tutorials.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Totem Reference Manual</th>
<td><a accesskey="n" href="core-api.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="totem-plugins"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="totem-plugins.top_of_page"></a>Writing Totem Plugins</span></h2>
<p>Writing Totem Plugins — brief tutorial on writing Totem plugins</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="id404383"></a><h2>Introduction</h2>
<p>Totem is extensible by means of small, dynamically-loadable plugins, which add functionality wanted by some but not others.</p>
<div class="refsect2">
<a name="id393581"></a><h3>Locations</h3>
<p>Totem plugins can either be installed in the system path
				(e.g. <code class="filename">/usr/lib/totem/plugins/</code>), or in a user's home directory
				(e.g. <code class="filename">~/.local/share/totem/plugins/</code>). In either case, each plugin resides in a
				subdirectory named after the plugin itself.</p>
<p>In addition, each plugin needs a <code class="filename">.totem-plugin</code> 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.</p>
<div class="example">
<a name="id400883"></a><p class="title"><b>Example 1. Example Plugin Directory</b></p>
<div class="example-contents">
<p>A system-installed plugin called <code class="literal">subtitle-downloader</code> would reside in
					<code class="filename">/usr/lib/totem/plugins/subtitle-downloader</code>, and would (at a
					minimum) have the following files:
					</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><code class="filename">subtitle-downloader.totem-plugin</code></li>
<li class="listitem"><code class="filename">libsubtitle-downloader.so</code></li>
</ul></div>
<p>
				</p>
<p>If installed in a user's home directory, it would reside in
					<code class="filename">~/.local/share/totem/plugins/subtitle-downloader</code> and have the same
					files.</p>
</div>
</div>
<br class="example-break">
</div>
<hr>
<div class="refsect2">
<a name="id403375"></a><h3>The <code class="filename">.totem-plugin</code> File</h3>
<p>The file should use the following template:
				</p>
<pre class="programlisting">[Totem Plugin]
	Module=<em class="replaceable"><code>plugin-name</code></em>
	IAge=<em class="replaceable"><code>plugin interface age (starting at 1)</code></em>
	Builtin=<em class="replaceable"><code><code class="literal">true</code> or <code class="literal">false</code></code></em>
	Name=<em class="replaceable"><code>Human-Readable Plugin Name</code></em>
	Description=<em class="replaceable"><code>Simple sentence describing the plugin's functionality.</code></em>
	Authors=<em class="replaceable"><code>Plugin Author Name</code></em>
	Copyright=Copyright © <em class="replaceable"><code>year</code></em> <em class="replaceable"><code>Copyright Holder</code></em>
	Website=<em class="replaceable"><code>http://plugin/website/</code></em></pre>
<p>
				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 <code class="literal">1</code>, 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 (<code class="literal">http://projects.gnome.org/totem/</code>) can be used.</p>
<p>The library file containing the plugin's code should be named
				<code class="filename">lib<em class="replaceable"><code>plugin-name</code></em>.so</code> (for C, or other compiled-language, plugins) or
				<code class="filename"><em class="replaceable"><code>plugin-name</code></em>.py</code> (for Python plugins).</p>
</div>
<hr>
<div class="refsect2">
<a name="id425305"></a><h3>Writing a Plugin</h3>
<p>Writing a plugin in C is a matter of creating a new <span class="type"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject">GObject</a></span> which inherits
				from <span class="type">TotemPlugin</span>. The following code will create a simple plugin
				called <code class="literal">foobar</code>:
				</p>
<div class="example">
<a name="id412647"></a><p class="title"><b>Example 2. Example Plugin Code</b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="normal">        </span><span class="symbol">(</span><span class="function">totem_foobar_plugin_get_type</span><span class="normal"> </span><span class="symbol">())</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_FOOBAR_PLUGIN</span><span class="symbol">(</span><span class="normal">o</span><span class="symbol">)</span><span class="normal">          </span><span class="symbol">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#G-TYPE-CHECK-INSTANCE-CAST:CAPS">G_TYPE_CHECK_INSTANCE_CAST</a></span><span class="normal"> </span><span class="symbol">((</span><span class="normal">o</span><span class="symbol">),</span><span class="normal"> TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="symbol">,</span><span class="normal"> TotemFoobarPlugin</span><span class="symbol">))</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_FOOBAR_PLUGIN_CLASS</span><span class="symbol">(</span><span class="normal">k</span><span class="symbol">)</span><span class="normal">        </span><span class="symbol">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#G-TYPE-CHECK-CLASS-CAST:CAPS">G_TYPE_CHECK_CLASS_CAST</a></span><span class="symbol">((</span><span class="normal">k</span><span class="symbol">),</span><span class="normal"> TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="symbol">,</span><span class="normal"> TotemFoobarPluginClass</span><span class="symbol">))</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_IS_FOOBAR_PLUGIN</span><span class="symbol">(</span><span class="normal">o</span><span class="symbol">)</span><span class="normal">       </span><span class="symbol">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#G-TYPE-CHECK-INSTANCE-TYPE:CAPS">G_TYPE_CHECK_INSTANCE_TYPE</a></span><span class="normal"> </span><span class="symbol">((</span><span class="normal">o</span><span class="symbol">),</span><span class="normal"> TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="symbol">))</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_IS_FOOBAR_PLUGIN_CLASS</span><span class="symbol">(</span><span class="normal">k</span><span class="symbol">)</span><span class="normal">     </span><span class="symbol">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#G-TYPE-CHECK-CLASS-TYPE:CAPS">G_TYPE_CHECK_CLASS_TYPE</a></span><span class="normal"> </span><span class="symbol">((</span><span class="normal">k</span><span class="symbol">),</span><span class="normal"> TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="symbol">))</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">TOTEM_FOOBAR_PLUGIN_GET_CLASS</span><span class="symbol">(</span><span class="normal">o</span><span class="symbol">)</span><span class="normal">    </span><span class="symbol">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#G-TYPE-INSTANCE-GET-CLASS:CAPS">G_TYPE_INSTANCE_GET_CLASS</a></span><span class="normal"> </span><span class="symbol">((</span><span class="normal">o</span><span class="symbol">),</span><span class="normal"> TOTEM_TYPE_FOOBAR_PLUGIN</span><span class="symbol">,</span><span class="normal"> TotemFoobarPluginClass</span><span class="symbol">))</span>

<span class="keyword">typedef</span><span class="normal"> </span><span class="keyword">struct</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">    </span><span class="usertype">TotemPlugin</span><span class="normal"> parent</span><span class="symbol">;</span>
<span class="normal">    </span><span class="comment">/* plugin object members */</span>
<span class="cbracket">}</span><span class="normal"> TotemFoobarPlugin</span><span class="symbol">;</span>

<span class="keyword">typedef</span><span class="normal"> </span><span class="keyword">struct</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">    </span><span class="usertype">TotemPluginClass</span><span class="normal"> parent_class</span><span class="symbol">;</span>
<span class="cbracket">}</span><span class="normal"> TotemFoobarPluginClass</span><span class="symbol">;</span>

<span class="normal"><a href="http://library.gnome.org/devel/glib/unstable/glib-Dynamic-Loading-of-Modules.html#G-MODULE-EXPORT:CAPS">G_MODULE_EXPORT</a> </span><span class="usertype">GType</span><span class="normal"> </span><span class="function">register_totem_plugin</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GTypeModule</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">module</span><span class="symbol">);</span>
<span class="usertype">GType</span><span class="normal"> </span><span class="function">totem_foobar_plugin_get_type</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span><span class="normal"> <a href="http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Macros.html#G-GNUC-CONST:CAPS">G_GNUC_CONST</a></span><span class="symbol">;</span>

<span class="keyword">static</span><span class="normal"> </span><span class="usertype">gboolean</span><span class="normal"> </span><span class="function">impl_activate</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">TotemObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">totem</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">GError</span><span class="normal"> </span><span class="symbol">**</span><span class="normal">error</span><span class="symbol">);</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">impl_deactivate</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">TotemObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">totem</span><span class="symbol">);</span>

<span class="function"><a href="totem-TotemPlugin.html#TOTEM-PLUGIN-REGISTER:CAPS">TOTEM_PLUGIN_REGISTER</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">TotemFoobarPlugin</span><span class="symbol">,</span><span class="normal"> totem_foobar_plugin</span><span class="symbol">)</span>

<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">totem_foobar_plugin_class_init</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemFoobarPluginClass</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">klass</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">    </span><span class="usertype">TotemPluginClass</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin_class </span><span class="symbol">=</span><span class="normal"> </span><span class="function">TOTEM_PLUGIN_CLASS</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">klass</span><span class="symbol">);</span>

<span class="normal">    plugin_class</span><span class="symbol">-&gt;</span><span class="normal">activate </span><span class="symbol">=</span><span class="normal"> impl_activate</span><span class="symbol">;</span>
<span class="normal">    plugin_class</span><span class="symbol">-&gt;</span><span class="normal">deactivate </span><span class="symbol">=</span><span class="normal"> impl_deactivate</span><span class="symbol">;</span>
<span class="cbracket">}</span>

<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">totem_foobar_plugin_init</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemFoobarPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">    </span><span class="comment">/* Initialise resources, but only ones which should exist for the entire lifetime of Totem;</span>
<span class="comment">     * those which should only exist for the lifetime of the plugin (which may be short, and may</span>
<span class="comment">     * occur several times during one Totem session) should be created in impl_activate, and destroyed</span>
<span class="comment">     * in impl_deactivate. */</span>
<span class="cbracket">}</span>

<span class="keyword">static</span><span class="normal"> <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean">gboolean</a></span>
<span class="function">impl_activate</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">TotemObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">totem</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">GError</span><span class="normal"> </span><span class="symbol">**</span><span class="normal">error</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">    </span><span class="usertype">TotemFoobarPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">TOTEM_FOOBAR_PLUGIN</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">plugin</span><span class="symbol">);</span>

<span class="normal">    </span><span class="comment">/* Initialise resources, connect to events, create menu items and UI, etc., here.</span>
<span class="comment">     * Note that impl_activate and impl_deactivate can be called multiple times in one</span>
<span class="comment">     * Totem instance, though impl_activate will always be followed by impl_deactivate before</span>
<span class="comment">     * it is called again. Similarly, impl_deactivate cannot be called twice in succession. */</span>

<span class="normal">    </span><span class="keyword">return</span><span class="normal"> <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">;</span>
<span class="cbracket">}</span>

<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">impl_deactivate</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">TotemPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">plugin</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">TotemObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">totem</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">    </span><span class="usertype">TotemFoobarPlugin</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">TOTEM_FOOBAR_PLUGIN</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">plugin</span><span class="symbol">);</span>

<span class="normal">    </span><span class="comment">/* Destroy resources created in impl_activate here. e.g. Disconnect from signals</span>
<span class="comment">     * and remove menu entries and UI. */</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break"></p>
<p>Once resources have been created, and the plugin has been connected to Totem's UI in the <code class="function">impl_activate</code>
				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 <code class="function">impl_deactivate</code> will be called. The plugin should free any resources
				grabbed or allocated in the <code class="function">impl_activate</code> function, and remove itself from the Totem
				interface.</p>
<p>Note that plugins can be activated and deactivated (e.g. from Totem's plugin manager) many times during one Totem session,
				so the <code class="function">impl_activate</code> and <code class="function">impl_deactivate</code> functions must be able to cope with
				this.</p>
<p>Any of the API documented in the rest of the Totem API reference can be used by plugins, though the bindings for Python
				plugins are incomplete. Otherwise, Python plugins are written in the same way as C plugins, and are similarly implemented
				as classes derived from <span class="type">TotemPlugin</span>.</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17.1</div>
</body>
</html>