[rhythmbox] remove old plugin system, switch to libpeas



commit ea851118fa076e7b30c5530678f3cdc3235a6d8c
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Apr 23 22:49:25 2011 +1000

    remove old plugin system, switch to libpeas

 .gitignore                           |   10 +-
 Makefile.am                          |    2 +-
 bindings/gi/Makefile.am              |   32 +-
 configure.ac                         |  100 +----
 data/org.gnome.rhythmbox.gschema.xml |   12 +-
 doc/reference/Makefile.am            |    1 -
 doc/reference/rhythmbox-sections.txt |   28 --
 doc/reference/rhythmbox.types        |    2 -
 lib/rb-file-helpers.c                |   55 +++
 lib/rb-file-helpers.h                |    2 +
 rhythmbox.h                          |    1 -
 shell/Makefile.am                    |   28 +--
 shell/rb-module.c                    |  185 ---------
 shell/rb-module.h                    |   59 ---
 shell/rb-plugin-manager.c            |  562 --------------------------
 shell/rb-plugin-manager.h            |   79 ----
 shell/rb-plugin.c                    |  393 ------------------
 shell/rb-plugin.h                    |  214 ----------
 shell/rb-plugins-engine.c            |  724 ----------------------------------
 shell/rb-plugins-engine.h            |   64 ---
 shell/rb-python-module.c             |  483 -----------------------
 shell/rb-python-module.h             |   71 ----
 shell/rb-python-plugin.c             |  283 -------------
 shell/rb-python-plugin.h             |   52 ---
 shell/rb-shell.c                     |  152 +++++++-
 sources/rb-display-page.c            |   10 +-
 sources/rb-source.c                  |    3 +-
 27 files changed, 255 insertions(+), 3352 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 40be3ba..959f343 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,7 @@
 .deps
 .libs
 *.pyc
-*.rb-plugin
+*.plugin
 
 autom4te*.cache
 stamp-h
@@ -30,10 +30,10 @@ gnome-doc-utils.make
 rhythmbox.pc
 
 #
-bindings/gi/MPID-0.13.gir
-bindings/gi/MPID-0.13.typelib
-bindings/gi/RB-0.13.gir
-bindings/gi/RB-0.13.typelib
+bindings/gi/MPID-3.0.gir
+bindings/gi/MPID-3.0.typelib
+bindings/gi/RB-3.0.gir
+bindings/gi/RB-3.0.typelib
 
 #
 org.gnome.Rhythmbox.service
diff --git a/Makefile.am b/Makefile.am
index fb6eeac..38967c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@ DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install --enable-gtk-doc --disable
 distuninstallcheck_listfiles = find . -type f -print | grep -v '^\./var/scrollkeeper'
 
 SUBDIRS = macros lib metadata rhythmdb widgets sources podcast \
-	backends shell bindings plugins remote data po help tests doc
+	backends shell bindings remote data po help tests doc
 
 INCLUDES = rhythmbox.h
 
diff --git a/bindings/gi/Makefile.am b/bindings/gi/Makefile.am
index 1a81437..7376b6a 100644
--- a/bindings/gi/Makefile.am
+++ b/bindings/gi/Makefile.am
@@ -66,8 +66,6 @@ rb_introspection_sources = \
 		shell/rb-history.c \
 		shell/rb-play-order.h \
 		shell/rb-play-order.c \
-		shell/rb-plugin.h \
-		shell/rb-plugin.c \
 		shell/rb-track-transfer-batch.c \
 		shell/rb-track-transfer-batch.h \
 		shell/rb-track-transfer-queue.c \
@@ -122,23 +120,23 @@ rb_introspection_sources = \
 		widgets/rb-uri-dialog.h \
 		widgets/rb-uri-dialog.c
 
-MPID-0.13.gir: $(top_builddir)/shell/librhythmbox-core.la
-MPID_0_13_gir_INCLUDES = GObject-2.0
-MPID_0_13_gir_CFLAGS = $(RHYTHMBOX_CFLAGS_NOWARN) $(GUDEV_CFLAGS) -I../..
-MPID_0_13_gir_LIBS = $(top_builddir)/shell/librhythmbox-core.la
-MPID_0_13_gir_FILES = $(addprefix $(top_srcdir)/,$(mpid_introspection_sources))
-MPID_0_13_gir_PACKAGES = gobject-2.0
-MPID_0_13_gir_SCANNERFLAGS = --symbol-prefix mpid_
+MPID-3.0.gir: $(top_builddir)/shell/librhythmbox-core.la
+MPID_3_0_gir_INCLUDES = GObject-2.0
+MPID_3_0_gir_CFLAGS = $(RHYTHMBOX_CFLAGS_NOWARN) $(GUDEV_CFLAGS) -I../..
+MPID_3_0_gir_LIBS = $(top_builddir)/shell/librhythmbox-core.la
+MPID_3_0_gir_FILES = $(addprefix $(top_srcdir)/,$(mpid_introspection_sources))
+MPID_3_0_gir_PACKAGES = gobject-2.0
+MPID_3_0_gir_SCANNERFLAGS = --symbol-prefix mpid_
 
