* lib/text.h: Added text_get_line() declaration
[dia.git] / lib / plug-ins.h
blob41edc40f4245543550126bc4be05310dc1d86d0a
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1999 Alexander Larsson
4 * plug-ins.h: plugin loading handling interfaces for dia
5 * Copyright (C) 2000 James Henstridge
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef PLUG_INS_H
23 #define PLUG_INS_H
25 #include <glib.h>
26 #include <gmodule.h>
27 #include "diatypes.h"
29 G_BEGIN_DECLS
32 * The api version to ensure dia core and the plug-ins agree on
33 * talking about the same thing. If some incompatible change is
34 * made to the interface between plug-ins and core it needs to
35 * be incremented to allow the core to detect outdated plug-ins
36 * and avoid to load them - which otherwise would produce strange
37 * misinterpretations or even crashes.
39 * Some of the things which require a new plug-in api version are :
40 * - Changes to DiaRenderer's vtable, that is adding new methods,
41 * especially if they are shifting the placement of previously
42 * defined ones, see : lib/diarenderer.h
43 * - Changes to lib/object.h:_ObjectOps
44 * - Changes to _DiaExportFilter, _DiaImportFilter, lib/filter.h
45 * - New, incompatibe versions of libraries where both the core
46 * and the plug-in depend on (Dia >0.90 crashing on pygtk 1.x
47 * could have been avoided this way)
48 * The list is by no means complete. If in doubt about your change
49 * please ask on dia-list or alternative increment ;-) --hb
51 #define DIA_PLUGIN_API_VERSION 7
53 typedef enum {
54 DIA_PLUGIN_INIT_OK,
55 DIA_PLUGIN_INIT_ERROR
56 } PluginInitResult;
58 typedef PluginInitResult (*PluginInitFunc) (PluginInfo *info);
59 typedef gboolean (*PluginCanUnloadFunc) (PluginInfo *info);
60 typedef void (*PluginUnloadFunc) (PluginInfo *info);
62 /* functions for use by plugins ... */
64 gboolean dia_plugin_info_init(PluginInfo *info, gchar *name,
65 gchar *description,
66 PluginCanUnloadFunc can_unload_func,
67 PluginUnloadFunc unload_func);
69 gchar *dia_plugin_check_version(gint version);
72 /* functiosn for use by dia ... */
73 const gchar *dia_plugin_get_filename (PluginInfo *info);
74 const gchar *dia_plugin_get_name (PluginInfo *info);
75 const gchar *dia_plugin_get_description (PluginInfo *info);
76 const gpointer *dia_plugin_get_symbol (PluginInfo *info, const gchar *name);
78 gboolean dia_plugin_can_unload (PluginInfo *info);
79 gboolean dia_plugin_is_loaded (PluginInfo *info);
80 gboolean dia_plugin_get_inhibit_load (PluginInfo *info);
81 void dia_plugin_set_inhibit_load (PluginInfo *info, gboolean inhibit_load);
83 void dia_plugin_load (PluginInfo *info);
84 void dia_plugin_unload (PluginInfo *info);
86 void dia_register_plugin (const gchar *filename);
87 void dia_register_plugins_in_dir (const gchar *directory);
88 void dia_register_plugins (void);
89 void dia_register_builtin_plugin (PluginInitFunc init_func);
91 GList *dia_list_plugins(void);
93 void dia_pluginrc_write(void);
95 /* macro defining the version check that should be implemented by all
96 * plugins. */
97 #define DIA_PLUGIN_CHECK_INIT \
98 G_MODULE_EXPORT const gchar *g_module_check_init(GModule *gmodule); \
99 const gchar * \
100 g_module_check_init(GModule *gmodule) \
102 return dia_plugin_check_version(DIA_PLUGIN_API_VERSION); \
105 /* prototype for plugin init function (should be implemented by plugin) */
106 G_MODULE_EXPORT PluginInitResult dia_plugin_init(PluginInfo *info);
108 G_END_DECLS
110 #endif