[totem] Port skipto plugin to libpeas



commit f5364cf6faeb2d474f6bf3d3caa3e2bd0da5c3a1
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 16 16:27:03 2010 +0100

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

 src/plugins/skipto/Makefile.am           |    1 +
 src/plugins/skipto/totem-skipto-plugin.c |   69 ++++++++++++++++++-----------
 src/plugins/skipto/totem-skipto-plugin.h |    7 ++-
 src/plugins/skipto/totem-skipto.c        |    5 +-
 4 files changed, 52 insertions(+), 30 deletions(-)
---
diff --git a/src/plugins/skipto/Makefile.am b/src/plugins/skipto/Makefile.am
index 40a20f1..54c2ae0 100644
--- a/src/plugins/skipto/Makefile.am
+++ b/src/plugins/skipto/Makefile.am
@@ -37,6 +37,7 @@ libskipto_la_CPPFLAGS = \
 
 libskipto_la_CFLAGS = 			\
 	$(DEPENDENCY_CFLAGS)		\
+	$(PEAS_CFLAGS)			\
 	$(WARN_CFLAGS)			\
 	$(DBUS_CFLAGS)			\
 	$(AM_CFLAGS)			\
diff --git a/src/plugins/skipto/totem-skipto-plugin.c b/src/plugins/skipto/totem-skipto-plugin.c
index 175da86..f9df72c 100644
--- a/src/plugins/skipto/totem-skipto-plugin.c
+++ b/src/plugins/skipto/totem-skipto-plugin.c
@@ -33,6 +33,8 @@
 #include <gmodule.h>
 #include <string.h>
 #include <gdk/gdkkeysyms.h>
+#include <libpeas/peas-activatable.h>
+
 
 #include "totem-skipto-plugin.h"
 #include "totem-skipto.h"
@@ -47,26 +49,35 @@ struct TotemSkiptoPluginPrivate
 	GtkActionGroup	*action_group;
 };
 
-G_MODULE_EXPORT GType register_totem_plugin		(GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types		(PeasObjectModule *module);
+static void peas_activatable_iface_init			(PeasActivatableInterface *iface);
 
 static void totem_skipto_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 (TotemSkiptoPlugin,
+				totem_skipto_plugin,
+				PEAS_TYPE_EXTENSION_BASE,
+				0,
+				G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
+							       peas_activatable_iface_init))
 
-TOTEM_PLUGIN_REGISTER_EXTENDED(TotemSkiptoPlugin, totem_skipto_plugin, TOTEM_PLUGIN_REGISTER_TYPE(totem_skipto))
 
 static void
 totem_skipto_plugin_class_init (TotemSkiptoPluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
 
 	g_type_class_add_private (klass, sizeof (TotemSkiptoPluginPrivate));
 
 	object_class->finalize = totem_skipto_plugin_finalize;
-
-	plugin_class->activate = impl_activate;
-	plugin_class->deactivate = impl_deactivate;
+}
+static void
+peas_activatable_iface_init (PeasActivatableInterface *iface)
+{
+	iface->activate = impl_activate;
+	iface->deactivate = impl_deactivate;
 }
 
 static void
@@ -79,6 +90,11 @@ totem_skipto_plugin_init (TotemSkiptoPlugin *plugin)
 }
 
 static void
