[rhythmbox] plugins: allow plugins to request to be enabled initially
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] plugins: allow plugins to request to be enabled initially
- Date: Sun, 19 Feb 2012 22:14:28 +0000 (UTC)
commit bca344b8d70cf39ceb57b3654124f23cad69e4b1
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Feb 19 23:10:08 2012 +1000
plugins: allow plugins to request to be enabled initially
This allows a plugin to request to be enabled the first time the user
starts the application with the plugin installed. This makes it
easier to add new default plugins, and allows plugins to be packaged
separately without messing with the GSettings default in the main
package.
data/org.gnome.rhythmbox.gschema.xml | 7 ++-
plugins/artdisplay/artdisplay.plugin.in | 3 +
plugins/artsearch/artsearch.plugin.in | 3 +
plugins/audioscrobbler/audioscrobbler.plugin.in | 3 +
.../brasero-disc-recorder/cd-recorder.plugin.in | 3 +
plugins/daap/daap.plugin.in | 3 +
.../dbus-media-server/dbus-media-server.plugin.in | 3 +
plugins/ipod/ipod.plugin.in | 3 +
plugins/lirc/Makefile.am | 2 +-
plugins/lirc/{lirc.plugin.in => rblirc.plugin.in} | 2 +-
plugins/mpris/mpris.plugin.in | 3 +
plugins/mtpdevice/mtpdevice.plugin.in | 3 +
plugins/notification/notification.plugin.in | 3 +
shell/rb-shell.c | 61 +++++++++++++++++++-
14 files changed, 98 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.rhythmbox.gschema.xml b/data/org.gnome.rhythmbox.gschema.xml
index f8986f4..5a1207c 100644
--- a/data/org.gnome.rhythmbox.gschema.xml
+++ b/data/org.gnome.rhythmbox.gschema.xml
@@ -253,10 +253,15 @@
<description>When set prevents loading of plugins from the user's home directory</description>
</key>
<key name="active-plugins" type="as">
- <default>['artdisplay','audiocd','audioscrobbler','cd-recorder','daap','dbus-media-server','generic-player','ipod','iradio','mmkeys','mpris','mtpdevice','notification']</default>
+ <default>[]</default>
<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="seen-plugins" type="as">
+ <default>[]</default>
+ <summary>List of plugins that have previously been seen.</summary>
+ <description>List of plugins that have previously been seen. Previously unseen plugins may be automatically enabled.</description>
+ </key>
</schema>
<schema id="org.gnome.rhythmbox.plugins.audiocd" path="/org/gnome/rhythmbox/plugins/audiocd/">
diff --git a/plugins/artdisplay/artdisplay.plugin.in b/plugins/artdisplay/artdisplay.plugin.in
index b231b17..89fa095 100644
--- a/plugins/artdisplay/artdisplay.plugin.in
+++ b/plugins/artdisplay/artdisplay.plugin.in
@@ -8,3 +8,6 @@ _Description=Fetch album covers from the Internet
Authors=James Livingston <doclivingston gmail com>
Copyright=Copyright  2006 James Livingston
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/artsearch/artsearch.plugin.in b/plugins/artsearch/artsearch.plugin.in
index 1e695cd..201373f 100644
--- a/plugins/artsearch/artsearch.plugin.in
+++ b/plugins/artsearch/artsearch.plugin.in
@@ -8,3 +8,6 @@ _Description=Fetch album covers from the Internet
Authors=Jonathan Matthew <jonathan d14n org>
Copyright=Copyright  2011 Jonathan Matthew
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/audioscrobbler/audioscrobbler.plugin.in b/plugins/audioscrobbler/audioscrobbler.plugin.in
index b2eda51..5772a3e 100644
--- a/plugins/audioscrobbler/audioscrobbler.plugin.in
+++ b/plugins/audioscrobbler/audioscrobbler.plugin.in
@@ -6,3 +6,6 @@ _Description=Submits song information to Last.fm and plays Last.fm radio streams
Authors=Alex Revo <xiphoidappendix gmail com>;Ruben Vermeersch <ruben Lambda1 be>
Copyright=Copyright  2005-2006 Alex Revo, Ruben Vermeersch
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/brasero-disc-recorder/cd-recorder.plugin.in b/plugins/brasero-disc-recorder/cd-recorder.plugin.in
index 3c10182..7793bdc 100644
--- a/plugins/brasero-disc-recorder/cd-recorder.plugin.in
+++ b/plugins/brasero-disc-recorder/cd-recorder.plugin.in
@@ -6,3 +6,6 @@ _Description=Record audio CDs from playlists and duplicate audio CDs
Authors=William Jon McCann, Rouquier Philippe
Copyright=Copyright  2006 William Jon McCann,  2008-2009 Rouquier Philippe
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/daap/daap.plugin.in b/plugins/daap/daap.plugin.in
index 6b5b394..93e16fd 100644
--- a/plugins/daap/daap.plugin.in
+++ b/plugins/daap/daap.plugin.in
@@ -6,3 +6,6 @@ _Description=Share music and play shared music on your local network
Authors=Charles Schmidt <cschmidt2 emich edu>, the Rhythmbox Developers
Copyright=Copyright  2005-2006 Charles Schmidt, the Rhythmbox Developers
Website=http://www.rhythmbox.org
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/dbus-media-server/dbus-media-server.plugin.in b/plugins/dbus-media-server/dbus-media-server.plugin.in
index b0ca90d..14f96d8 100644
--- a/plugins/dbus-media-server/dbus-media-server.plugin.in
+++ b/plugins/dbus-media-server/dbus-media-server.plugin.in
@@ -6,3 +6,6 @@ _Description=Provides an implementation of the MediaServer2 D-Bus interface spec
Authors=Jonathan Matthew
Copyright=Copyright  2010 Jonathan Matthew
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/ipod/ipod.plugin.in b/plugins/ipod/ipod.plugin.in
index 3d26eae..a9c8902 100644
--- a/plugins/ipod/ipod.plugin.in
+++ b/plugins/ipod/ipod.plugin.in
@@ -6,3 +6,6 @@ _Description=Support for Apple iPod devices (show the content, play from device)
Authors=James Livingston, Christophe Fergeau
Copyright=Copyright  2006 James Livingston
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/lirc/Makefile.am b/plugins/lirc/Makefile.am
index 7f87007..74cab23 100644
--- a/plugins/lirc/Makefile.am
+++ b/plugins/lirc/Makefile.am
@@ -30,7 +30,7 @@ INCLUDES = \
$(RHYTHMBOX_CFLAGS) \
-D_BSD_SOURCE
-plugin_in_files = lirc.plugin.in
+plugin_in_files = rblirc.plugin.in
%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
diff --git a/plugins/lirc/lirc.plugin.in b/plugins/lirc/rblirc.plugin.in
similarity index 94%
rename from plugins/lirc/lirc.plugin.in
rename to plugins/lirc/rblirc.plugin.in
index 1a12782..7a96f42 100644
--- a/plugins/lirc/lirc.plugin.in
+++ b/plugins/lirc/rblirc.plugin.in
@@ -1,7 +1,7 @@
[Plugin]
Module=rblirc
IAge=2
-_Name=LIRC
+_Name=LIRC
_Description=Control Rhythmbox using an infrared remote control
Authors=Jonathan Matthew <jonathan d14n org>
Copyright=Copyright  2006 Jonathan Matthew
diff --git a/plugins/mpris/mpris.plugin.in b/plugins/mpris/mpris.plugin.in
index c499a47..a88b230 100644
--- a/plugins/mpris/mpris.plugin.in
+++ b/plugins/mpris/mpris.plugin.in
@@ -6,3 +6,6 @@ _Description=Provides an implementation of the MPRIS D-Bus interface specificati
Authors=Jonathan Matthew
Copyright=Copyright  2010 Jonathan Matthew
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/mtpdevice/mtpdevice.plugin.in b/plugins/mtpdevice/mtpdevice.plugin.in
index 028d927..c80edec 100644
--- a/plugins/mtpdevice/mtpdevice.plugin.in
+++ b/plugins/mtpdevice/mtpdevice.plugin.in
@@ -6,3 +6,6 @@ _Description=Support for MTP devices (show the content, transfer, play from devi
Authors=Peter GrundstrÃm
Copyright=Copyright  2006-2007 Peter GrundstrÃm
Website=http://www.rhythmbox.org/
+
+[RB]
+InitiallyEnabled=true
diff --git a/plugins/notification/notification.plugin.in b/plugins/notification/notification.plugin.in
index fdc748e..9aee0c0 100644
--- a/plugins/notification/notification.plugin.in
+++ b/plugins/notification/notification.plugin.in
@@ -6,3 +6,6 @@ _Description=Notification popups
Authors=Jonathan Matthew
Copyright=Copyright  2010 Jonathan Matthew
Website=http://www.rhythmbox.org
+
+[RB]
+InitiallyEnabled=true
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 2ef24c4..71ca243 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -925,6 +925,8 @@ construct_plugins (RBShell *shell)
char *typelib_dir;
char *plugindir;
char *plugindatadir;
+ char **seen_plugins;
+ GPtrArray *new_plugins = NULL;
const GList *plugins;
const GList *l;
GError *error = NULL;
@@ -1010,16 +1012,73 @@ construct_plugins (RBShell *shell)
"loaded-plugins",
G_SETTINGS_BIND_DEFAULT);
- /* load builtin plugins */
+ seen_plugins = g_settings_get_strv (shell->priv->plugin_settings, "seen-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);
+ char *kf_name;
+ char *kf_path;
+ GKeyFile *keyfile;
+
+ /* load builtin plugins, except for the 'rb' utility module, which only
+ * gets loaded if another plugin needs it.
+ */
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);
+ continue;
+ }
+
+ /* have we seen this plugin before? */
+ if (rb_str_in_strv (peas_plugin_info_get_module_name (info), (const char **)seen_plugins)) {
+ continue;
+ }
+ if (new_plugins == NULL) {
+ new_plugins = g_ptr_array_new_with_free_func (g_free);
+ }
+ g_ptr_array_add (new_plugins, g_strdup (peas_plugin_info_get_module_name (info)));
+
+ /* it's a new plugin, see if it wants to be enabled */
+ kf_name = g_strdup_printf ("%s.plugin", peas_plugin_info_get_module_name (info));
+ kf_path = g_build_filename (peas_plugin_info_get_module_dir (info), kf_name, NULL);
+ g_free (kf_name);
+
+ keyfile = g_key_file_new ();
+ if (g_key_file_load_from_file (keyfile, kf_path, G_KEY_FILE_NONE, NULL)) {
+ if (g_key_file_get_boolean (keyfile, "RB", "InitiallyEnabled", NULL)) {
+ rb_debug ("loading new plugin %s", peas_plugin_info_get_module_name (info));
+ peas_engine_load_plugin (shell->priv->plugin_engine, info);
+ } else {
+ rb_debug ("new plugin %s not enabled", peas_plugin_info_get_module_name (info));
+ }
+ } else {
+ rb_debug ("couldn't load plugin file %s", kf_path);
}
+ g_free (kf_path);
+ g_key_file_unref (keyfile);
}
+ if (new_plugins != NULL) {
+ GPtrArray *update;
+ int i;
+
+ update = g_ptr_array_new_with_free_func (g_free);
+ for (i = 0; i < g_strv_length (seen_plugins); i++) {
+ g_ptr_array_add (update, g_strdup (seen_plugins[i]));
+ }
+ for (i = 0; i < new_plugins->len; i++) {
+ g_ptr_array_add (update, g_strdup (g_ptr_array_index (new_plugins, i)));
+ }
+
+ g_ptr_array_add (update, NULL);
+ g_settings_set_strv (shell->priv->plugin_settings, "seen-plugins", (const char * const *)update->pdata);
+
+ g_ptr_array_free (new_plugins, TRUE);
+ g_ptr_array_free (update, TRUE);
+ }
+
+ g_strfreev (seen_plugins);
+
rb_profile_end ("loading plugins");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]