]> Pileus Git - grits/blob - src/grits-plugin.h
Add cube GtkGL example
[grits] / src / grits-plugin.h
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 #ifndef __GRITS_PLUGIN_H__
19 #define __GRITS_PLUGIN_H__
20
21 #include <glib-object.h>
22 #include <gtk/gtk.h>
23
24 /********************
25  * Plugin interface *
26  ********************/
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))
31
32 typedef struct _GritsPlugin          GritsPlugin;
33 typedef struct _GritsPluginInterface GritsPluginInterface;
34
35 struct _GritsPluginInterface
36 {
37         GTypeInterface parent_iface;
38
39         /* Virtual data */
40         const gchar *name;
41         const gchar *description;
42
43         /* Virtual functions */
44         GtkWidget *(*get_config)(GritsPlugin *plugin);
45 };
46
47 GType grits_plugin_get_type();
48
49 /* Methods */
50 const gchar *grits_plugin_get_name(GritsPlugin *plugin);
51
52 const gchar *grits_plugin_get_description(GritsPlugin *plugin);
53
54 GtkWidget *grits_plugin_get_config(GritsPlugin *plugin);
55
56 /***************
57  * Plugins API *
58  ***************/
59 typedef struct _GritsPlugins GritsPlugins;
60
61 #include "grits-viewer.h"
62 #include "grits-prefs.h"
63
64 /**
65  * GritsPluginConstructor:
66  * @viewer: the viewer the plugin is associated with
67  * @prefs:  preferences the plugin can use for storing informtion
68  *
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.
71  *
72  * Returns: the new plugin
73  */
74 typedef GritsPlugin *(*GritsPluginConstructor)(GritsViewer *viewer, GritsPrefs *prefs);
75
76 struct _GritsPlugins {
77         gchar      *dir;
78         GList      *plugins;
79         GritsPrefs *prefs;
80 };
81
82 GritsPlugins *grits_plugins_new(const gchar *dir, GritsPrefs *prefs);
83
84 void grits_plugins_free();
85
86 GList *grits_plugins_available(GritsPlugins *plugins);
87
88 GritsPlugin *grits_plugins_load(GritsPlugins *plugins, const char *name,
89                 GritsViewer *viewer, GritsPrefs *prefs);
90
91 GritsPlugin *grits_plugins_enable(GritsPlugins *plugins, const char *name,
92                 GritsViewer *viewer, GritsPrefs *prefs);
93
94 GList *grits_plugins_load_enabled(GritsPlugins *plugins,
95                 GritsViewer *viewer, GritsPrefs *prefs);
96
97 gboolean grits_plugins_disable(GritsPlugins *plugins, const char *name);
98
99 gboolean grits_plugins_unload(GritsPlugins *plugins, const char *name);
100
101 void grits_plugins_foreach(GritsPlugins *plugins, GCallback callback, gpointer user_data);
102
103 #endif