-RB-0.13.gir: $(top_builddir)/shell/librhythmbox-core.la MPID-0.13.gir
-RB_0_13_gir_INCLUDES = GObject-2.0 Gio-2.0 Gtk-3.0 Gst-0.10 libxml2-2.0
-RB_0_13_gir_CFLAGS = $(RHYTHMBOX_CFLAGS_NOWARN) $(TOTEM_PLPARSER_CFLAGS) $(DBUS_CFLAGS) $(GUDEV_CFLAGS) -I../..
-RB_0_13_gir_LIBS = $(top_builddir)/shell/librhythmbox-core.la
-RB_0_13_gir_FILES = $(addprefix $(top_srcdir)/,$(rb_introspection_sources))
-RB_0_13_gir_PACKAGES = gobject-2.0 gio-2.0 gtk+-3.0 gstreamer-0.10 libxml-2.0
-RB_0_13_gir_SCANNERFLAGS = --symbol-prefix rb_ --identifier-prefix RB --accept-unprefixed --include-uninstalled=$(builddir)/MPID-0.13.gir
+RB-3.0.gir: $(top_builddir)/shell/librhythmbox-core.la MPID-3.0.gir
+RB_3_0_gir_INCLUDES = GObject-2.0 Gio-2.0 Gtk-3.0 Gst-0.10 libxml2-2.0
+RB_3_0_gir_CFLAGS = $(RHYTHMBOX_CFLAGS_NOWARN) $(TOTEM_PLPARSER_CFLAGS) $(DBUS_CFLAGS) $(GUDEV_CFLAGS) -I../..
+RB_3_0_gir_LIBS = $(top_builddir)/shell/librhythmbox-core.la
+RB_3_0_gir_FILES = $(addprefix $(top_srcdir)/,$(rb_introspection_sources))
+RB_3_0_gir_PACKAGES = gobject-2.0 gio-2.0 gtk+-3.0 gstreamer-0.10 libxml-2.0
+RB_3_0_gir_SCANNERFLAGS = --symbol-prefix rb_ --identifier-prefix RB --accept-unprefixed --include-uninstalled=$(builddir)/MPID-3.0.gir
 
-INTROSPECTION_GIRS += MPID-0.13.gir RB-0.13.gir
+INTROSPECTION_GIRS += MPID-3.0.gir RB-3.0.gir
 
 girdir = $(datadir)/gir-1.0
 dist_gir_DATA = $(INTROSPECTION_GIRS)
diff --git a/configure.ac b/configure.ac
index 75f2e0b..bfead77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,12 +58,13 @@ AVAHI_REQS=0.6
 LIBSOUP_REQS=2.26.0
 GUDEV_REQS=143
 LIBMTP_REQS=0.3.0
-PYGOBJECT_REQUIRED=2.15.4
+LIBPEAS_REQS=0.7.3
 
 GNOME_MEDIA_PROFILES_REQS=2.91.0
 LIBNOTIFY_REQS=0.7.0
 BRASERO_MIN_REQS=2.31.5
 WEBKIT_MIN_REQS=1.3.9
+PYGOBJECT_REQUIRED=2.28
 
 GLIB_GSETTINGS
 
@@ -103,7 +104,9 @@ PKG_CHECK_MODULES(RHYTHMBOX,				\
 		  gio-unix-2.0 >= $GLIB_REQS		\
 		  libgnome-media-profiles-3.0 >= $GNOME_MEDIA_PROFILES_REQS \
 		  libsoup-2.4 >= $LIBSOUP_REQS		\
-		  libsoup-gnome-2.4 >= $LIBSOUP_REQS)
+		  libsoup-gnome-2.4 >= $LIBSOUP_REQS	\
+		  libpeas-1.0 >= $LIBPEAS_REQS
+		  libpeas-gtk-1.0 >= $LIBPEAS_REQS)
 
 PKG_CHECK_MODULES(TOTEM_PLPARSER, totem-plparser >= $TOTEM_PLPARSER_REQS, have_totem_plparser=yes, have_totem_plparser=no)
 if test x$have_totem_plparser != xyes; then
