[totem] Port screensaver plugin to libpeas



commit 9b7c8d03af6188e9b318ad735b910b676723486f
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 16 16:36:03 2010 +0100

    Port screensaver plugin to libpeas
    
    https://bugzilla.gnome.org/show_bug.cgi?id=604830

 src/plugins/screensaver/Makefile.am         |    1 +
 src/plugins/screensaver/totem-screensaver.c |   64 +++++++++++++++++++--------
 2 files changed, 46 insertions(+), 19 deletions(-)
---
diff --git a/src/plugins/screensaver/Makefile.am b/src/plugins/screensaver/Makefile.am
index 5f2c9ce..a3a7f2c 100644
--- a/src/plugins/screensaver/Makefile.am
+++ b/src/plugins/screensaver/Makefile.am
@@ -28,6 +28,7 @@ libscreensaver_la_CPPFLAGS = $(common_defines)
 
 libscreensaver_la_CFLAGS = \
 	$(DEPENDENCY_CFLAGS)	\
+	$(PEAS_CFLAGS)		\
 	$(WARN_CFLAGS)		\
 	$(DBUS_CFLAGS)		\
 	$(AM_CFLAGS)		\
diff --git a/src/plugins/screensaver/totem-screensaver.c b/src/plugins/screensaver/totem-screensaver.c
index 5b4e167..dedd7b3 100644
--- a/src/plugins/screensaver/totem-screensaver.c
+++ b/src/plugins/screensaver/totem-screensaver.c
@@ -31,11 +31,13 @@
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
 #include <gconf/gconf-client.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+#include <libpeas/peas-activatable.h>
 
 #include <gmodule.h>
 #include <string.h>
 
-#include "totem-plugin.h"
 #include "totem.h"
 #include "totem-scrsaver.h"
 #include "backend/bacon-video-widget.h"
@@ -49,8 +51,8 @@
 
 typedef struct
 {
-	TotemPlugin   parent;
-	TotemObject  *totem;
+	PeasExtensionBase parent;
+	TotemObject *totem;
 	BaconVideoWidget *bvw;
 
 	TotemScrsaver *scr;
@@ -61,29 +63,44 @@ typedef struct
 
 typedef struct
 {
-	TotemPluginClass parent_class;
+	PeasExtensionBaseClass parent_class;
 } TotemScreensaverPluginClass;
 
 
-G_MODULE_EXPORT GType register_totem_plugin		(GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types		(PeasObjectModule *module);
 GType	totem_screensaver_plugin_get_type		(void) G_GNUC_CONST;
+static void peas_activatable_iface_init			(PeasActivatableInterface *iface);
 
 static void totem_screensaver_plugin_finalize		(GObject *object);
-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);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (TotemScreensaverPlugin,
+				totem_screensaver_plugin,
+				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;
+}
 
-TOTEM_PLUGIN_REGISTER(TotemScreensaverPlugin, totem_screensaver_plugin)
 
 static void
 totem_screensaver_plugin_class_init (TotemScreensaverPluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
 
 	object_class->finalize = totem_screensaver_plugin_finalize;
+}
 
-	plugin_class->activate = impl_activate;
-	plugin_class->deactivate = impl_deactivate;
+static void
+totem_screensaver_plugin_class_finalize (TotemScreensaverPluginClass *klass)
+{
 }
 
 static void
@@ -152,12 +169,12 @@ lock_screensaver_on_audio_changed_cb (GConfClient *client, guint cnxn_id,
 	totem_screensaver_update_from_state (pi->totem, pi);
 }
 
-static gboolean
-impl_activate (TotemPlugin *plugin,
-	       TotemObject *totem,
-	       GError **error)
+static void
+impl_activate (PeasActivatable *plugin,
+	       GObject *object)
 {
 	TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
+	TotemObject *totem = TOTEM_OBJECT (object);
 	GConfClient *gc;
 
 	pi->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (totem));
@@ -183,15 +200,14 @@ impl_activate (TotemPlugin *plugin,
 
 	/* Force setting the current status */
 	totem_screensaver_update_from_state (totem, pi);
-
-	return TRUE;
 }
 
 static void
-impl_deactivate	(TotemPlugin *plugin,
-		 TotemObject *totem)
+impl_deactivate	(PeasActivatable *plugin,
+		 GObject *object)
 {
 	TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
+	TotemObject *totem = TOTEM_OBJECT (object);
 	GConfClient *gc;
 
 	gc = gconf_client_get_default ();
@@ -213,3 +229,13 @@ impl_deactivate	(TotemPlugin *plugin,
 	totem_scrsaver_enable (pi->scr);
 }
 
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+	totem_screensaver_plugin_register_type (G_TYPE_MODULE (module));
+
+	peas_object_module_register_extension_type (module,
+						    PEAS_TYPE_ACTIVATABLE,
+						    TOTEM_TYPE_SCREENSAVER_PLUGIN);
+}
+



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