[totem/peas-0.5.4: 2/4] Port to libpeas 0.5.4



commit 9060949508effd5e6af7863ff8b9f796d0394776
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Aug 5 10:04:58 2010 +0100

    Port to libpeas 0.5.4
    
    The object parameter has been moved from the activate/deactivate functions
    to a property on the activatable object, which must be installed for each
    plugin. This requires moving quite a lot of code into the
    TOTEM_PLUGIN_REGISTER macros.

 configure.in                       |    2 +-
 src/plugins/totem-plugin.h         |   64 ++++++++++++++++++++++++++++++++++-
 src/plugins/totem-plugins-engine.c |   14 ++++----
 3 files changed, 70 insertions(+), 10 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9034177..ee391b1 100644
--- a/configure.in
+++ b/configure.in
@@ -48,7 +48,7 @@ TOTEM_PLPARSER_REQS=2.29.1
 GNOMEICON_REQS=2.15.90
 DBUS_REQS=0.61
 VALA_REQS=0.7.5
-PEAS_REQS=0.5.3
+PEAS_REQS=0.5.4
 
 AC_SUBST(GLIB_REQS)
 AC_SUBST(GTK_REQS)
diff --git a/src/plugins/totem-plugin.h b/src/plugins/totem-plugin.h
index a3598de..7392304 100644
--- a/src/plugins/totem-plugin.h
+++ b/src/plugins/totem-plugin.h
@@ -37,8 +37,8 @@
 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);							\
+	static void impl_activate (PeasActivatable *plugin);									\
+	static void impl_deactivate (PeasActivatable *plugin);									\
 	G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);							\
 	static void peas_activatable_iface_init (PeasActivatableInterface *iface);						\
 																\
@@ -49,6 +49,10 @@ G_BEGIN_DECLS
 	                                G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, peas_activatable_iface_init)	\
 	                                { TYPE_CODE; })										\
 																\
+	enum {															\
+		PROP_OBJECT = 1													\
+	};															\
+																\
 	G_MODULE_EXPORT void													\
 	peas_register_types (PeasObjectModule *module)										\
 	{															\
@@ -58,6 +62,62 @@ G_BEGIN_DECLS
 	}															\
 																\
 	static void														\
+	type_name##_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)				\
+	{															\
+		TypeName##Private *priv = G_TYPE_INSTANCE_GET_PRIVATE (object, TYPE_NAME, TypeName##Private);			\
+																\
+		switch (prop_id) {												\
+			case PROP_OBJECT:											\
+				g_value_set_object (value, priv->totem);							\
+				break;												\
+			default:												\
+				G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);					\
+				break;												\
+		}														\
+	}															\
+																\
+	static void														\
+	type_name##_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)			\
+	{															\
+		TypeName##Private *priv = G_TYPE_INSTANCE_GET_PRIVATE (object, TYPE_NAME, TypeName##Private);			\
+																\
+		switch (prop_id) {												\
+			case PROP_OBJECT:											\
+				priv->totem = g_value_dup_object (value);							\
+				break;												\
+			default:												\
+				G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);					\
+				break;												\
+		}														\
+	}															\
+																\
+	static void														\
+	type_name##_dispose (GObject *object)											\
+	{															\
+		TypeName##Private *priv = G_TYPE_INSTANCE_GET_PRIVATE (object, TYPE_NAME, TypeName##Private);			\
+																\
+		if (priv->totem != NULL)											\
+			g_object_unref (priv->totem);										\
+		priv->totem = NULL;												\
+																\
+		G_OBJECT_CLASS (type_name##_parent_class)->dispose (object);							\
+	}															\
+																\
+	static void														\
+	type_name##_class_init (TypeName##Class *klass)										\
+	{															\
+		GObjectClass *object_class = G_OBJECT_CLASS (klass);								\
+																\
+		object_class->get_property = type_name##_get_property;								\
+		object_class->set_property = type_name##_set_property;								\
+		object_class->dispose = type_name##_dispose;									\
+																\
+		g_object_class_override_property (object_class, PROP_OBJECT, "object");						\
+																\
+		g_type_class_add_private (klass, sizeof (TypeName##Private));							\
+	}															\
+																\
+	static void														\
 	type_name##_class_finalize (TypeName##Class *klass)									\
 	{															\
 	}															\
diff --git a/src/plugins/totem-plugins-engine.c b/src/plugins/totem-plugins-engine.c
index 4cd9f47..4a46a05 100644
--- a/src/plugins/totem-plugins-engine.c
+++ b/src/plugins/totem-plugins-engine.c
@@ -138,7 +138,7 @@ on_activatable_extension_added (PeasExtensionSet *set,
 				TotemPluginsEngine *engine)
 {
 	g_message ("on_activatable_extension_added");
-	if (peas_extension_call (exten, "activate", engine->priv->totem)) {
+	if (peas_extension_call (exten, "activate")) {
 		if (peas_plugin_info_is_builtin (info) == FALSE) {
 			char *key_name;
 
@@ -156,7 +156,7 @@ on_activatable_extension_removed (PeasExtensionSet *set,
 				  TotemPluginsEngine *engine)
 {
 	g_message ("on_activatable_extension_removed");
-	peas_extension_call (exten, "deactivate", engine->priv->totem);
+	peas_extension_call (exten, "deactivate");
 
 	if (peas_plugin_info_is_builtin (info) == FALSE) {
 		char *key_name;
@@ -207,12 +207,13 @@ totem_plugins_engine_get_default (TotemObject *totem)
 
 	engine->priv->totem = g_object_ref (totem);
 
-	engine->priv->activatable_extensions = peas_extension_set_new (PEAS_ENGINE (engine),
-								       PEAS_TYPE_ACTIVATABLE);
+	engine->priv->activatable_extensions = peas_extension_set_new (PEAS_ENGINE (engine), PEAS_TYPE_ACTIVATABLE,
+	                                                               "object", totem,
+	                                                               NULL);
 	totem_plugins_engine_load_all (engine);
 	totem_plugins_engine_monitor (engine);
 
-	peas_extension_set_call (engine->priv->activatable_extensions, "activate", engine->priv->totem);
+	peas_extension_set_call (engine->priv->activatable_extensions, "activate");
 
 	g_signal_connect (engine->priv->activatable_extensions, "extension-added",
 			  G_CALLBACK (on_activatable_extension_added), engine);
@@ -247,8 +248,7 @@ totem_plugins_engine_finalize (GObject *object)
 					      G_CALLBACK (on_activatable_extension_removed), engine);
 
 	if (engine->priv->totem) {
-		peas_extension_set_call (engine->priv->activatable_extensions,
-					 "deactivate", engine->priv->totem);
+		peas_extension_set_call (engine->priv->activatable_extensions, "deactivate");
 
 		g_object_unref (engine->priv->totem);
 		engine->priv->totem = NULL;



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