@@ -636,94 +639,27 @@ AC_SUBST(PLUGINDIR)
 dnl ================================================================
 dnl Python plugins
 dnl ================================================================
+AM_PATH_PYTHON
 
-AC_MSG_CHECKING([whether Python plugin support is requested])
-AC_ARG_ENABLE([python],
-	AS_HELP_STRING([--enable-python],[Enable python support]),
-	[enable_python=$enableval have_python=$enableval],
-	[enable_python=autodetect have_python=yes])
-AC_MSG_RESULT([$have_python])
-
-if test "x$have_python" != "xyes"; then
-	if test "x$enable_python" = "xyes"; then
-		AC_MSG_ERROR([Python not found])
-	elif test "x$enable_python" = "xautodetect"; then
-		enable_python=no
-		AC_MSG_WARN([Python not found, disabling python support])
-	fi
-fi
 
-if test "x$have_python" != "xno"; then
-	AM_PATH_PYTHON([2.3],[],[have_python=no])
-	if test "x$PYTHON" = "x:"; then
-		have_python=no
-	fi
-fi
-
-if test "x$have_python" != "xno"; then
-	PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
-	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
-	PYTHON_LIBS="-lpython$PYTHON_VERSION"
-	if test -d $PY_EXEC_PREFIX/lib64/python$PYTHON_VERSION ; then
-		PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib64/python$PYTHON_VERSION/config"
-		PYTHON_MAKEFILE="$PY_EXEC_PREFIX/lib64/python$PYTHON_VERSION/config/Makefile"
-	else
-		PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config"
-		PYTHON_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config/Makefile"
-	fi
-	PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
-	PYTHON_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
-	PYTHON_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
-	PYTHON_EXTRA_LIBS="$PYTHON_BASEMODLIBS $PYTHON_OTHER_LIBS"
-	AC_SUBST([PYTHON_LIBS])
-	AC_SUBST([PYTHON_LIB_LOC])
-	AC_SUBST([PYTHON_CFLAGS])
-	AC_SUBST([PYTHON_EXTRA_LIBS])
-
-	GST_PYTHON_REQUIRED=0.10.1
-	PKG_CHECK_MODULES([PYGOBJECT], [
-		gst-python-0.10 >= $GST_PYTHON_REQUIRED
-		pygobject-2.0 >= $PYGOBJECT_REQUIRED],
-		[],
-		[
-		have_python=no
-		if test "x$enable_python" = "xyes"; then
-			AC_MSG_ERROR([$PYGOBJECT_PKG_ERRORS])
-		elif test "x$enable_python" = "xautodetect"; then
-			enable_python=no
-			AC_MSG_WARN([$PYGOBJECT_PKG_ERRORS])
-			AC_MSG_WARN([Disabling python support])
-		fi
-		])
+AC_ARG_ENABLE([python],
+              AS_HELP_STRING([--enable-python[=@<:@no/auto/yes@:>@]],[Build with python support]),
+              [enable_python=$enableval],
+              [enable_python="auto"])
 
-	AC_SUBST([PYGOBJECT_CFLAGS])
-	AC_SUBST([PYGOBJECT_LIBS])
+if test "x$enable_python" = "xauto"; then
+	PKG_CHECK_EXISTS([pygobject-2.0 >= $PYGOBJECT_REQUIRED],
+	                 [enable_python=yes],[enable_python=no])
 fi
 
-if test "x$have_python" != "xno"; then
-	AC_MSG_CHECKING([for gst-python defs])
-	GST_PYTHON_DEFSDIR=`$PKG_CONFIG --variable=defsdir gst-python-0.10`
-	AC_MSG_RESULT([$GST_PYTHON_DEFSDIR])
-
-	AC_MSG_CHECKING([for pygobject codegen])
-	PYGOBJECT_CODEGEN="$PYTHON `$PKG_CONFIG --variable=codegendir pygobject-2.0`/codegen.py"
-	AC_MSG_RESULT([$PYGOBJECT_CODEGEN])
-
-	AC_MSG_CHECKING([for pygobject h2def])
-	PYGOBJECT_H2DEF="$PYTHON `$PKG_CONFIG --variable=codegendir pygobject-2.0`/h2def.py"
-	AC_MSG_RESULT([$PYGOBJECT_H2DEF])
-
-	AC_SUBST([GST_PYTHON_DEFSDIR])
-	AC_SUBST([PYGOBJECT_CODEGEN])
-	AC_SUBST([PYGOBJECT_H2DEF])
-fi
+if test "x$enable_python" = "xyes"; then
+	PKG_CHECK_MODULES(PYTHON, [pygobject-2.0 >= $PYGOBJECT_REQUIRED])
 
