xed/xedit/xedit-plugin.h

241 lines
7.1 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.h
* This file is part of xedit
2011-11-07 13:46:58 -06:00
*
* Copyright (C) 2002-2005 - Paolo Maggi
*
* 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
* Modified by the xedit Team, 2002-2005. See the AUTHORS file for a
* list of people on the xedit Team.
2011-11-07 13:46:58 -06:00
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
2016-01-25 08:13:49 -06:00
#ifndef __XEDIT_PLUGIN_H__
#define __XEDIT_PLUGIN_H__
2011-11-07 13:46:58 -06:00
#include <glib-object.h>
2016-01-25 08:13:49 -06:00
#include <xedit/xedit-window.h>
#include <xedit/xedit-debug.h>
2011-11-07 13:46:58 -06:00
/* TODO: add a .h file that includes all the .h files normally needed to
* develop a plugin */
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_TYPE_PLUGIN (xedit_plugin_get_type())
#define XEDIT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_PLUGIN, XeditPlugin))
#define XEDIT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XEDIT_TYPE_PLUGIN, XeditPluginClass))
#define XEDIT_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XEDIT_TYPE_PLUGIN))
#define XEDIT_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XEDIT_TYPE_PLUGIN))
#define XEDIT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XEDIT_TYPE_PLUGIN, XeditPluginClass))
2011-11-07 13:46:58 -06:00
/*
* Main object structure
*/
2016-01-25 08:13:49 -06:00
typedef struct _XeditPlugin XeditPlugin;
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
struct _XeditPlugin
2011-11-07 13:46:58 -06:00
{
GObject parent;
};
/*
* Class definition
*/
2016-01-25 08:13:49 -06:00
typedef struct _XeditPluginClass XeditPluginClass;
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
struct _XeditPluginClass
2011-11-07 13:46:58 -06:00
{
GObjectClass parent_class;
/* Virtual public methods */
2016-01-25 08:13:49 -06:00
void (*activate) (XeditPlugin *plugin,
XeditWindow *window);
void (*deactivate) (XeditPlugin *plugin,
XeditWindow *window);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
void (*update_ui) (XeditPlugin *plugin,
XeditWindow *window);
2011-11-07 13:46:58 -06:00
GtkWidget *(*create_configure_dialog)
2016-01-25 08:13:49 -06:00
(XeditPlugin *plugin);
2011-11-07 13:46:58 -06:00
/* Plugins should not override this, it's handled automatically by
2016-01-25 08:13:49 -06:00
the XeditPluginClass */
2011-11-07 13:46:58 -06:00
gboolean (*is_configurable)
2016-01-25 08:13:49 -06:00
(XeditPlugin *plugin);
2011-11-07 13:46:58 -06:00
/* Padding for future expansion */
2016-01-25 08:13:49 -06:00
void (*_xedit_reserved1) (void);
void (*_xedit_reserved2) (void);
void (*_xedit_reserved3) (void);
void (*_xedit_reserved4) (void);
2011-11-07 13:46:58 -06:00
};
/*
* Public methods
*/
2016-01-25 08:13:49 -06:00
GType xedit_plugin_get_type (void) G_GNUC_CONST;
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
gchar *xedit_plugin_get_install_dir (XeditPlugin *plugin);
gchar *xedit_plugin_get_data_dir (XeditPlugin *plugin);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
void xedit_plugin_activate (XeditPlugin *plugin,
XeditWindow *window);
void xedit_plugin_deactivate (XeditPlugin *plugin,
XeditWindow *window);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
void xedit_plugin_update_ui (XeditPlugin *plugin,
XeditWindow *window);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
gboolean xedit_plugin_is_configurable (XeditPlugin *plugin);
GtkWidget *xedit_plugin_create_configure_dialog
(XeditPlugin *plugin);
2011-11-07 13:46:58 -06:00
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register plugins with additional code.
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE) \
2011-11-07 13:46:58 -06:00
G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginName, \
plugin_name, \
2016-01-25 08:13:49 -06:00
XEDIT_TYPE_PLUGIN, \
2011-11-07 13:46:58 -06:00
0, \
GTypeModule *module G_GNUC_UNUSED = type_module; /* back compat */ \
CODE) \
\
/* This is not very nice, but G_DEFINE_DYNAMIC wants it and our old macro \
* did not support it */ \
static void \
plugin_name##_class_finalize (PluginName##Class *klass) \
{ \
} \
\
\
G_MODULE_EXPORT GType \
2016-01-25 08:13:49 -06:00
register_xedit_plugin (GTypeModule *type_module) \
2011-11-07 13:46:58 -06:00
{ \
plugin_name##_register_type (type_module); \
\
return plugin_name##_get_type(); \
}
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_REGISTER_TYPE(PluginName, plugin_name):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register plugins.
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_REGISTER_TYPE(PluginName, plugin_name) \
XEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, ;)
2011-11-07 13:46:58 -06:00
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register gobject types in plugins with additional code.
*
* Deprecated: use G_DEFINE_DYNAMIC_TYPE_EXTENDED instead
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE) \
2011-11-07 13:46:58 -06:00
\
static GType g_define_type_id = 0; \
\
GType \
object_name##_get_type (void) \
{ \
return g_define_type_id; \
} \
\
static void object_name##_init (ObjectName *self); \
static void object_name##_class_init (ObjectName##Class *klass); \
static gpointer object_name##_parent_class = NULL; \
static void object_name##_class_intern_init (gpointer klass) \
{ \
object_name##_parent_class = g_type_class_peek_parent (klass); \
object_name##_class_init ((ObjectName##Class *) klass); \
} \
\
GType \
object_name##_register_type (GTypeModule *type_module) \
{ \
GTypeModule *module G_GNUC_UNUSED = type_module; /* back compat */ \
static const GTypeInfo our_info = \
{ \
sizeof (ObjectName##Class), \
NULL, /* base_init */ \
NULL, /* base_finalize */ \
(GClassInitFunc) object_name##_class_intern_init, \
NULL, \
NULL, /* class_data */ \
sizeof (ObjectName), \
0, /* n_preallocs */ \
(GInstanceInitFunc) object_name##_init \
}; \
\
g_define_type_id = g_type_module_register_type (type_module, \
PARENT_TYPE, \
#ObjectName, \
&our_info, \
0); \
\
CODE \
\
return g_define_type_id; \
}
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register gobject types in plugins.
*
* Deprecated: use G_DEFINE_DYNAMIC instead
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \
XEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
2011-11-07 13:46:58 -06:00
/**
2016-01-25 08:13:49 -06:00
* XEDIT_PLUGIN_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
2011-11-07 13:46:58 -06:00
*
* Utility macro used to register interfaces for gobject types in plugins.
*/
2016-01-25 08:13:49 -06:00
#define XEDIT_PLUGIN_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init) \
2011-11-07 13:46:58 -06:00
const GInterfaceInfo object_name##_interface_info = \
{ \
(GInterfaceInitFunc) iface_init, \
NULL, \
NULL \
}; \
\
g_type_module_add_interface (type_module, \
g_define_type_id, \
TYPE_IFACE, \
&object_name##_interface_info);
G_END_DECLS
2016-01-25 08:13:49 -06:00
#endif /* __XEDIT_PLUGIN_H__ */