xed/xedit/xedit-plugin-loader.h

107 lines
3.7 KiB
C
Raw Permalink Normal View History

2011-11-07 13:46:58 -06:00
/*
2016-01-25 08:13:49 -06:00
* xedit-plugin-loader.h
* This file is part of xedit
2011-11-07 13:46:58 -06:00
*
* Copyright (C) 2008 - Jesse van den Kieboom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2012-11-18 19:54:49 -06:00
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
2011-11-07 13:46:58 -06:00
*/
2016-01-25 08:13:49 -06:00
#ifndef __XEDIT_PLUGIN_LOADER_H__
#define __XEDIT_PLUGIN_LOADER_H__
2011-11-07 13:46:58 -06:00
#include <glib-object.h>
2016-01-25 08:13:49 -06:00
#include <xedit/xedit-plugin.h>
#include <xedit/xedit-plugin-info.h>
2011-11-07 13:46:58 -06:00
G_BEGIN_DECLS
2016-01-25 08:13:49 -06:00
#define XEDIT_TYPE_PLUGIN_LOADER (xedit_plugin_loader_get_type ())
#define XEDIT_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XEDIT_TYPE_PLUGIN_LOADER, XeditPluginLoader))
#define XEDIT_IS_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XEDIT_TYPE_PLUGIN_LOADER))
#define XEDIT_PLUGIN_LOADER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), XEDIT_TYPE_PLUGIN_LOADER, XeditPluginLoaderInterface))
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
typedef struct _XeditPluginLoader XeditPluginLoader; /* dummy object */
typedef struct _XeditPluginLoaderInterface XeditPluginLoaderInterface;
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
struct _XeditPluginLoaderInterface {
2011-11-07 13:46:58 -06:00
GTypeInterface parent;
const gchar *(*get_id) (void);
2016-01-25 08:13:49 -06:00
XeditPlugin *(*load) (XeditPluginLoader *loader,
XeditPluginInfo *info,
2011-11-07 13:46:58 -06:00
const gchar *path);
2016-01-25 08:13:49 -06:00
void (*unload) (XeditPluginLoader *loader,
XeditPluginInfo *info);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
void (*garbage_collect) (XeditPluginLoader *loader);
2011-11-07 13:46:58 -06:00
};
2016-01-25 08:13:49 -06:00
GType xedit_plugin_loader_get_type (void);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
const gchar *xedit_plugin_loader_type_get_id (GType type);
XeditPlugin *xedit_plugin_loader_load (XeditPluginLoader *loader,
XeditPluginInfo *info,
2011-11-07 13:46:58 -06:00
const gchar *path);
2016-01-25 08:13:49 -06:00
void xedit_plugin_loader_unload (XeditPluginLoader *loader,
XeditPluginInfo *info);
void xedit_plugin_loader_garbage_collect (XeditPluginLoader *loader);
2011-11-07 13:46:58 -06:00
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register interfaces for gobject types in plugin loaders.
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
2011-11-07 13:46:58 -06:00
const GInterfaceInfo g_implement_interface_info = \
{ \
(GInterfaceInitFunc) iface_init, \
NULL, \
NULL \
}; \
\
g_type_module_add_interface (type_module, \
g_define_type_id, \
TYPE_IFACE, \
&g_implement_interface_info);
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_interface_init):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register plugin loaders.
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_iface_init) \
2011-11-07 13:46:58 -06:00
G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginLoaderName, \
plugin_loader_name, \
PARENT_TYPE, \
0, \
2016-01-25 08:13:49 -06:00
XEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(XEDIT_TYPE_PLUGIN_LOADER, loader_iface_init)); \
2011-11-07 13:46:58 -06:00
\
\
G_MODULE_EXPORT GType \
2016-01-25 08:13:49 -06:00
register_xedit_plugin_loader (GTypeModule *type_module) \
2011-11-07 13:46:58 -06:00
{ \
plugin_loader_name##_register_type (type_module); \
\
return plugin_loader_name##_get_type(); \
}
G_END_DECLS
2016-01-25 08:13:49 -06:00
#endif /* __XEDIT_PLUGIN_LOADER_H__ */