gedit r6635 - in trunk: . gedit plugin-loaders/c plugin-loaders/python plugins/filebrowser
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6635 - in trunk: . gedit plugin-loaders/c plugin-loaders/python plugins/filebrowser
- Date: Sat, 29 Nov 2008 20:57:47 +0000 (UTC)
Author: pborelli
Date: Sat Nov 29 20:57:47 2008
New Revision: 6635
URL: http://svn.gnome.org/viewvc/gedit?rev=6635&view=rev
Log:
2008-11-29 Paolo Borelli <pborelli katamail com>
* gedit/gedit-object-module.h:
* gedit/gedit-plugin.h:
* gedit/gedit-plugin-loader.h:
Rework macros since gedit-plugin.h is public while object-module
is not and also switch to G_DEFINE_DYNAMIC_TYPE where possible.
Modified:
trunk/ChangeLog
trunk/gedit/gedit-object-module.h
trunk/gedit/gedit-plugin-loader.h
trunk/gedit/gedit-plugin.h
trunk/plugin-loaders/c/gedit-plugin-loader-c.c
trunk/plugin-loaders/python/gedit-plugin-loader-python.c
trunk/plugins/filebrowser/gedit-file-browser-plugin.c
Modified: trunk/gedit/gedit-object-module.h
==============================================================================
--- trunk/gedit/gedit-object-module.h (original)
+++ trunk/gedit/gedit-object-module.h Sat Nov 29 20:57:47 2008
@@ -49,8 +49,8 @@
#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_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;
@@ -87,142 +87,6 @@
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, \
- 0); \
- \
- CODE \
- \
- return g_define_type_id; \
-}
-
-/**
- * GEDIT_OBJECT_MODULE_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE):
- *
- * Utility macro used to register gobject types in plugins.
- */
-#define GEDIT_OBJECT_MODULE_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \
- GEDIT_OBJECT_MODULE_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
-
-/**
- * GEDIT_OBJECT_MODULE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
- *
- * Utility macro used to register interfaces for gobject types in plugins.
- */
-#define GEDIT_OBJECT_MODULE_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init) \
- const GInterfaceInfo object_name##_interface_info = \
- { \
- (GInterfaceInitFunc) iface_init, \
- NULL, \
- NULL \
- }; \
- \
- g_type_module_add_interface (module, \
- g_define_type_id, \
- TYPE_IFACE, \
- &object_name##_interface_info);
G_END_DECLS
#endif
Modified: trunk/gedit/gedit-plugin-loader.h
==============================================================================
--- trunk/gedit/gedit-plugin-loader.h (original)
+++ trunk/gedit/gedit-plugin-loader.h Sat Nov 29 20:57:47 2008
@@ -27,6 +27,8 @@
#include <gedit/gedit-plugin.h>
#include <gedit/gedit-plugin-info.h>
+G_BEGIN_DECLS
+
#define GEDIT_TYPE_PLUGIN_LOADER (gedit_plugin_loader_get_type ())
#define GEDIT_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_PLUGIN_LOADER, GeditPluginLoader))
#define GEDIT_IS_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_PLUGIN_LOADER))
@@ -58,50 +60,47 @@
const gchar *path);
void gedit_plugin_loader_unload (GeditPluginLoader *loader,
GeditPluginInfo *info);
-
void gedit_plugin_loader_garbage_collect (GeditPluginLoader *loader);
/**
- * GEDIT_PLUGIN_LOADER_REGISTER_TYPE_WITH_CODE(PluginLoaderName, plugin_loader_name, CODE):
- *
- * Utility macro used to register plugins with additional code.
- */
-#define GEDIT_PLUGIN_LOADER_REGISTER_TYPE_WITH_CODE(PluginLoaderName, plugin_loader_name, CODE) \
- GEDIT_OBJECT_MODULE_REGISTER_TYPE_WITH_CODE (register_gedit_plugin_loader, \
- PluginLoaderName, \
- plugin_loader_name, \
- G_TYPE_OBJECT, \
- GEDIT_OBJECT_MODULE_IMPLEMENT_INTERFACE (cplugin_loader_iface, GEDIT_TYPE_PLUGIN_LOADER, gedit_plugin_loader_iface_init); \
- CODE)
-/**
- * GEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginName, plugin_name):
- *
- * Utility macro used to register plugins.
- */
-#define GEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginName, plugin_name) \
- GEDIT_PLUGIN_LOADER_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, ;)
-
-/**
- * GEDIT_PLUGIN_LOADER_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE):
+ * GEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
*
- * Utility macro used to register gobject types in plugins with additional code.
+ * Utility macro used to register interfaces for gobject types in plugin loaders.
*/
-#define GEDIT_PLUGIN_LOADER_DEFINE_TYPE_WITH_CODE GEDIT_OBJECT_MODULE_DEFINE_TYPE_WITH_CODE
+#define GEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
+ 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);
/**
- * GEDIT_PLUGIN_LOADER_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE):
+ * GEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_interface_init):
*
- * Utility macro used to register gobject types in plugins.
+ * Utility macro used to register plugin loaders.
*/
-#define GEDIT_PLUGIN_LOADER_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \
- GEDIT_PLUGIN_LOADER_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
+#define GEDIT_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_iface_init) \
+ G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginLoaderName, \
+ plugin_loader_name, \
+ PARENT_TYPE, \
+ 0, \
+ GEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(GEDIT_TYPE_PLUGIN_LOADER, loader_iface_init)); \
+ \
+ \
+G_MODULE_EXPORT GType \
+register_gedit_plugin_loader (GTypeModule *type_module) \
+{ \
+ plugin_loader_name##_register_type (type_module); \
+ \
+ return plugin_loader_name##_get_type(); \
+}
-/**
- * GEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
- *
- * Utility macro used to register interfaces for gobject types in plugins.
- */
-#define GEDIT_PLUGIN_LOADER_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init) \
- GEDIT_OBJECT_MODULE_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init)
+G_END_DECLS
#endif /* __GEDIT_PLUGIN_LOADER_H__ */
Modified: trunk/gedit/gedit-plugin.h
==============================================================================
--- trunk/gedit/gedit-plugin.h (original)
+++ trunk/gedit/gedit-plugin.h Sat Nov 29 20:57:47 2008
@@ -35,7 +35,6 @@
#include <gedit/gedit-window.h>
#include <gedit/gedit-debug.h>
-#include <gedit/gedit-object-module.h>
/* TODO: add a .h file that includes all the .h files normally needed to
* develop a plugin */
@@ -118,16 +117,29 @@
*
* Utility macro used to register plugins with additional code.
*/
-#define GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE) \
- GEDIT_OBJECT_MODULE_REGISTER_TYPE_WITH_CODE (register_gedit_plugin, \
- PluginName, \
- plugin_name, \
- GEDIT_TYPE_PLUGIN, \
- /* Initialise the i18n stuff */ \
- bindtextdomain (GETTEXT_PACKAGE, GEDIT_LOCALEDIR); \
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \
+#define GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE) \
+ G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginName, \
+ plugin_name, \
+ GEDIT_TYPE_PLUGIN, \
+ 0, \
+ GTypeModule *module G_GNUC_UNUSED = type_module; /* back compat */ \
+ CODE) \
\
- 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 \
+register_gedit_plugin (GTypeModule *type_module) \
+{ \
+ plugin_name##_register_type (type_module); \
+ \
+ return plugin_name##_get_type(); \
+}
/**
* GEDIT_PLUGIN_REGISTER_TYPE(PluginName, plugin_name):
@@ -141,13 +153,63 @@
* GEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE):
*
* Utility macro used to register gobject types in plugins with additional code.
+ *
+ * Deprecated: use G_DEFINE_DYNAMIC_TYPE_EXTENDED instead
*/
-#define GEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE GEDIT_OBJECT_MODULE_DEFINE_TYPE_WITH_CODE
+#define GEDIT_PLUGIN_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 *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; \
+}
+
/**
* GEDIT_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE):
*
* Utility macro used to register gobject types in plugins.
+ *
+ * Deprecated: use G_DEFINE_DYNAMIC instead
*/
#define GEDIT_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \
GEDIT_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
@@ -158,10 +220,18 @@
* Utility macro used to register interfaces for gobject types in plugins.
*/
#define GEDIT_PLUGIN_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init) \
- GEDIT_OBJECT_MODULE_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init)
+ 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
#endif /* __GEDIT_PLUGIN_H__ */
-
-
Modified: trunk/plugin-loaders/c/gedit-plugin-loader-c.c
==============================================================================
--- trunk/plugin-loaders/c/gedit-plugin-loader-c.c (original)
+++ trunk/plugin-loaders/c/gedit-plugin-loader-c.c Sat Nov 29 20:57:47 2008
@@ -32,7 +32,8 @@
static void gedit_plugin_loader_iface_init (gpointer g_iface, gpointer iface_data);
-GEDIT_PLUGIN_LOADER_REGISTER_TYPE (GeditPluginLoaderC, gedit_plugin_loader_c);
+GEDIT_PLUGIN_LOADER_REGISTER_TYPE (GeditPluginLoaderC, gedit_plugin_loader_c, G_TYPE_OBJECT, gedit_plugin_loader_iface_init);
+
static const gchar *
gedit_plugin_loader_iface_get_name (void)
@@ -140,6 +141,11 @@
}
static void
+gedit_plugin_loader_c_class_finalize (GeditPluginLoaderCClass *klass)
+{
+}
+
+static void
gedit_plugin_loader_c_init (GeditPluginLoaderC *self)
{
self->priv = GEDIT_PLUGIN_LOADER_C_GET_PRIVATE (self);
Modified: trunk/plugin-loaders/python/gedit-plugin-loader-python.c
==============================================================================
--- trunk/plugin-loaders/python/gedit-plugin-loader-python.c (original)
+++ trunk/plugin-loaders/python/gedit-plugin-loader-python.c Sat Nov 29 20:57:47 2008
@@ -73,7 +73,7 @@
/* We retreive this to check for correct class hierarchy */
static PyTypeObject *PyGeditPlugin_Type;
-GEDIT_PLUGIN_LOADER_REGISTER_TYPE (GeditPluginLoaderPython, gedit_plugin_loader_python);
+GEDIT_PLUGIN_LOADER_REGISTER_TYPE (GeditPluginLoaderPython, gedit_plugin_loader_python, G_TYPE_OBJECT, gedit_plugin_loader_iface_init);
static PyObject *
@@ -619,6 +619,11 @@
}
static void
+gedit_plugin_loader_python_class_finalize (GeditPluginLoaderPythonClass *klass)
+{
+}
+
+static void
destroy_python_info (PythonInfo *info)
{
PyGILState_STATE state = pyg_gil_state_ensure ();
Modified: trunk/plugins/filebrowser/gedit-file-browser-plugin.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-plugin.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-plugin.c Sat Nov 29 20:57:47 2008
@@ -103,11 +103,11 @@
GeditWindow * window);
GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE (GeditFileBrowserPlugin, filetree_plugin, \
- gedit_file_browser_enum_and_flag_register_type (module); \
- gedit_file_browser_store_register_type (module); \
- gedit_file_bookmarks_store_register_type (module); \
- gedit_file_browser_view_register_type (module); \
- gedit_file_browser_widget_register_type (module); \
+ gedit_file_browser_enum_and_flag_register_type (type_module); \
+ gedit_file_browser_store_register_type (type_module); \
+ gedit_file_bookmarks_store_register_type (type_module); \
+ gedit_file_browser_view_register_type (type_module); \
+ gedit_file_browser_widget_register_type (type_module); \
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]