[totem] Factor out common code in plugin macros to a new _TOTEM_PLUGIN_REGISTER macro
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Factor out common code in plugin macros to a new _TOTEM_PLUGIN_REGISTER macro
- Date: Sun, 5 Sep 2010 01:28:37 +0000 (UTC)
commit df5f7f673be84c80743ac00b9d94b62b83b9605b
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Sep 5 01:19:49 2010 +0100
Factor out common code in plugin macros to a new _TOTEM_PLUGIN_REGISTER macro
src/plugins/totem-plugin.h | 92 ++++++++++----------------------------------
1 files changed, 21 insertions(+), 71 deletions(-)
---
diff --git a/src/plugins/totem-plugin.h b/src/plugins/totem-plugin.h
index d97f2e8..6734eb8 100644
--- a/src/plugins/totem-plugin.h
+++ b/src/plugins/totem-plugin.h
@@ -42,11 +42,13 @@ G_BEGIN_DECLS
* @TYPE_NAME: the name of the plugin type, in UPPER_CASE
* @TypeName: the name of the plugin type, in CamelCase
* @type_name: the name of the plugin type, in lower_case
+ * @TYPE_CODE: code to go in the fifth parameter to %G_DEFINE_DYNAMIC_TYPE_EXTENDED
+ * @REGISTER_CODE: code to go in the peas_register_types() exported function
*
* 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) \
+#define _TOTEM_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name, TYPE_CODE, REGISTER_CODE) \
static void impl_activate (PeasActivatable *plugin); \
static void impl_deactivate (PeasActivatable *plugin); \
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); \
@@ -60,7 +62,8 @@ G_BEGIN_DECLS
PEAS_TYPE_EXTENSION_BASE, \
0, \
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, \
- peas_activatable_iface_init)) \
+ peas_activatable_iface_init) \
+ TYPE_CODE) \
static void \
peas_activatable_iface_init (PeasActivatableInterface *iface) \
{ \
@@ -110,9 +113,22 @@ G_BEGIN_DECLS
peas_object_module_register_extension_type (module, \
PEAS_TYPE_ACTIVATABLE, \
TYPE_NAME); \
+ REGISTER_CODE \
}
/**
+ * TOTEM_PLUGIN_REGISTER:
+ * @TYPE_NAME: the name of the plugin type, in UPPER_CASE
+ * @TypeName: the name of the plugin type, in CamelCase
+ * @type_name: the name of the plugin type, in lower_case
+ *
+ * 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) \
+ _TOTEM_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name,,)
+
+/**
* TOTEM_PLUGIN_REGISTER_CONFIGURABLE:
* @TYPE_NAME: the name of the plugin type, in UPPER_CASE
* @TypeName: the name of the plugin type, in CamelCase
@@ -122,81 +138,15 @@ G_BEGIN_DECLS
* and deactivate and widget creation functions.
**/
#define TOTEM_PLUGIN_REGISTER_CONFIGURABLE(TYPE_NAME, TypeName, type_name) \
- static void impl_activate (PeasActivatable *plugin); \
- static void impl_deactivate (PeasActivatable *plugin); \
static GtkWidget *impl_create_configure_widget (PeasGtkConfigurable *configurable); \
- G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); \
- static void peas_activatable_iface_init (PeasActivatableInterface *iface); \
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface); \
- enum { \
- PROP_0, \
- PROP_OBJECT \
- }; \
- 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_GTK_TYPE_CONFIGURABLE, \
- peas_gtk_configurable_iface_init)) \
- static void \
- peas_activatable_iface_init (PeasActivatableInterface *iface) \
- { \
- iface->activate = impl_activate; \
- iface->deactivate = impl_deactivate; \
- } \
+ _TOTEM_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name, \
+ (G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE, peas_gtk_configurable_iface_init)), \
+ peas_object_module_register_extension_type (module, PEAS_GTK_TYPE_CONFIGURABLE, TYPE_NAME);) \
static void \
peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface) \
{ \
iface->create_configure_widget = impl_create_configure_widget; \
- } \
- static void \
- set_property (GObject *object, \
- guint prop_id, \
- const GValue *value, \
- GParamSpec *pspec) \
- { \
- switch (prop_id) { \
- case PROP_OBJECT: \
- g_object_set_data_full (object, "object", \
- g_value_dup_object (value), \
- g_object_unref); \
- break; \
- default: \
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
- break; \
- } \
- } \
- static void \
- get_property (GObject *object, \
- guint prop_id, \
- GValue *value, \
- GParamSpec *pspec) \
- { \
- switch (prop_id) { \
- case PROP_OBJECT: \
- g_value_set_object (value, g_object_get_data (object, "object")); \
- break; \
- default: \
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
- break; \
- } \
- } \
- 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_GTK_TYPE_CONFIGURABLE, \
- TYPE_NAME); \
}
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]