gplugin/gplugin
Clone
Summary
Browse
Changes
Graph
Merge develop into default for the release
v0.29.0
2019-11-07, Gary Kramlich
fc9c95c883ae
Merge develop into default for the release
<?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>
<simplesect
id=
"intro"
>
<para>
Writing
Native
plugins
is
very
simple,
but
since
it's
C/C++
it's
a
bit
more
complicated.
</para>
<para>
There
are
currently
no
C++
bindings
and
no
intention
to
write
them,
but
the
C
API
is
still
usable
from
C++.
</para>
</simplesect>
<simplesect
id=
"example"
>
<para>
<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
if
everything
is
fine.
If
something
*
went
wrong,
error
should
be
set
to
a
valid
GError
and
NULL
should
be
*
returned.
*/
G_MODULE_EXPORT
GPluginPluginInfo
*
gplugin_plugin_query(GError
**error)
{
/*
Authors
is
a
list
of
authors
of
the
plugin.
Generally
these
are
*
in
the
"Name
Surname
<
user@domain.com
>
"
format.
*/
const
gchar
*
const
authors[]
=
{
"author",
NULL
};
/*
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,
"name",
"name",
"version",
"version",
"summary",
"summary",
"description",
"description",
"authors",
authors,
"website",
"website",
NULL
);
}
/*
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
*
set
to
a
valid
GError.
*/
G_MODULE_EXPORT
gboolean
gplugin_plugin_load(GPluginNativePlugin
*plugin,
GError
**error)
{
return
TRUE;
}
/*
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.
*/
G_MODULE_EXPORT
gboolean
gplugin_plugin_unload(GPluginNativePlugin
*plugin,
GError
**error)
{
return
TRUE;
}
</programlisting></informalexample>
</para>
</simplesect>
</chapter>