<?xml version='1.0' encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ <chapter id="chapter-native-plugins"> <title>Writing
Native
Plugins
</title> Writing
Native
plugins
is
pretty
simple,
but
since
it's
C/C++
it's
a
bit
There
are
currently
no
C++
bindings
and
no
intention
to
write
them,
but
the
C
API
is
still
usable
from
C++.
<simplesect id="example"> <informalexample><programlisting> #include
<gplugin.h
> #include
<gplugin-native.h
> /*
gplugin_plugin_query
is
called
by
the
native
loader
to
determine
if
*
the
plugin
is
loadable.
It
must
have
this
signature
and
should
*
return
a
valid
GPluginPluginInfo
instance
if
everything
is
fine.
If
*
something
went
wrong,
error
should
be
set
to
a
valid
GError
and
NULL
G_MODULE_EXPORT
GPluginPluginInfo
*
gplugin_plugin_query(GError
**error)
{
/*
Authors
is
a
list
of
authors
who
worked
on
the
plugin.
Generally
*
these
are
in
the
"Name
Surname
<user@domain.com
>"
format.
const
gchar
*
const
authors[]
=
{
"Author
O
<author@example.com
>",
/*
gplugin_plugin_info_new
only
requires
that
the
id
be
set,
and
the
*
rest
are
here
for
demonstration
purposes.
return
gplugin_plugin_info_new(
"gplugin/basic-native-plugin",
GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
"description",
"description",
/*
gplugin_plugin_load
is
called
by
the
loader
when
the
plugin
should
*
be
loaded.
It
must
have
this
exact
signature
and
return
TRUE
if
*
loading
was
successful,
otherwise
it
should
return
FALSE
with
error
gplugin_plugin_load(GPluginNativePlugin
*plugin,
GError
**error)
{
/*
gplugin_plugin_unload
is
called
by
the
loader
when
the
plugin
should
*
be
unloaded.
It
must
have
this
exact
signature
and
should
return
TRUE
*
if
unloading
was
successful,
otherwise
it
should
return
FALSE
with
*
error
set
to
a
valid
GError.
gplugin_plugin_unload(GPluginNativePlugin
*plugin,
GError
**error)
{
</programlisting></informalexample>