-if test "x$have_python" != "xno" -a "x$enable_python" != "xno"; then
-	enable_python=yes
-	AC_DEFINE([ENABLE_PYTHON],[1],[Define to compile with python plugin support])
+	pyoverridesdir=`$PKG_CONFIG --variable=overridesdir pygobject-2.0`
+	AC_SUBST(pyoverridesdir)
 fi
 
-AM_CONDITIONAL([ENABLE_PYTHON],[test "x$enable_python" = "xyes"])
+AM_CONDITIONAL(ENABLE_PYTHON, test x"$enable_python" = "xyes")
 
 dnl ================================================================
 dnl Vala plugins
diff --git a/data/org.gnome.rhythmbox.gschema.xml b/data/org.gnome.rhythmbox.gschema.xml
index b7b095d..9eeb447 100644
--- a/data/org.gnome.rhythmbox.gschema.xml
+++ b/data/org.gnome.rhythmbox.gschema.xml
@@ -256,11 +256,6 @@
       <summary>List of active plugin names.</summary>
       <description>List of active plugin names. These plugins will be loaded on startup if available.</description>
     </key>
-    <key name="hidden-plugins" type="as">
-      <default>['audiocd','cd-recorder','generic-player','iradio','mmkeys','mpris']</default>
-      <summary>List of hidden plugin names.</summary>
-      <description>List of hidden plugin names. These plugins will not be shown in the plugin configuration dialog.</description>
-    </key>
   </schema>
 
   <schema id="org.gnome.rhythmbox.plugins.audiocd" path="/org/gnome/rhythmbox/plugins/audiocd/">
@@ -311,6 +306,11 @@
     <child name="source" schema="org.gnome.rhythmbox.source"/>
   </schema>
 
+  <schema id="org.gnome.rhythmbox.plugins.iradio.source" extends="org.gnome.rhythmbox.source">
+    <override name="sorting">('Title',true)</override>
+    <override name="paned-position">200</override>
+    <override name="show-browser">true</override>
+  </schema>
   <schema id="org.gnome.rhythmbox.plugins.iradio" path="/org/gnome/rhythmbox/plugins/iradio/">
     <key name="initial-stations-loaded" type="b">
       <default>false</default>
@@ -318,7 +318,7 @@
       <description>Whether the initial station list has been loaded</description>
     </key>
 
-    <child name='source' schema='org.gnome.rhythmbox.source'/>
+    <child name='source' schema='org.gnome.rhythmbox.plugins.iradio.source'/>
   </schema>
 
   <enum id="org.gnome.rhythmbox.plugins.jamendo.audio-format">
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index 21cca16..d81304c 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -157,7 +157,6 @@ INCLUDES=\
 	$(RHYTHMBOX_CFLAGS)
 	
 if ENABLE_PYTHON
-BINDING_LIBS = $(top_builddir)/bindings/python/rb.la
 MORE_GTKDOC_LIBS = $(PYTHON_LIBS)
 endif
 
diff --git a/doc/reference/rhythmbox-sections.txt b/doc/reference/rhythmbox-sections.txt
index 9f1c371..ae07f0c 100644
--- a/doc/reference/rhythmbox-sections.txt
+++ b/doc/reference/rhythmbox-sections.txt
@@ -1166,34 +1166,6 @@ RB_LIBRARY_BROWSER_GET_CLASS
 </SECTION>
 
 <SECTION>
-<FILE>rb-plugin</FILE>
-<TITLE>RBPlugin</TITLE>
-RBPlugin
-RBPluginClass
-RBPluginActivationFunc
-RBPluginWidgetFunc
-RBPluginBooleanFunc
-rb_plugin_activate
-rb_plugin_deactivate
-rb_plugin_is_configurable
-rb_plugin_create_configure_dialog
-rb_plugin_find_file
-rb_get_plugin_paths
-RB_PLUGIN_REGISTER
-RB_PLUGIN_REGISTER_TYPE
-RB_PLUGIN_DEFINE_TYPE
-<SUBSECTION Standard>
-RB_PLUGIN
-RB_IS_PLUGIN
-RB_TYPE_PLUGIN
-rb_plugin_get_type
-RB_PLUGIN_CLASS
-RB_IS_PLUGIN_CLASS
-RB_PLUGIN_GET_CLASS
-RB_PLUGIN_CONST
-</SECTION>
-
-<SECTION>
 <FILE>rb-player-gst-filter</FILE>
 <TITLE>RBPlayerGstFilter</TITLE>
 RBPlayerGstFilter
