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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Part II. Parole Plugin Tutorial</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Parole Plugins Reference Manual">
<link rel="up" href="index.html" title="Parole Plugins Reference Manual">
<link rel="prev" href="Intro.html" title="Part I. Introduction">
<link rel="next" href="fundamentals.html" title="Part III. Fundamentals">
<meta name="generator" content="GTK-Doc V1.17 (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="Intro.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td> </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">Parole Plugins Reference Manual</th>
<td><a accesskey="n" href="fundamentals.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="part">
<div class="titlepage"><div><div><h1 class="title">
<a name="parole-plugins-tut"></a>Part II. Parole Plugin Tutorial</h1></div></div></div>
<p>
This section explains the steps required to write a plugin for Parole using
the C language interface.
</p>
<p>
A simple example can be found in the parole plugins dir shipped with the source code, the sample
plugin.
</p>
<p>
As a basics, the plugin needs to implement <a class="link" href="Parole-Plugins-parole-provider-plugin.html#ParoleProviderPlugin"><span class="type">ParoleProviderPlugin</span></a>
interface, That is, the player use this interface to get if the plugin is configurable, to ask it to show
its properties dialog when needed, to set the <a class="link" href="Parole-Plugins-parole-provider-player.html#ParoleProviderPlayer" title="ParoleProviderPlayer"><span class="type">ParoleProviderPlayer</span></a>
interface used by plugins to access the the Parole player backend.
</p>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2731529"></a>Plugin structure.</h2></div></div></div>
sample-plugin.c
<pre class="programlisting">
#include "sample-provider.h"
/* Avoid a no previous function declaration compiler warning*/
G_MODULE_EXPORT GType parole_plugin_initialize (ParoleProviderPlugin *plugin);
G_MODULE_EXPORT void parole_plugin_shutdown (void);
G_MODULE_EXPORT GType
parole_plugin_initialize (ParoleProviderPlugin *plugin)
{
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
sample_provider_register_type (plugin);
return SAMPLE_TYPE_PROVIDER;
}
G_MODULE_EXPORT void
parole_plugin_shutdown (void)
{
}
</pre>
sample-provider.h
<pre class="programlisting">
#ifndef SAMPLE_PROVIDER_H_
#define SAMPLE_PROVIDER_H_
#include <parole/parole.h>
G_BEGIN_DECLS
typedef struct _SampleProviderClass SampleProviderClass;
typedef struct _SampleProvider SampleProvider;
#define SAMPLE_TYPE_PROVIDER (sample_provider_get_type ())
#define SAMPLE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SAMPLE_TYPE_PROVIDER, SampleProvider))
#define SAMPLE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SAMPLE_TYPE_PROVIDER, SampleProviderClass))
#define SAMPLE_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SAMPLE_TYPE_PROVIDER))
#define SAMPLE_IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SAMPLE_TYPE_PROVIDER))
#define SAMPLE_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SAMPLE_TYPE_PROVIDER, SampleProviderClass))
GType sample_provider_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
void sample_provider_register_type (ParoleProviderPlugin *plugin);
G_END_DECLS
</pre>
sample-provider.c
<pre class="programlisting">
#include "sample-provider.h"
static void sample_provider_iface_init (ParoleProviderPluginIface *iface);
static void sample_provider_finalize (GObject *object);
struct _SampleProviderClass
{
GObjectClass parent_class;
};
struct _SampleProvider
{
GObject parent;
ParoleProviderPlayer *player;
};
PAROLE_DEFINE_TYPE_WITH_CODE (SampleProvider,
sample_provider,
G_TYPE_OBJECT,
PAROLE_IMPLEMENT_INTERFACE (PAROLE_TYPE_PROVIDER_PLUGIN,
sample_provider_iface_init));
static void sample_provider_configure (ParoleProviderPlugin *provider, GtkWidget *parent)
{
/*Open the configuration dialog, parent is the window transient for*/
}
static gboolean sample_provider_is_configurable (ParoleProviderPlugin *plugin)
{
return TRUE; /*Returns FALSE and don't override the iface->configure function*/
}
static void
sample_provider_set_player (ParoleProviderPlugin *plugin, ParoleProviderPlayer *player)
{
SampleProvider *provider;
provider = SAMPLE_PROVIDER (plugin);
provider->player = player;
}
static void
sample_provider_iface_init (ParoleProviderPluginIface *iface)
{
iface->get_is_configurable = sample_provider_is_configurable;
iface->configure = sample_provider_configure;
iface->set_player = sample_provider_set_player;
}
static void sample_provider_class_init (SampleProviderClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = sample_provider_finalize;
}
static void sample_provider_init (SampleProvider *provider)
{
provider->player = NULL;
}
static void sample_provider_finalize (GObject *object)
{
G_OBJECT_CLASS (sample_provider_parent_class)->finalize (object);
}
</pre>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.17</div>
</body>
</html>
|