[totem] Port ontop to libpeas



commit df9ac486d233ff586d8744eac1a3d189f3c78ec2
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 16 18:15:35 2010 +0100

    Port ontop to libpeas

 src/plugins/ontop/Makefile.am   |    1 +
 src/plugins/ontop/totem-ontop.c |   63 ++++++++++++++++++++++++++------------
 2 files changed, 44 insertions(+), 20 deletions(-)
---
diff --git a/src/plugins/ontop/Makefile.am b/src/plugins/ontop/Makefile.am
index bf52c09..22b5507 100644
--- a/src/plugins/ontop/Makefile.am
+++ b/src/plugins/ontop/Makefile.am
@@ -28,6 +28,7 @@ libontop_la_CPPFLAGS = $(common_defines)
 
 libontop_la_CFLAGS = \
 	$(DEPENDENCY_CFLAGS)	\
+	$(PEAS_CFLAGS)		\
 	$(WARN_CFLAGS)		\
 	$(DBUS_CFLAGS)		\
 	$(AM_CFLAGS)		\
diff --git a/src/plugins/ontop/totem-ontop.c b/src/plugins/ontop/totem-ontop.c
index a380e90..eb7a79d 100644
--- a/src/plugins/ontop/totem-ontop.c
+++ b/src/plugins/ontop/totem-ontop.c
@@ -30,9 +30,10 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
-#include <gmodule.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+#include <libpeas/peas-activatable.h>
 
-#include "totem-plugin.h"
 #include "totem.h"
 #include "backend/bacon-video-widget.h"
 
@@ -54,32 +55,45 @@ typedef struct
 
 typedef struct
 {
-	TotemPlugin parent;
+	PeasExtensionBase parent;
 	TotemOntopPluginPrivate *priv;
 } TotemOntopPlugin;
 
 typedef struct
 {
-	TotemPluginClass parent_class;
+	PeasExtensionBaseClass parent_class;
 } TotemOntopPluginClass;
 
-G_MODULE_EXPORT GType register_totem_plugin	(GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types	(PeasObjectModule *module);
 GType totem_ontop_plugin_get_type		(void) G_GNUC_CONST;
+static void peas_activatable_iface_init		(PeasActivatableInterface *iface);
 
-static gboolean impl_activate			(TotemPlugin *plugin, TotemObject *totem, GError **error);
-static void impl_deactivate			(TotemPlugin *plugin, TotemObject *totem);
+static void impl_activate			(PeasActivatable *plugin, GObject *object);
+static void impl_deactivate			(PeasActivatable *plugin, GObject *object);
 
-TOTEM_PLUGIN_REGISTER (TotemOntopPlugin, totem_ontop_plugin)
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (TotemOntopPlugin,
+				totem_ontop_plugin,
+				PEAS_TYPE_EXTENSION_BASE,
+				0,
+				G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
+							       peas_activatable_iface_init))
 
 static void
-totem_ontop_plugin_class_init (TotemOntopPluginClass *klass)
+peas_activatable_iface_init (PeasActivatableInterface *iface)
 {
-	TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
+	iface->activate = impl_activate;
+	iface->deactivate = impl_deactivate;
+}
 
+static void
+totem_ontop_plugin_class_init (TotemOntopPluginClass *klass)
+{
 	g_type_class_add_private (klass, sizeof (TotemOntopPluginPrivate));
+}
 
-	plugin_class->activate = impl_activate;
-	plugin_class->deactivate = impl_deactivate;
+static void
+totem_ontop_plugin_class_finalize (TotemOntopPluginClass *klass)
+{
 }
 
 static void
@@ -115,12 +129,12 @@ property_notify_cb (TotemObject *totem,
 	update_from_state (pi->priv);
 }
 
-static gboolean
-impl_activate (TotemPlugin *plugin,
-	       TotemObject *totem,
-	       GError **error)
+static void
+impl_activate (PeasActivatable *plugin,
+	       GObject *object)
 {
 	TotemOntopPlugin *pi = TOTEM_ONTOP_PLUGIN (plugin);
+	TotemObject *totem = TOTEM_OBJECT (object);
 
 	pi->priv->window = totem_get_main_window (totem);
 	pi->priv->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (totem));
@@ -136,15 +150,14 @@ impl_activate (TotemPlugin *plugin,
 						    pi);
 
 	update_from_state (pi->priv);
-
-	return TRUE;
 }
 
 static void
-impl_deactivate	(TotemPlugin *plugin,
-		 TotemObject *totem)
+impl_deactivate (PeasActivatable *plugin,
+		 GObject *object)
 {
 	TotemOntopPlugin *pi = TOTEM_ONTOP_PLUGIN (plugin);
+	TotemObject *totem = TOTEM_OBJECT (object);
 
 	g_signal_handler_disconnect (G_OBJECT (totem), pi->priv->handler_id);
 	g_signal_handler_disconnect (G_OBJECT (pi->priv->bvw), pi->priv->handler_id_metadata);
@@ -157,3 +170,13 @@ impl_deactivate	(TotemPlugin *plugin,
 	g_object_unref (pi->priv->window);
 }
 
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+	totem_ontop_plugin_register_type (G_TYPE_MODULE (module));
+
+	peas_object_module_register_extension_type (module,
+						    PEAS_TYPE_ACTIVATABLE,
+						    TOTEM_TYPE_ONTOP_PLUGIN);
+}
+



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