Commit 86332540 authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

Merged plugin system changes from new_plugins branch to trunk. Changes

	* configure.ac:
	* Makefile.am:
	* bindings/:
	* plugin-loaders/:
	* gedit/Makefile.am:
	* gedit/gedit-module.[ch]:
	* gedit/gedit-object-module.[ch]:
	* gedit/gedit-plugin.h:
	* gedit/gedit-plugin-info.c:
	* gedit/gedit-plugin-info-priv.h:
	* gedit/gedit-plugin-loader.[ch]:
	* gedit/gedit-plugins-engine.[ch]:
	* gedit/gedit-window.c:
	* gedit/gedit-window-private.h:	

	Merged plugin system changes from new_plugins branch to trunk. Changes
	include plugin loader refactoring in loadable modules and pyton
	plugin internals rework.

svn path=/trunk/; revision=6619
parent 3beed79a
2008-11-25 Jesse van den Kieboom <jesse@icecrew.nl>
* configure.ac:
* Makefile.am:
* bindings/:
* plugin-loaders/:
* gedit/Makefile.am:
* gedit/gedit-module.[ch]:
* gedit/gedit-object-module.[ch]:
* gedit/gedit-plugin.h:
* gedit/gedit-plugin-info.c:
* gedit/gedit-plugin-info-priv.h:
* gedit/gedit-plugin-loader.[ch]:
* gedit/gedit-plugins-engine.[ch]:
* gedit/gedit-window.c:
* gedit/gedit-window-private.h:
Merged plugin system changes from new_plugins branch to trunk. Changes
include plugin loader refactoring in loadable modules and pyton
plugin internals rework.
2008-11-24 Paolo Borelli <pborelli@katamail.com>
* plugins/filebrowser/gedit-file-browser-widget.c::
......
## Process this file with automake to produce Makefile.in
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = bindings gedit pixmaps po help data plugins docs
SUBDIRS = plugin-loaders gedit pixmaps po help data plugins docs
distuninstallcheck_listfiles = find . -type f -print | grep -v scrollkeeper
......
......@@ -189,7 +189,6 @@ GEDIT_LIBS="${GEDIT_LIBS}"
AC_SUBST(GEDIT_LIBS)
AC_SUBST(GEDIT_CFLAGS)
dnl ================================================================
dnl GConf related settings
dnl ================================================================
......@@ -345,10 +344,11 @@ fi
AC_SUBST(GEDIT_IMPLIB)
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
LOADER_LIBTOOL_FLAGS="-module -avoid-version"
AC_SUBST(LOADER_LIBTOOL_FLAGS)
AC_CONFIG_FILES([
Makefile
bindings/Makefile
bindings/python/Makefile
data/gedit.desktop.in
data/gedit-bugreport.sh
data/gedit.pc
......@@ -362,6 +362,10 @@ help/Makefile
help/eu/Makefile
help/ro/Makefile
pixmaps/Makefile
plugin-loaders/Makefile
plugin-loaders/c/Makefile
plugin-loaders/python/Makefile
plugin-loaders/python/bindings/Makefile
plugins/changecase/Makefile
plugins/docinfo/Makefile
plugins/externaltools/Makefile
......
......@@ -5,34 +5,30 @@ bin_PROGRAMS = gedit
noinst_LTLIBRARIES = libgedit.la
INCLUDES = \
-I$(top_srcdir) \
-I$(srcdir) \
-I$(srcdir)/smclient \
$(GEDIT_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DGEDIT_DATADIR=\""$(datadir)/gedit-2"\" \
-DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DGEDIT_UIDIR=\""$(datadir)/gedit-2/ui/"\" \
-DGEDIT_PLUGINDIR=\""$(libdir)/gedit-2/plugins"\" \
INCLUDES = \
-I$(top_srcdir) \
-I$(srcdir) \
-I$(srcdir)/smclient \
$(GEDIT_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DGEDIT_DATADIR=\""$(datadir)/gedit-2"\" \
-DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DGEDIT_UIDIR=\""$(datadir)/gedit-2/ui/"\" \
-DGEDIT_PLUGINDIR=\""$(libdir)/gedit-2/plugins"\" \
-DGEDIT_LOADERDIR=\""$(libdir)/gedit-2/plugin-loaders"\" \
-DGEDIT_ICONDIR=\""$(datadir)/gedit-2/icons"\"
if ENABLE_PYTHON
INCLUDES += \
$(NO_STRICT_ALIASING_CFLAGS) \
$(PYGTK_CFLAGS) \
$(PYTHON_CFLAGS) \
$(AM_CFLAGS)
endif
gedit_SOURCES = \
gedit.c
gedit_SOURCES = gedit.c
gedit_LDADD = libgedit.la $(GEDIT_LIBS)
if PLATFORM_WIN32
gedit_LDFLAGS = -Wl,--export-all-symbols -Wl,--out-implib,libgedit-$(GEDIT_API_VERSION).a
else
gedit_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
endif
......@@ -42,10 +38,6 @@ libgedit_la_LIBADD = \
dialogs/libdialogs.la \
smclient/libeggsmclient.la
if ENABLE_PYTHON
libgedit_la_LIBADD += $(top_builddir)/bindings/python/gedit.la
endif
# GEDIT_LIBS must be the last to ensure correct order on some platforms
libgedit_la_LIBADD += $(GEDIT_LIBS)
......@@ -63,7 +55,7 @@ NOINST_H_FILES = \
gedit-plugin-info-priv.h \
gedit-plugin-manager.h \
gedit-plugins-engine.h \
gedit-module.h \
gedit-object-module.h \
gedit-ui.h \
gedit-window-private.h \
gedit-documents-panel.h \
......@@ -83,12 +75,6 @@ NOINST_H_FILES = \
gedittextregion.h \
gedit-session.h
if ENABLE_PYTHON
NOINST_H_FILES += \
gedit-python-module.h \
gedit-python-plugin.h
endif
INST_H_FILES = \
gedit-app.h \
gedit-convert.h \
......@@ -103,6 +89,7 @@ INST_H_FILES = \
gedit-notebook.h \
gedit-panel.h \
gedit-plugin.h \
gedit-plugin-loader.h \
gedit-prefs-manager-app.h \
gedit-prefs-manager.h \
gedit-progress-message-area.h \
......@@ -147,11 +134,12 @@ libgedit_la_SOURCES = \
gedit-language-manager.c \
gedit-message-area.c \
gedit-metadata-manager.c \
gedit-module.c \
gedit-object-module.c \
gedit-notebook.c \
gedit-panel.c \
gedit-plugin-info.c \
gedit-plugin.c \
gedit-plugin-loader.c \
gedit-plugin-manager.c \
gedit-plugins-engine.c \
gedit-prefs-manager-app.c \
......@@ -173,15 +161,6 @@ libgedit_la_SOURCES = \
$(NOINST_H_FILES) \
$(INST_H_FILES)
if ENABLE_PYTHON
libgedit_la_SOURCES += \
gedit-python-module.c \
gedit-python-module.h \
gedit-python-plugin.c \
gedit-python-plugin.h
endif
gedit-enum-types.h: gedit-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
(cd $(srcdir) && $(GLIB_MKENUMS) --template gedit-enum-types.h.template $(INST_H_FILES)) > $@
......
/*
* gedit-module.c
* gedit-object-module.c
* This file is part of gedit
*
* Copyright (C) 2005 - Paolo Maggi
* Copyright (C) 2005 - Paolo Maggi
* 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
......@@ -33,54 +34,66 @@
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
* $Id: gedit-module.c 6314 2008-06-05 12:57:53Z pborelli $
*/
#include "config.h"
#include "gedit-module.h"
#include "gedit-object-module.h"
#include "gedit-debug.h"
typedef GType (*GeditModuleRegisterFunc) (GTypeModule *);
typedef GType (*GeditObjectModuleRegisterFunc) (GTypeModule *);
enum {
PROP_0,
PROP_MODULE_NAME,
PROP_PATH
PROP_PATH,
PROP_TYPE_REGISTRATION
};
G_DEFINE_TYPE (GeditModule, gedit_module, G_TYPE_TYPE_MODULE);
struct _GeditObjectModulePrivate
{
GModule *library;
GType type;
gchar *path;
gchar *module_name;
gchar *type_registration;
};
G_DEFINE_TYPE (GeditObjectModule, gedit_object_module, G_TYPE_TYPE_MODULE);
static gboolean
gedit_module_load (GTypeModule *gmodule)
gedit_object_module_load (GTypeModule *gmodule)
{
GeditModule *module = GEDIT_MODULE (gmodule);
GeditModuleRegisterFunc register_func;
GeditObjectModule *module = GEDIT_OBJECT_MODULE (gmodule);
GeditObjectModuleRegisterFunc register_func;
gchar *path;
gedit_debug_message (DEBUG_PLUGINS, "Loading %s module from %s",
module->module_name, module->path);
module->priv->module_name, module->priv->path);
path = g_module_build_path (module->path, module->module_name);
path = g_module_build_path (module->priv->path, module->priv->module_name);
g_return_val_if_fail (path != NULL, FALSE);
gedit_debug_message (DEBUG_PLUGINS, "Module filename: %s", path);
module->library = g_module_open (path, 0);
module->priv->library = g_module_open (path,
G_MODULE_BIND_LAZY);
g_free (path);
if (module->library == NULL)
if (module->priv->library == NULL)
{
g_warning ("%s: %s", module->module_name, g_module_error());
g_warning ("%s: %s", module->priv->module_name, g_module_error());
return FALSE;
}
/* extract symbols from the lib */
if (!g_module_symbol (module->library, "register_gedit_plugin",
if (!g_module_symbol (module->priv->library, module->priv->type_registration,
(void *) &register_func))
{
g_warning ("%s: %s", module->module_name, g_module_error());
g_module_close (module->library);
g_warning ("%s: %s", module->priv->module_name, g_module_error());
g_module_close (module->priv->library);
return FALSE;
}
......@@ -89,17 +102,17 @@ gedit_module_load (GTypeModule *gmodule)
* returned TRUE */
if (register_func == NULL)
{
g_warning ("Symbol 'register_gedit_plugin' should not be NULL");
g_module_close (module->library);
g_warning ("Symbol '%s' should not be NULL", module->priv->type_registration);
g_module_close (module->priv->library);
return FALSE;
}
module->type = register_func (gmodule);
module->priv->type = register_func (gmodule);
if (module->type == 0)
if (module->priv->type == 0)
{
g_warning ("Invalid gedit plugin contained by module %s", module->module_name);
g_warning ("Invalid object contained by module %s", module->priv->module_name);
return FALSE;
}
......@@ -107,81 +120,85 @@ gedit_module_load (GTypeModule *gmodule)
}
static void
gedit_module_unload (GTypeModule *gmodule)
gedit_object_module_unload (GTypeModule *gmodule)
{
GeditModule *module = GEDIT_MODULE (gmodule);
GeditObjectModule *module = GEDIT_OBJECT_MODULE (gmodule);
gedit_debug_message (DEBUG_PLUGINS, "Unloading %s", module->path);
gedit_debug_message (DEBUG_PLUGINS, "Unloading %s", module->priv->path);
g_module_close (module->library);
g_module_close (module->priv->library);
module->library = NULL;
module->type = 0;
module->priv->library = NULL;
module->priv->type = 0;
}
static void
gedit_module_class_real_garbage_collect (void)
gedit_object_module_init (GeditObjectModule *module)
{
/* Do nothing */
gedit_debug_message (DEBUG_PLUGINS, "GeditObjectModule %p initialising", module);
module->priv = G_TYPE_INSTANCE_GET_PRIVATE (module,
GEDIT_TYPE_OBJECT_MODULE,
GeditObjectModulePrivate);
}
static void
gedit_module_init (GeditModule *module)
gedit_object_module_finalize (GObject *object)
{
gedit_debug_message (DEBUG_PLUGINS, "GeditModule %p initialising", module);
}
GeditObjectModule *module = GEDIT_OBJECT_MODULE (object);
static void
gedit_module_finalize (GObject *object)
{
GeditModule *module = GEDIT_MODULE (object);
gedit_debug_message (DEBUG_PLUGINS, "GeditModule %p finalising", module);
gedit_debug_message (DEBUG_PLUGINS, "GeditObjectModule %p finalising", module);
g_free (module->path);
g_free (module->module_name);
g_free (module->priv->path);
g_free (module->priv->module_name);
g_free (module->priv->type_registration);
G_OBJECT_CLASS (gedit_module_parent_class)->finalize (object);
G_OBJECT_CLASS (gedit_object_module_parent_class)->finalize (object);
}
static void
gedit_module_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
gedit_object_module_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GeditModule *module = GEDIT_MODULE (object);
GeditObjectModule *module = GEDIT_OBJECT_MODULE (object);
switch (prop_id)
{
case PROP_MODULE_NAME:
g_value_set_string (value, module->module_name);
g_value_set_string (value, module->priv->module_name);
break;
case PROP_PATH:
g_value_set_string (value, module->path);
g_value_set_string (value, module->priv->path);
break;
case PROP_TYPE_REGISTRATION:
g_value_set_string (value, module->priv->type_registration);
default:
g_return_if_reached ();
}
}
static void
gedit_module_set_property (GObject *object,
gedit_object_module_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GeditModule *module = GEDIT_MODULE (object);
GeditObjectModule *module = GEDIT_OBJECT_MODULE (object);
switch (prop_id)
{
case PROP_MODULE_NAME:
module->module_name = g_value_dup_string (value);
module->priv->module_name = g_value_dup_string (value);
g_type_module_set_name (G_TYPE_MODULE (object),
module->module_name);
module->priv->module_name);
break;
case PROP_PATH:
module->path = g_value_dup_string (value);
module->priv->path = g_value_dup_string (value);
break;
case PROP_TYPE_REGISTRATION:
module->priv->type_registration = g_value_dup_string (value);
break;
default:
g_return_if_reached ();
......@@ -189,25 +206,23 @@ gedit_module_set_property (GObject *object,
}
static void
gedit_module_class_init (GeditModuleClass *klass)
gedit_object_module_class_init (GeditObjectModuleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
object_class->set_property = gedit_module_set_property;
object_class->get_property = gedit_module_get_property;
object_class->finalize = gedit_module_finalize;
object_class->set_property = gedit_object_module_set_property;
object_class->get_property = gedit_object_module_get_property;
object_class->finalize = gedit_object_module_finalize;
module_class->load = gedit_module_load;
module_class->unload = gedit_module_unload;
klass->garbage_collect = gedit_module_class_real_garbage_collect;
module_class->load = gedit_object_module_load;
module_class->unload = gedit_object_module_unload;
g_object_class_install_property (object_class,
PROP_MODULE_NAME,
g_param_spec_string ("module-name",
"Module Name",
"The module to load for this plugin",
"The module to load for this object",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
......@@ -220,39 +235,82 @@ gedit_module_class_init (GeditModuleClass *klass)
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_TYPE_REGISTRATION,
g_param_spec_string ("type-registration",
"Type Registration",
"The name of the type registration function",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (klass, sizeof (GeditObjectModulePrivate));
}
void
gedit_module_class_garbage_collect (GeditModuleClass *klass)
GeditObjectModule *
gedit_object_module_new (const gchar *module_name,
const gchar *path,
const gchar *type_registration)
{
g_return_if_fail (GEDIT_IS_MODULE_CLASS (klass));
GEDIT_MODULE_CLASS (klass)->garbage_collect ();
return (GeditObjectModule *)g_object_new (GEDIT_TYPE_OBJECT_MODULE,
"module-name",
module_name,
"path",
path,
"type-registration",
type_registration,
NULL);
}
GObject *
gedit_module_new_object (GeditModule *module)
gedit_object_module_new_object (GeditObjectModule *module,
const gchar *first_property_name,
...)
{
g_return_val_if_fail (module->type != 0, NULL);
va_list var_args;
GObject *result;
g_return_val_if_fail (module->priv->type != 0, NULL);
gedit_debug_message (DEBUG_PLUGINS, "Creating object of type %s",
g_type_name (module->type));
g_type_name (module->priv->type));
va_start (var_args, first_property_name);
result = g_object_new_valist (module->priv->type, first_property_name, var_args);
va_end (var_args);
return result;
}
return g_object_new (module->type, NULL);
const gchar *
gedit_object_module_get_path (GeditObjectModule *module)
{
g_return_val_if_fail (GEDIT_IS_OBJECT_MODULE (module), NULL);
return module->priv->path;
}
const gchar *
gedit_module_get_path (GeditModule *module)
gedit_object_module_get_module_name (GeditObjectModule *module)
{
g_return_val_if_fail (GEDIT_IS_MODULE (module), NULL);
g_return_val_if_fail (GEDIT_IS_OBJECT_MODULE (module), NULL);
return module->path;
return module->priv->module_name;
}
const gchar *
gedit_module_get_module_name (GeditModule *module)
gedit_object_module_get_type_registration (GeditObjectModule *module)
{
g_return_val_if_fail (GEDIT_IS_MODULE (module), NULL);
g_return_val_if_fail (GEDIT_IS_OBJECT_MODULE (module), NULL);
return module->module_name;
return module->priv->module_name;
}
GType
gedit_object_module_get_object_type (GeditObjectModule *module)
{
g_return_val_if_fail (GEDIT_IS_OBJECT_MODULE (module), 0);
return module->priv->type;
}
/*
* gedit-object-module.h
* This file is part of gedit
*
* Copyright (C) 2005 - Paolo Maggi
* 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
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* This is a modified version of gedit-module.h from Epiphany source code.
* Here the original copyright assignment:
*
* Copyright (C) 2003 Marco Pesenti Gritti
* Copyright (C) 2003, 2004 Christian Persch
*
*/
/*
* Modified by the gedit Team, 2005. See the AUTHORS file for a
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*
* $Id: gedit-module.h 6263 2008-05-05 10:52:10Z sfre $
*/
#ifndef __GEDIT_OBJECT_MODULE_H__
#define __GEDIT_OBJECT_MODULE_H__
#include <glib-object.h>
#include <gmodule.h>
#include <stdarg.h>
G_BEGIN_DECLS
#define GEDIT_TYPE_OBJECT_MODULE (gedit_object_module_get_type ())
#define GEDIT_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_OBJECT_MODULE, GeditObjectModule))
#define GEDIT_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_OBJECT_MODULE, GeditObjectModuleClass))
#define GEDIT_IS_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_OBJECT_MODULE))
#define GEDIT_IS_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_OBJECT_MODULE))
#define GEDIT_OBJECT_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_OBJECT_MODULE, GeditObjectModuleClass))
typedef struct _GeditObjectModule GeditObjectModule;
typedef struct _GeditObjectModulePrivate GeditObjectModulePrivate;
struct _GeditObjectModule
{
GTypeModule parent;
GeditObjectModulePrivate *priv;
};
typedef struct _GeditObjectModuleClass GeditObjectModuleClass;
struct _GeditObjectModuleClass
{
GTypeModuleClass parent_class;
/* Virtual class methods */
void (* garbage_collect) ();
};
GType gedit_object_module_get_type (void) G_GNUC_CONST;
GeditObjectModule *gedit_object_module_new (const gchar *module_name,
const gchar *path,
const gchar *type_registration);
GObject *gedit_object_module_new_object (GeditObjectModule *module,
const gchar *first_property_name,
...);
GType gedit_object_module_get_object_type (GeditObjectModule *module);
const gchar *gedit_object_module_get_path (GeditObjectModule *module);
const gchar *gedit_object_module_get_module_name (GeditObjectModule *module);
const gchar *gedit_object_module_get_type_registration (GeditObjectModule *module);
/**
* GEDIT_OBJECT_MODULE_REGISTER_TYPE_WITH_CODE(type_registration, TypeName, type_name, PARENT_TYPE, CODE):
*
* Utility macro used to register types with additional code.
*/
#define GEDIT_OBJECT_MODULE_REGISTER_TYPE_WITH_CODE(type_registration, TypeName, type_name, PARENT_TYPE, CODE) \
\
static GType g_define_type_id = 0; \
\
GType \
type_name##_get_type (void) \
{ \
return g_define_type_id; \
} \
\
static void type_name##_init (TypeName *self); \
static void type_name##_class_init (TypeName##Class *klass); \
static gpointer type_name##_parent_class = NULL; \
static void type_name##_class_intern_init (gpointer klass) \
{ \
type_name##_parent_class = g_type_class_peek_parent (klass); \
type_name##_class_init ((TypeName##Class *) klass); \
} \
\
G_MODULE_EXPORT GType \
type_registration (GTypeModule *module) \
{ \
static const GTypeInfo our_info = \
{ \
sizeof (TypeName##Class), \
NULL, /* base_init */ \
NULL, /* base_finalize */ \
(GClassInitFunc) type_name##_class_intern_init, \
NULL, \
NULL, /* class_data */ \
sizeof (TypeName), \
0, /* n_preallocs */ \
(GInstanceInitFunc) type_name##_init \
}; \
\
g_define_type_id = g_type_module_register_type (module, \
PARENT_TYPE, \
#TypeName, \
&our_info, \
0); \
\
CODE \
\
return g_define_type_id; \
}
/**
* GEDIT_PLUGIN_REGISTER_TYPE(TypeName, type_name):
*
* Utility macro used to register plugins.
*/
#define GEDIT_OBJECT_MODULE_REGISTER_TYPE(type_registration, TypeName, type_name, PARENT_TYPE) \
GEDIT_OBJECT_MODULE_REGISTER_TYPE_WITH_CODE(type_registration, TypeName, type_name, PARENT_TYPE, ;)
/**
* GEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE):
*
* Utility macro used to register gobject types in plugins with additional code.
*/
#define GEDIT_OBJECT_MODULE_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE) \
\
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 *module) \
{ \
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 (module, \
PARENT_TYPE, \
#ObjectName, \
&our_info, \