diff --git a/doc/reference/rhythmbox.types b/doc/reference/rhythmbox.types
index 427891c..a2771a8 100644
--- a/doc/reference/rhythmbox.types
+++ b/doc/reference/rhythmbox.types
@@ -34,7 +34,6 @@
 #include "rb-play-order.h"
 #include "rb-play-order-random.h"
 #include "rb-play-queue-source.h"
-#include "rb-plugin.h"
 #include "rb-property-view.h"
 #include "rb-query-creator.h"
 #include "rb-rating.h"
@@ -99,7 +98,6 @@ rb_playlist_manager_get_type
 rb_playlist_source_get_type
 rb_play_order_get_type
 rb_play_queue_source_get_type
-rb_plugin_get_type
 rb_property_view_get_type
 rb_query_creator_get_type
 rb_random_play_order_get_type
diff --git a/lib/rb-file-helpers.c b/lib/rb-file-helpers.c
index 6b61e30..a3c579a 100644
--- a/lib/rb-file-helpers.c
+++ b/lib/rb-file-helpers.c
@@ -38,6 +38,8 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
+#include <libpeas/peas.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <config.h>
@@ -306,6 +308,59 @@ rb_find_user_cache_file (const char *name,
 }
 
 /**
+ * rb_find_plugin_data_file:
+ * @plugin: the plugin object
+ * @name: name of the file to find
+ *
+ * Locates a file under the plugin's data directory.
+ *
+ * Returns: allocated string containing the location of the file
+ */
+char *
+rb_find_plugin_data_file (GObject *object, const char *name)
+{
+	PeasPluginInfo *info;
+	char *ret = NULL;
+	const char *plugin_name = "<unknown>";
+
+	g_object_get (object, "plugin-info", &info, NULL);
+	if (info != NULL) {
+		char *tmp;
+
+		tmp = g_build_filename (peas_plugin_info_get_data_dir (info), name, NULL);
+		if (g_file_test (tmp, G_FILE_TEST_EXISTS)) {
+			ret = tmp;
+		} else {
+			g_free (tmp);
+		}
+
+		plugin_name = peas_plugin_info_get_name (info);
+	}
+	
+	if (ret == NULL) {
+		const char *f;
+		f = rb_file (name);
+		if (f != NULL) {
+			ret = g_strdup (f);
+		}
+	}
+
+	rb_debug ("found '%s' when searching for file '%s' for plugin '%s'",
+		  ret, name, plugin_name);
+
+	/* ensure it's an absolute path */
+	if (ret != NULL && ret[0] != '/') {
+		char *pwd = g_get_current_dir ();
+		char *path = g_strconcat (pwd, G_DIR_SEPARATOR_S, ret, NULL);
+		g_free (ret);
+		g_free (pwd);
+		ret = path;
+	}
+
+	return ret;
+}
+
+/**
  * rb_file_helpers_init:
  * @uninstalled: if %TRUE, search in source and build directories
  * as well as installed locations
diff --git a/lib/rb-file-helpers.h b/lib/rb-file-helpers.h
index 75a0bac..45366e3 100644
--- a/lib/rb-file-helpers.h
+++ b/lib/rb-file-helpers.h
@@ -43,6 +43,8 @@ char *		rb_find_user_data_file	(const char *name,
 					 GError **error);
 char *		rb_find_user_cache_file	(const char *name,
 					 GError **error);
+char *		rb_find_plugin_data_file (GObject *plugin,
+					 const char *name);
 
 char *		rb_canonicalise_uri	(const char *uri);
 
diff --git a/rhythmbox.h b/rhythmbox.h
index 2ed28c9..c1d29a2 100644
--- a/rhythmbox.h
+++ b/rhythmbox.h
@@ -48,7 +48,6 @@
 #include <shell/rb-removable-media-manager.h>
 #include <shell/rb-history.h>
 #include <shell/rb-play-order.h>
-#include <shell/rb-plugin.h>
 #include <sources/rb-display-page.h>
 #include <sources/rb-display-page-group.h>
 #include <sources/rb-display-page-model.h>
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 306010d..631e739 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -25,7 +25,7 @@ rhythmbox_SOURCES = main.c
 lib_LTLIBRARIES = librhythmbox-core.la
 
 INCLUDES = 						\
-        -DGNOMELOCALEDIR=\""$(datadir)/locale"\"        \
+	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"        \
 	-DG_LOG_DOMAIN=\"Rhythmbox\"		 	\
 	-I$(top_srcdir) 				\
 	-I$(top_srcdir)/lib                        	\
@@ -41,7 +41,7 @@ INCLUDES = 						\
 	-DPIXMAP_DIR=\""$(datadir)/pixmaps"\"		\
 	-DSHARE_DIR=\"$(pkgdatadir)\"                   \
 	-DDATADIR=\""$(datadir)"\"			\
-	-DRB_PLUGIN_DIR=\"$(PLUGINDIR)\"		\
+	-DLIBDIR=\""$(libdir)"\"			\
 	$(RHYTHMBOX_CFLAGS)				\
 	$(TOTEM_PLPARSER_CFLAGS)			\
 	$(DBUS_CFLAGS)					\
@@ -58,7 +58,6 @@ shellinclude_HEADERS =					\
 	rb-removable-media-manager.h			\
 	rb-history.h					\
 	rb-play-order.h					\
-	rb-plugin.h					\
 	rb-track-transfer-batch.h			\
 	rb-track-transfer-queue.h
 
@@ -97,15 +96,7 @@ librhythmbox_core_la_SOURCES =				\
 	rb-statusbar.c					\
 	rb-statusbar.h					\
 	rb-track-transfer-batch.c			\
-	rb-track-transfer-queue.c			\
-	\
-	rb-plugin.c					\
-	rb-module.h					\
-	rb-module.c					\
-	rb-plugin-manager.h				\
-	rb-plugin-manager.c				\
-	rb-plugins-engine.h				\
-	rb-plugins-engine.c
+	rb-track-transfer-queue.c
 
 librhythmbox_core_la_LIBADD =				\
 	$(top_builddir)/sources/libsources.la	        \
@@ -131,19 +122,6 @@ librhythmbox_core_la_LDFLAGS = 				\
 	-export-dynamic -no-undefined
 librhythmbox_core_la_LIBTOOLFLAGS = --tag=disable-static
 
-if ENABLE_PYTHON
-
-librhythmbox_core_la_SOURCES +=				\
-	rb-python-module.h				\
-	rb-python-module.c				\
-	rb-python-plugin.h				\
-	rb-python-plugin.c
-
-INCLUDES += $(PYGOBJECT_CFLAGS) $(PYTHON_CFLAGS)
-
-librhythmbox_core_la_LIBADD += $(PYTHON_LIBS)
-endif
-
 rb-shell-glue.h: rb-shell.xml Makefile
 	$(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=rb_shell --mode=glib-server --output=$@ $<
 rb-shell-binding.h: rb-shell.xml Makefile
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 828e101..aaf5e97 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -47,6 +47,10 @@
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #include <gtk/gtk.h>
+#include <girepository.h>
+
+#include <libpeas/peas.h>
+#include <libpeas-gtk/peas-gtk.h>
 
 #ifdef HAVE_MMKEYS
 #include <X11/XF86keysym.h>
@@ -82,8 +86,6 @@
 #include "rb-play-queue-source.h"
 #include "rb-missing-files-source.h"
 #include "rb-import-errors-source.h"
-#include "rb-plugins-engine.h"
-#include "rb-plugin-manager.h"
 #include "rb-util.h"
 #include "rb-display-page-model.h"
 #include "rb-song-info.h"
@@ -95,6 +97,8 @@
 
 #include "eggsmclient.h"
 
+#define UNINSTALLED_PLUGINS_LOCATION "plugins"
+
 #define PLAYING_ENTRY_NOTIFY_TIME 4
 
 static void rb_shell_class_init (RBShellClass *klass);
@@ -330,6 +334,10 @@ struct _RBShellPrivate
 	gboolean party_mode;
 
 	GSettings *settings;
+
+	GSettings *plugin_settings;
+	PeasEngine *plugin_engine;
+	PeasExtensionSet *activatable;
 };
 
 
@@ -1040,6 +1048,19 @@ rb_shell_shutdown (RBShell *shell)
 	display = gtk_widget_get_display (shell->priv->window);
 	gtk_widget_hide (shell->priv->window);
 	gdk_display_sync (display);
+
+	if (shell->priv->plugin_engine != NULL) {
+		g_object_unref (shell->priv->plugin_engine);
+		shell->priv->plugin_engine = NULL;
+	}
+	if (shell->priv->activatable != NULL) {
+		g_object_unref (shell->priv->activatable);
+		shell->priv->activatable = NULL;
+	}
+	if (shell->priv->plugin_settings != NULL) {
+		g_object_unref (shell->priv->plugin_settings);
+		shell->priv->plugin_settings = NULL;
+	}
 }
 
 static void
@@ -1508,6 +1529,124 @@ construct_load_ui (RBShell *shell)
 	rb_profile_end ("loading ui");
 }
 
+static void
+extension_added_cb (PeasExtensionSet *set, PeasPluginInfo *info, PeasExtension *extension, RBShell *shell)
+{
+	rb_debug ("activating extension %s", peas_plugin_info_get_name (info));
+	peas_extension_call (extension, "activate");
+}
+
+static void
+extension_removed_cb (PeasExtensionSet *set, PeasPluginInfo *info, PeasExtension *extension, RBShell *shell)
+{
+	rb_debug ("deactivating extension %s", peas_plugin_info_get_name (info));
+	peas_extension_call (extension, "deactivate");
+}
+
+static void
+construct_plugins (RBShell *shell)
+{
+	char *typelib_dir;
+	char *plugindir;
+	char *plugindatadir;
+	const GList *plugins;
+	const GList *l;
+	GError *error = NULL;
+
+	if (shell->priv->disable_plugins) {
+		return;
+	}
+
+	rb_profile_start ("loading plugins");
+	shell->priv->plugin_settings = g_settings_new ("org.gnome.rhythmbox.plugins");
+
+	shell->priv->plugin_engine = peas_engine_new ();
+	/* need an #ifdef for this? */
+	peas_engine_enable_loader (shell->priv->plugin_engine, "python");
+
+	typelib_dir = g_build_filename (LIBDIR,
+					"girepository-1.0",
+					NULL);
+	if (g_irepository_require_private (g_irepository_get_default (),
+					   typelib_dir, "MPID", "3.0", 0, &error) == FALSE) {
+		g_clear_error (&error);
+		if (g_irepository_require (g_irepository_get_default (), "MPID", "3.0", 0, &error) == FALSE) {
+			g_warning ("Could not load MPID typelib: %s", error->message);
+			g_clear_error (&error);
+		}
+	}
+
+	if (g_irepository_require_private (g_irepository_get_default (),
+					   typelib_dir, "RB", "3.0", 0, &error) == FALSE) {
+		g_clear_error (&error);
+		if (g_irepository_require (g_irepository_get_default (), "RB", "3.0", 0, &error) == FALSE) {
+			g_warning ("Could not load RB typelib: %s", error->message);
+			g_clear_error (&error);
+		}
+	}
+	g_free (typelib_dir);
+
+	if (g_irepository_require (g_irepository_get_default (), "Peas", "1.0", 0, &error) == FALSE) {
+		g_warning ("Could not load Peas typelib: %s", error->message);
+		g_clear_error (&error);
+	}
+
+	if (g_irepository_require (g_irepository_get_default (), "PeasGtk", "1.0", 0, &error) == FALSE) {
+		g_warning ("Could not load PeasGtk typelib: %s", error->message);
+		g_clear_error (&error);
+	}
+
+	plugindir = g_build_filename (rb_user_data_dir (), "plugins", NULL);
+	rb_debug ("plugin search path: %s", plugindir);
+	peas_engine_add_search_path (shell->priv->plugin_engine,
+				     plugindir,
+				     plugindir);
+	g_free (plugindir);
+
+	plugindir = g_build_filename (LIBDIR, "rhythmbox", "plugins", NULL);
+	plugindatadir = g_build_filename (DATADIR, "rhythmbox", "plugins", NULL);
+	rb_debug ("plugin search path: %s / %s", plugindir, plugindatadir);
+	peas_engine_add_search_path (shell->priv->plugin_engine,
+				     plugindir,
+				     /*plugindatadir*/ plugindir);
+	g_free (plugindir);
+	g_free (plugindatadir);
+
+#ifdef USE_UNINSTALLED_DIRS
+	plugindir = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "..", UNINSTALLED_PLUGINS_LOCATION, NULL);
+	rb_debug ("plugin search path: %s", plugindir);
+	peas_engine_add_search_path (shell->priv->plugin_engine,
+				     plugindir,
+				     plugindir);
+	g_free (plugindir);
+#endif
+
+	shell->priv->activatable = peas_extension_set_new (shell->priv->plugin_engine,
+							   PEAS_TYPE_ACTIVATABLE,
+							   "object", shell,
+							   NULL);
+	g_signal_connect (shell->priv->activatable, "extension-added", G_CALLBACK (extension_added_cb), shell);
+	g_signal_connect (shell->priv->activatable, "extension-removed", G_CALLBACK (extension_removed_cb), shell);
+
+	g_settings_bind (shell->priv->plugin_settings,
+			 "active-plugins",
+			 shell->priv->plugin_engine,
+			 "loaded-plugins",
+			 G_SETTINGS_BIND_DEFAULT);
+
+	/* load builtin plugins */
+	plugins = peas_engine_get_plugin_list (shell->priv->plugin_engine);
+	for (l = plugins; l != NULL; l = l->next) {
+		PeasPluginInfo *info = PEAS_PLUGIN_INFO (l->data);
+		if (peas_plugin_info_is_builtin (info) &&
+		    g_strcmp0 (peas_plugin_info_get_module_name (info), "rb") != 0) {
+			peas_engine_load_plugin (shell->priv->plugin_engine, info);
+		}
+	}
+
+	rb_profile_end ("loading plugins");
+}
+
 static gboolean
 _scan_idle (RBShell *shell)
 {
@@ -1574,6 +1713,8 @@ rb_shell_constructed (GObject *object)
 
 	construct_load_ui (shell);
 
+	construct_plugins (shell);
+
 	rb_shell_sync_window_state (shell, FALSE);
 	rb_shell_sync_smalldisplay (shell);
 	rb_shell_sync_party_mode (shell);
@@ -1581,9 +1722,6 @@ rb_shell_constructed (GObject *object)
 
 	rb_shell_select_page (shell, RB_DISPLAY_PAGE (shell->priv->library_source));
 
-	if (!shell->priv->disable_plugins)
-		rb_plugins_engine_init (shell);
-
 	/* by now we've added the built in sources and any sources from plugins,
 	 * so we can consider the fixed page groups loaded
 	 */
@@ -2468,7 +2606,7 @@ rb_shell_cmd_plugins (GtkAction *action,
 					 G_CALLBACK (rb_shell_plugins_response_cb),
 					 NULL, 0);
 
-		manager = rb_plugin_manager_new ();
+		manager = peas_gtk_plugin_manager_new (NULL);
 		gtk_widget_show_all (GTK_WIDGET (manager));
 		gtk_container_add (GTK_CONTAINER (content_area),
 				   manager);
@@ -2600,8 +2738,6 @@ rb_shell_quit (RBShell *shell,
 	/* Stop the playing source, if any */
 	rb_shell_player_stop (shell->priv->player_shell);
 
-	rb_plugins_engine_shutdown ();
-
 	rb_podcast_manager_shutdown (shell->priv->podcast_manager);
 
 	rb_shell_shutdown (shell);
diff --git a/sources/rb-display-page.c b/sources/rb-display-page.c
index 7dde3eb..ed0cad3 100644
--- a/sources/rb-display-page.c
+++ b/sources/rb-display-page.c
@@ -29,7 +29,7 @@
 #include "config.h"
 
 #include "rb-display-page.h"
-#include "rb-plugin.h"
+#include "rb-shell.h"
 #include "rb-debug.h"
 #include "rb-util.h"
 
@@ -58,7 +58,7 @@ struct _RBDisplayPagePrivate
 	GdkPixbuf *pixbuf;
 	RBDisplayPage *parent;
 
-	RBPlugin *plugin;
+	GObject *plugin;
 	RBShell *shell;
 
 	gboolean deleted;
@@ -685,9 +685,9 @@ rb_display_page_class_init (RBDisplayPageClass *klass)
 	g_object_class_install_property (object_class,
 					 PROP_PLUGIN,
 					 g_param_spec_object ("plugin",
-							      "RBPlugin",
-							      "RBPlugin instance for the plugin that created the page",
-							      RB_TYPE_PLUGIN,
+							      "plugin instance",
+							      "plugin instance that created the page",
+							      G_TYPE_OBJECT,
 							      G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 	/**
 	 * RBDisplayPage::deleted:
diff --git a/sources/rb-source.c b/sources/rb-source.c
index 227a31f..7711fcd 100644
--- a/sources/rb-source.c
+++ b/sources/rb-source.c
@@ -43,7 +43,6 @@
 #include "rb-source.h"
 #include "rb-util.h"
 #include "rb-static-playlist-source.h"
-#include "rb-plugin.h"
 #include "rb-play-order.h"
 
 static void rb_source_class_init (RBSourceClass *klass);
@@ -263,7 +262,7 @@ rb_source_class_init (RBSourceClass *klass)
 							      "settings",
 							      "GSettings instance",
 							      G_TYPE_SETTINGS,
-							      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+							      G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 	/**
 	 * RBSource:show-browser:
 	 *



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