[totem/peas-0.5.4: 1/4] Rearrange the TOTEM_PLUGIN_REGISTER macros to share more code



commit 8b6ec9d8d0aad070d984c261902e5f50894f2fd1
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Aug 5 09:44:38 2010 +0100

    Rearrange the TOTEM_PLUGIN_REGISTER macros to share more code

 src/plugins/totem-plugin.h |  116 ++++++++++++++++++--------------------------
 1 files changed, 47 insertions(+), 69 deletions(-)
---
diff --git a/src/plugins/totem-plugin.h b/src/plugins/totem-plugin.h
index e2f7412..a3598de 100644
--- a/src/plugins/totem-plugin.h
+++ b/src/plugins/totem-plugin.h
@@ -36,6 +36,39 @@
 
 G_BEGIN_DECLS
 
+#define __TOTEM_PLUGIN_REGISTER_BEGIN(TYPE_NAME, TypeName, type_name, TYPE_CODE, register_code) \
+	static void impl_activate (PeasActivatable *plugin, GObject *totem);							\
+	static void impl_deactivate (PeasActivatable *plugin, GObject *totem);							\
+	G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);							\
+	static void peas_activatable_iface_init (PeasActivatableInterface *iface);						\
+																\
+	G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName,										\
+	                                type_name,										\
+	                                PEAS_TYPE_EXTENSION_BASE,								\
+	                                0,											\
+	                                G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, peas_activatable_iface_init)	\
+	                                { TYPE_CODE; })										\
+																\
+	G_MODULE_EXPORT void													\
+	peas_register_types (PeasObjectModule *module)										\
+	{															\
+		type_name##_register_type (G_TYPE_MODULE (module));								\
+		peas_object_module_register_extension_type (module, PEAS_TYPE_ACTIVATABLE, TYPE_NAME);				\
+		register_code													\
+	}															\
+																\
+	static void														\
+	type_name##_class_finalize (TypeName##Class *klass)									\
+	{															\
+	}															\
+																\
+	static void														\
+	peas_activatable_iface_init (PeasActivatableInterface *iface)								\
+	{															\
+		iface->activate = impl_activate;										\
+		iface->deactivate = impl_deactivate;										\
+	}
+
 /**
  * TOTEM_PLUGIN_REGISTER:
  * @TYPE_NAME: the name of the plugin type, in UPPER_CASE
@@ -45,35 +78,8 @@ G_BEGIN_DECLS
  * Registers a plugin with the Totem plugin system, including registering the type specified in the parameters and declaring its activate and
  * deactivate functions.
  **/
-#define TOTEM_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name)			\
-	static void impl_activate (PeasActivatable *plugin, GObject *totem);	\
-	static void impl_deactivate (PeasActivatable *plugin, GObject *totem);	\
-	G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);	\
-	static void peas_activatable_iface_init (PeasActivatableInterface *iface); \
-	G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName,				\
-					type_name,				\
-					PEAS_TYPE_EXTENSION_BASE,		\
-					0,					\
-					G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, \
-								       peas_activatable_iface_init)) \
-	static void								\
-	peas_activatable_iface_init (PeasActivatableInterface *iface)		\
-	{									\
-		iface->activate = impl_activate;				\
-		iface->deactivate = impl_deactivate;				\
-	}									\
-	static void								\
-	type_name##_class_finalize (TypeName##Class *klass)		\
-	{									\
-	}									\
-	G_MODULE_EXPORT void							\
-	peas_register_types (PeasObjectModule *module)				\
-	{									\
-		type_name##_register_type (G_TYPE_MODULE (module));		\
-		peas_object_module_register_extension_type (module,		\
-							    PEAS_TYPE_ACTIVATABLE, \
-							    TYPE_NAME);		\
-	}
+#define TOTEM_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name) \
+	__TOTEM_PLUGIN_REGISTER_BEGIN(TYPE_NAME, TypeName, type_name,,)
 
 /**
  * TOTEM_PLUGIN_REGISTER_CONFIGURABLE:
@@ -84,46 +90,18 @@ G_BEGIN_DECLS
  * Registers a configurable plugin with the Totem plugin system, including registering the type specified in the parameters and declaring its activate
  * and deactivate and widget creation functions.
  **/
-#define TOTEM_PLUGIN_REGISTER_CONFIGURABLE(TYPE_NAME, TypeName, type_name)	\
-	static void impl_activate (PeasActivatable *plugin, GObject *totem);	\
-	static void impl_deactivate (PeasActivatable *plugin, GObject *totem);	\
-	static GtkWidget *impl_create_configure_widget (PeasUIConfigurable *configurable); \
-	G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);	\
-	static void peas_activatable_iface_init (PeasActivatableInterface *iface); \
-	static void peas_ui_configurable_iface_init (PeasUIConfigurableInterface *iface); \
-	G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName,				\
-					type_name,				\
-					PEAS_TYPE_EXTENSION_BASE,		\
-					0,					\
-					G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, \
-								       peas_activatable_iface_init) \
-					G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_UI_TYPE_CONFIGURABLE, \
-								       peas_ui_configurable_iface_init)) \
-	static void								\
-	peas_activatable_iface_init (PeasActivatableInterface *iface)		\
-	{									\
-		iface->activate = impl_activate;				\
-		iface->deactivate = impl_deactivate;				\
-	}									\
-	static void								\
-	peas_ui_configurable_iface_init (PeasUIConfigurableInterface *iface)	\
-	{									\
-		iface->create_configure_widget = impl_create_configure_widget;	\
-	}									\
-	static void								\
-	type_name##_class_finalize (TypeName##Class *klass)			\
-	{									\
-	}									\
-	G_MODULE_EXPORT void							\
-	peas_register_types (PeasObjectModule *module)				\
-	{									\
-		type_name##_register_type (G_TYPE_MODULE (module));		\
-		peas_object_module_register_extension_type (module,		\
-							    PEAS_TYPE_ACTIVATABLE, \
-							    TYPE_NAME);		\
-		peas_object_module_register_extension_type (module,		\
-							    PEAS_UI_TYPE_CONFIGURABLE, \
-							    TYPE_NAME);		\
+#define TOTEM_PLUGIN_REGISTER_CONFIGURABLE(TYPE_NAME, TypeName, type_name) \
+	static GtkWidget *impl_create_configure_widget (PeasUIConfigurable *configurable);						\
+	static void peas_ui_configurable_iface_init (PeasUIConfigurableInterface *iface);						\
+																	\
+	__TOTEM_PLUGIN_REGISTER_BEGIN(TYPE_NAME, TypeName, type_name,									\
+	                              (G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_UI_TYPE_CONFIGURABLE, peas_ui_configurable_iface_init)),	\
+	                              peas_object_module_register_extension_type (module, PEAS_UI_TYPE_CONFIGURABLE, TYPE_NAME);)	\
+																	\
+	static void															\
+	peas_ui_configurable_iface_init (PeasUIConfigurableInterface *iface)								\
+	{																\
+		iface->create_configure_widget = impl_create_configure_widget;								\
 	}
 
 G_END_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]