medit/moo/mooedit/mooplugin-macro.h

206 lines
14 KiB
C
Raw Normal View History

2005-09-11 23:57:29 -07:00
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
*
* mooplugin-macro.h
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
2005-09-11 23:57:29 -07:00
*
* 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.
*
* See COPYING file that comes with this distribution.
*/
#ifndef __MOO_PLUGIN_MACRO_H__
#define __MOO_PLUGIN_MACRO_H__
#include <mooedit/mooplugin.h>
2005-09-11 23:57:29 -07:00
#define MOO_PLUGIN_DEFINE_INFO(plugin_name__,id__,name__, \
description__,author__,version__, \
langs__) \
\
static MooPluginParams plugin_name__##_plugin_params = { \
2005-11-05 07:32:04 -08:00
TRUE, \
TRUE \
}; \
\
2005-11-06 04:26:19 -08:00
static MooPluginPrefsParams plugin_name__##_plugin_prefs_params = { \
TRUE \
}; \
\
static MooPluginInfo plugin_name__##_plugin_info = { \
id__, \
name__, \
description__, \
author__, \
version__, \
langs__, \
&plugin_name__##_plugin_params, \
&plugin_name__##_plugin_prefs_params \
2005-09-11 23:57:29 -07:00
};
#define MOO_PLUGIN_DEFINE_FULL(Name__,name__, \
init__,deinit__, \
attach_win__,detach_win__, \
attach_doc__,detach_doc__, \
prefs_page_func__, \
WIN_PLUGIN_TYPE__,DOC_PLUGIN_TYPE__) \
\
static gpointer name__##_plugin_parent_class; \
\
typedef struct { \
MooPluginClass parent_class; \
} Name__##PluginClass; \
\
static void \
name__##_plugin_class_init (MooPluginClass *klass) \
{ \
name__##_plugin_parent_class = g_type_class_peek_parent (klass); \
\
klass->plugin_system_version = MOO_PLUGIN_CURRENT_VERSION; \
\
klass->init = (MooPluginInitFunc) init__; \
klass->deinit = (MooPluginDeinitFunc) deinit__; \
klass->attach_win = (MooPluginAttachWinFunc) attach_win__; \
klass->detach_win = (MooPluginDetachWinFunc) detach_win__; \
klass->attach_doc = (MooPluginAttachDocFunc) attach_doc__; \
klass->detach_doc = (MooPluginDetachDocFunc) detach_doc__; \
klass->create_prefs_page = (MooPluginPrefsPageFunc) prefs_page_func__; \
} \
\
static void \
name__##_plugin_instance_init (MooPlugin *plugin) \
{ \
plugin->info = &name__##_plugin_info; \
plugin->win_plugin_type = WIN_PLUGIN_TYPE__; \
plugin->doc_plugin_type = DOC_PLUGIN_TYPE__; \
} \
\
GType name__##_plugin_get_type (void) G_GNUC_CONST; \
\
GType \
name__##_plugin_get_type (void) \
{ \
static GType type__ = 0; \
\
if (G_UNLIKELY (type__ == 0)) \
{ \
static const GTypeInfo info__ = { \
sizeof (Name__##PluginClass), \
(GBaseInitFunc) NULL, \
(GBaseFinalizeFunc) NULL, \
(GClassInitFunc) name__##_plugin_class_init, \
(GClassFinalizeFunc) NULL, \
NULL, /* class_data */ \
sizeof (Name__##Plugin), \
0, /* n_preallocs */ \
(GInstanceInitFunc) name__##_plugin_instance_init, \
NULL /* value_table */ \
}; \
\
type__ = g_type_register_static (MOO_TYPE_PLUGIN, \
#Name__ "Plugin", &info__, 0); \
} \
\
return type__; \
}
#define MOO_WIN_PLUGIN_DEFINE(Name__,name__,create__,destroy__) \
\
typedef struct { \
MooWinPluginClass parent_class; \
} Name__##WindowPluginClass; \
\
GType name__##_window_plugin_get_type (void) G_GNUC_CONST; \
\
static gpointer name__##_window_plugin_parent_class = NULL; \
\
static void \
name__##_window_plugin_class_init (MooWinPluginClass *klass) \
{ \
name__##_window_plugin_parent_class = g_type_class_peek_parent (klass); \
klass->create = (MooWinPluginCreateFunc) create__; \
klass->destroy = (MooWinPluginDestroyFunc) destroy__; \
} \
\
GType \
name__##_window_plugin_get_type (void) \
{ \
static GType type__ = 0; \
\
if (G_UNLIKELY (type__ == 0)) \
{ \
static const GTypeInfo info__ = { \
sizeof (Name__##WindowPluginClass), \
(GBaseInitFunc) NULL, \
(GBaseFinalizeFunc) NULL, \
(GClassInitFunc) name__##_window_plugin_class_init, \
(GClassFinalizeFunc) NULL, \
NULL, /* class_data */ \
sizeof (Name__##WindowPlugin), \
0, /* n_preallocs */ \
NULL, \
NULL /* value_table */ \
}; \
\
type__ = g_type_register_static (MOO_TYPE_WIN_PLUGIN, \
#Name__ "WindowPlugin",&info__, 0);\
} \
\
return type__; \
2005-09-11 23:57:29 -07:00
}
#define MOO_DOC_PLUGIN_DEFINE(Name__,name__,create__,destroy__) \
2005-09-11 23:57:29 -07:00
\
typedef struct { \
MooDocPluginClass parent_class; \
} Name__##DocPluginClass; \
2005-09-11 23:57:29 -07:00
\
GType name__##_doc_plugin_get_type (void) G_GNUC_CONST; \
2005-09-11 23:57:29 -07:00
\
static gpointer name__##_doc_plugin_parent_class = NULL; \
2005-09-11 23:57:29 -07:00
\
static void \
name__##_doc_plugin_class_init (MooDocPluginClass *klass) \
2005-09-11 23:57:29 -07:00
{ \
name__##_doc_plugin_parent_class = g_type_class_peek_parent (klass); \
klass->create = (MooDocPluginCreateFunc) create__; \
klass->destroy = (MooDocPluginDestroyFunc) destroy__; \
2005-09-11 23:57:29 -07:00
} \
\
GType \
name__##_doc_plugin_get_type (void) \
2005-09-11 23:57:29 -07:00
{ \
static GType type__ = 0; \
\
if (G_UNLIKELY (type__ == 0)) \
{ \
static const GTypeInfo info__ = { \
sizeof (Name__##DocPluginClass), \
2005-09-11 23:57:29 -07:00
(GBaseInitFunc) NULL, \
(GBaseFinalizeFunc) NULL, \
(GClassInitFunc) name__##_doc_plugin_class_init, \
2005-09-11 23:57:29 -07:00
(GClassFinalizeFunc) NULL, \
NULL, /* class_data */ \
sizeof (Name__##DocPlugin), \
2005-09-11 23:57:29 -07:00
0, /* n_preallocs */ \
NULL, \
NULL /* value_table */ \
}; \
\
type__ = g_type_register_static (MOO_TYPE_DOC_PLUGIN, \
#Name__ "DocPlugin", &info__, 0); \
2005-09-11 23:57:29 -07:00
} \
\
return type__; \
}
#endif /* __MOO_PLUGIN_MACRO_H__ */