+totem_skipto_plugin_class_finalize (TotemSkiptoPluginClass *klass)
+{
+}
+
+static void
 destroy_dialog (TotemSkiptoPlugin *plugin)
 {
 	TotemSkiptoPluginPrivate *priv = plugin->priv;
@@ -201,29 +217,20 @@ on_window_key_press_event (GtkWidget *window, GdkEventKey *event, TotemSkiptoPlu
 	return TRUE;
 }
 
-static gboolean
-impl_activate (TotemPlugin *plugin,
-	       TotemObject *totem,
-	       GError **error)
+static void
+impl_activate (PeasActivatable *plugin,
+	       GObject *object)
 {
 	GtkWindow *window;
 	GtkUIManager *manager;
 	TotemSkiptoPlugin *pi = TOTEM_SKIPTO_PLUGIN (plugin);
 	TotemSkiptoPluginPrivate *priv = pi->priv;
+	TotemObject *totem = TOTEM_OBJECT (object);
 
-	char *builder_path;
 	const GtkActionEntry menu_entries[] = {
 		{ "skip-to", GTK_STOCK_JUMP_TO, N_("_Skip to..."), "<Control>K", N_("Skip to a specific time"), G_CALLBACK (skip_to_action_callback) }
 	};
 
-	builder_path = totem_plugin_find_file (TOTEM_PLUGIN (plugin), "skipto.ui");
-	if (builder_path == NULL) {
-		g_set_error_literal (error, TOTEM_PLUGIN_ERROR, TOTEM_PLUGIN_ERROR_ACTIVATION,
-                                     _("Could not load the \"Skip to\" dialog interface."));
-		return FALSE;
-	}
-	g_free (builder_path);
-
 	pi->totem = totem;
 	priv->handler_id_stream_length = g_signal_connect (G_OBJECT (totem),
 				"notify::stream-length",
@@ -237,7 +244,7 @@ impl_activate (TotemPlugin *plugin,
 	/* Key press handler */
 	window = totem_get_main_window (totem);
 	priv->handler_id_key_press = g_signal_connect (G_OBJECT(window),
-				"key-press-event", 
+				"key-press-event",
 				G_CALLBACK (on_window_key_press_event),
 				pi);
 	g_object_unref (window);
@@ -259,16 +266,15 @@ impl_activate (TotemPlugin *plugin,
 			       "skip-to", GTK_UI_MANAGER_AUTO, TRUE);
 
 	totem_skipto_update_from_state (totem, pi);
-
-	return TRUE;
 }
 
 static void
-impl_deactivate	(TotemPlugin *plugin,
-		 TotemObject *totem)
+impl_deactivate	(PeasActivatable *plugin,
+		 GObject *object)
 {
 	GtkWindow *window;
 	GtkUIManager *manager;
+	TotemObject *totem = TOTEM_OBJECT (object);
 	TotemSkiptoPluginPrivate *priv = TOTEM_SKIPTO_PLUGIN (plugin)->priv;
 
 	g_signal_handler_disconnect (G_OBJECT (totem),
@@ -289,3 +295,14 @@ impl_deactivate	(TotemPlugin *plugin,
 	gtk_ui_manager_remove_ui (manager, priv->ui_merge_id);
 	gtk_ui_manager_remove_action_group (manager, priv->action_group);
 }
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+	totem_skipto_plugin_register_type (G_TYPE_MODULE (module));
+
+	peas_object_module_register_extension_type (module,
+						    PEAS_TYPE_ACTIVATABLE,
+						    TOTEM_TYPE_SKIPTO_PLUGIN);
+}
+
diff --git a/src/plugins/skipto/totem-skipto-plugin.h b/src/plugins/skipto/totem-skipto-plugin.h
index 02ddbf0..f29d788 100644
--- a/src/plugins/skipto/totem-skipto-plugin.h
+++ b/src/plugins/skipto/totem-skipto-plugin.h
@@ -31,6 +31,8 @@
 #define TOTEM_SKIPTO_PLUGIN_H
 
 #include <glib.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
 
 #include "totem.h"
 #include "totem-plugin.h"
@@ -48,7 +50,7 @@ typedef struct TotemSkiptoPluginPrivate         TotemSkiptoPluginPrivate;
 
 typedef struct
 {
-	TotemPlugin	          parent;
+	PeasExtensionBase         parent;
 
 	TotemObject              *totem;
 	TotemSkiptoPluginPrivate *priv;
@@ -56,10 +58,11 @@ typedef struct
 
 typedef struct
 {
-	TotemPluginClass parent_class;
+	PeasExtensionBaseClass parent_class;
 } TotemSkiptoPluginClass;
 
 GType totem_skipto_plugin_get_type			(void) G_GNUC_CONST;
+G_MODULE_EXPORT void peas_register_types		(PeasObjectModule *module);
 
 G_END_DECLS
 
diff --git a/src/plugins/skipto/totem-skipto.c b/src/plugins/skipto/totem-skipto.c
index 93e2f43..0758b84 100644
--- a/src/plugins/skipto/totem-skipto.c
+++ b/src/plugins/skipto/totem-skipto.c
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
+#include "totem-dirs.h"
 #include "totem-skipto.h"
 #include "totem-skipto-plugin.h"
 #include "totem-uri.h"
@@ -54,7 +55,7 @@ struct TotemSkiptoPrivate {
 	Totem *totem;
 };
 
-TOTEM_PLUGIN_DEFINE_TYPE (TotemSkipto, totem_skipto, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (TotemSkipto, totem_skipto, GTK_TYPE_DIALOG)
 #define TOTEM_SKIPTO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOTEM_TYPE_SKIPTO, TotemSkiptoPrivate))
 
 static void
@@ -157,7 +158,7 @@ totem_skipto_new (TotemSkiptoPlugin *plugin)
 	skipto = TOTEM_SKIPTO (g_object_new (TOTEM_TYPE_SKIPTO, NULL));
 
 	skipto->priv->totem = plugin->totem;
-	skipto->priv->xml = totem_plugin_load_interface (TOTEM_PLUGIN (plugin),
+	skipto->priv->xml = totem_plugin_load_interface ("skipto",
 							 "skipto.ui", TRUE,
 							 NULL, skipto);
 



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