3
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4
<title>Getting Started</title>
5
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
6
<link rel="start" href="index.html" title="Thunar Extensions Reference Manual">
7
<link rel="up" href="thunarx-writing-extensions.html" title="Part II. Writing Extensions">
8
<link rel="prev" href="thunarx-writing-extensions.html" title="Part II. Writing Extensions">
9
<link rel="next" href="thunarx-writing-extensions-advanced-topics.html" title="Advanced topics">
10
<meta name="generator" content="GTK-Doc V1.4 (XML mode)">
11
<link rel="stylesheet" href="style.css" type="text/css">
12
<link rel="part" href="thunarx-overview.html" title="Part I. Overview">
13
<link rel="part" href="thunarx-writing-extensions.html" title="Part II. Writing Extensions">
14
<link rel="part" href="thunarx-fundamentals.html" title="Part III. Fundamentals">
15
<link rel="part" href="thunarx-abstraction-layer.html" title="Part IV. Abstraction Layer">
16
<link rel="part" href="thunarx-providers.html" title="Part V. Providers">
17
<link rel="index" href="ix01.html" title="Index">
19
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
20
<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
21
<td><a accesskey="p" href="thunarx-writing-extensions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
22
<td><a accesskey="u" href="thunarx-writing-extensions.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
23
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
24
<th width="100%" align="center">Thunar Extensions Reference Manual</th>
25
<td><a accesskey="n" href="thunarx-writing-extensions-advanced-topics.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
27
<div class="sect1" lang="en">
28
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
29
<a name="thunarx-writing-extensions-getting-started"></a>Getting Started</h2></div></div></div>
31
Providers are <span class="type">GTypeModule</span>s loaded from shared libraries installed in
32
<code class="filename">$libdir/thunarx-1/</code>. The shared libraries are linked against the
33
<code class="systemitem">thunarx-1</code> library.
36
The extensions must provide three public functions, <code class="function">thunar_extension_initialize()</code>,
37
<code class="function">thunar_extension_shutdown()</code> and <code class="function">thunar_extension_list_types()</code>.
40
<code class="function">thunar_extension_initialize()</code> is passed a <span class="type">GTypeModule</span>
41
object, and must register all GTypes that the extension needs. <code class="function">thunar_extension_shutdown()</code> should
42
perform any extension-specific shutdown required prior to unloading the extension. <code class="function">thunar_extension_list_types()</code>
43
returns an array of GTypes that represent the types of the providers exported by the extension. Thunar will instantiate
44
objects of those types when needed.
47
<a name="id2539667"></a><p class="title"><b>Example 1. Basic Structure of an extension</b></p>
48
<pre class="programlisting">
49
#include <gmodule.h>
50
#include <thunarx/thunarx.h>
52
static GType type_list[1];
55
foo_extension_register_type (GTypeModule *module)
57
static const GTypeInfo info =
59
sizeof (FooExtensionClass),
62
(GClassInitFunc) foo_extension_class_init,
65
sizeof (FooExtension),
67
(GInstanceInitFunc) foo_extension_init,
71
type_list[0] = g_type_module_register_type (module,
76
/* implement the desired provider interfaces */
80
foo_extension_get_type (void)
86
thunar_extension_initialize (GTypeModule *module)
88
const gchar *mismatch;
90
/* verify the versions */
91
mismatch = thunarx_check_version (THUNARX_MAJOR_VERSION,
92
THUNARX_MINOR_VERSION,
93
THUNARX_MICRO_VERSION);
94
if (G_UNLIKELY (mismatch != NULL))
96
g_warning ("Version mismatch: %s", mismatch);
100
foo_extension_register_type (module);
104
thunar_extension_shutdown (void)
106
/* any extension-specific shutdown */
110
thunar_extension_list_types (const GType **types,
114
*n_types = G_N_ELEMENTS (type_list);
117
<div class="sect2" lang="en">
118
<div class="titlepage"><div><div><h3 class="title">
119
<a name="thunarx-writing-extensions-compiling-thunar-extensions"></a>Compiling Thunar Extensions</h3></div></div></div>
121
To compile a Thunar extension, you need to tell the compiler where to find the
122
<code class="systemitem">thunarx</code> header files and library. This
123
is done with the <code class="literal">pkg-config</code> utility.
126
The following interactive shell session demonstrates how <code class="literal">pkg-config</code>
127
is used (the actual output on your system will be different):
130
$ pkg-config --cflags thunarx-1
131
-DXTHREADS -DXUSE_MTSAFE_API -I/opt/local/include/thunarx-1 -I/usr/local/include/atk-1.0 \
132
-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/X11R6/include/gtk-2.0 \
133
-I/usr/X11R6/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/X11R6/include/pango-1.0 \
134
-I/usr/local/include/freetype2 -I/usr/local/include
135
$ pkg-config --libs thunarx-1
136
-Wl,--rpath -Wl,/usr/local/lib -L/usr/local/lib -L/usr/X11R6/lib -L/opt/local/lib -lthunarx-1</pre>
140
The easiest way to compile an extension is to use the <span class="emphasis"><em>backticks</em></span>
141
feature of the shell. If you enclose a command in backticks (<span class="emphasis"><em>not single
142
quotes</em></span>), then its output will be substituted into the command line before
143
execution. So to compile an extension, you would type the following:
146
$ gcc -shared -fPIC -DPIC `pkg-config --cflags --libs thunarx-1` foo.c -o foo.so</pre>
150
<div class="sect2" lang="en">
151
<div class="titlepage"><div><div><h3 class="title">
152
<a name="thunarx-writing-extensions-installing-thunar-extensions"></a>Installing Thunar Extensions</h3></div></div></div>
154
To determine the directory where extensions must be installed on your local system,
155
you can use the following command (as mentioned above, the output will be different
159
$ pkg-config --variable=extensionsdir thunarx-1
160
/opt/local/lib/thunarx-1</pre>
164
For example, to install the extension <code class="filename">foo.so</code> on your system,
165
you would type the following:
168
$ install -d `pkg-config --variable=extensionsdir thunarx-1`
169
$ install -c -m 0755 foo.so `pkg-config --variable=extensionsdir thunarx-1`/foo.so</pre>
174
<table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle">
175
<td align="left"><a accesskey="p" href="thunarx-writing-extensions.html"><b><< Part II. Writing Extensions</b></a></td>
176
<td align="right"><a accesskey="n" href="thunarx-writing-extensions-advanced-topics.html"><b>Advanced topics >></b></a></td>