Commit bca344b8 authored by Jonathan Matthew's avatar Jonathan Matthew

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.
parent f700521e
......@@ -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/">
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
[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
......
......@@ -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
......@@ -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
......@@ -6,3 +6,6 @@ _Description=Notification popups
Authors=Jonathan Matthew
Copyright=Copyright © 2010 Jonathan Matthew
Website=http://www.rhythmbox.org
[RB]
InitiallyEnabled=true
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment