2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __GRITS_PLUGIN_H__
19 #define __GRITS_PLUGIN_H__
21 #include <glib-object.h>
27 #define GRITS_TYPE_PLUGIN (grits_plugin_get_type())
28 #define GRITS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRITS_TYPE_PLUGIN, GritsPlugin))
29 #define GRITS_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRITS_TYPE_PLUGIN))
30 #define GRITS_PLUGIN_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), GRITS_TYPE_PLUGIN, GritsPluginInterface))
32 typedef struct _GritsPlugin GritsPlugin;
33 typedef struct _GritsPluginInterface GritsPluginInterface;
35 struct _GritsPluginInterface
37 GTypeInterface parent_iface;
41 const gchar *description;
43 /* Virtual functions */
44 GtkWidget *(*get_config)(GritsPlugin *plugin);
47 GType grits_plugin_get_type();
50 const gchar *grits_plugin_get_name(GritsPlugin *plugin);
52 const gchar *grits_plugin_get_description(GritsPlugin *plugin);
54 GtkWidget *grits_plugin_get_config(GritsPlugin *plugin);
59 typedef struct _GritsPlugins GritsPlugins;
61 #include "grits-viewer.h"
62 #include "grits-prefs.h"
65 * GritsPluginConstructor:
66 * @viewer: the viewer the plugin is associated with
67 * @prefs: preferences the plugin can use for storing informtion
69 * Create a new instance of a plugin. Each plugin should supply a constructor named
70 * grits_plugin_NAME_new in it's shared object.
72 * Returns: the new plugin
74 typedef GritsPlugin *(*GritsPluginConstructor)(GritsViewer *viewer, GritsPrefs *prefs);
76 struct _GritsPlugins {
82 GritsPlugins *grits_plugins_new(const gchar *dir, GritsPrefs *prefs);
84 void grits_plugins_free();
86 GList *grits_plugins_available(GritsPlugins *plugins);
88 GritsPlugin *grits_plugins_load(GritsPlugins *plugins, const char *name,
89 GritsViewer *viewer, GritsPrefs *prefs);
91 GritsPlugin *grits_plugins_enable(GritsPlugins *plugins, const char *name,
92 GritsViewer *viewer, GritsPrefs *prefs);
94 GList *grits_plugins_load_enabled(GritsPlugins *plugins,
95 GritsViewer *viewer, GritsPrefs *prefs);
97 gboolean grits_plugins_disable(GritsPlugins *plugins, const char *name);
99 gboolean grits_plugins_unload(GritsPlugins *plugins, const char *name);
101 void grits_plugins_foreach(GritsPlugins *plugins, GCallback callback, gpointer user_data);