diff options
-rw-r--r-- | doc/grilo/environment-setup.xml | 16 | ||||
-rw-r--r-- | src/grl-registry.c | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/doc/grilo/environment-setup.xml b/doc/grilo/environment-setup.xml index b2a90ae..96267af 100644 --- a/doc/grilo/environment-setup.xml +++ b/doc/grilo/environment-setup.xml @@ -150,5 +150,21 @@ $ export GRL_DEBUG=registry:*,youtube:warning $ export GRL_PLUGIN_RANKS=youtube:5,bookmarks:-4 </programlisting> + <para> + Some plugins extend their plugin name with login specific identifiers. + To match these plugins the ranks environment variable allows for simple + glob pattern matching with the '?' and '*' wildcards. This can of course + also be used in other situations. + Here is one example: + </para> + + <programlisting> +# Set the rank of all coverart plugins to 2, but the Last.FM +# coverart plugin whether logged in or not to 5. +# Note that order is important here: the ranks are interpreted from +# right to left. +$ export GRL_PLUGIN_RANKS=grl-lastfm-cover*:5,*cover*:2 + </programlisting> + </section> </section> diff --git a/src/grl-registry.c b/src/grl-registry.c index a6189b7..afb9772 100644 --- a/src/grl-registry.c +++ b/src/grl-registry.c @@ -380,9 +380,26 @@ set_source_rank (GrlRegistry *registry, GrlSource *source) rank = GPOINTER_TO_INT (g_hash_table_lookup (registry->priv->ranks, grl_source_get_id (source))); + + if (!rank) { + GHashTableIter iter; + const gchar *key = NULL; + gpointer value; + + g_hash_table_iter_init(&iter, registry->priv->ranks); + + while (g_hash_table_iter_next (&iter, (gpointer *) &key, &value)) { + if (g_pattern_match_simple ((const gchar*) key, grl_source_get_id (source))) { + rank = GPOINTER_TO_INT (value); + break; + } + } + } + if (!rank) { rank = GRL_RANK_DEFAULT; } + g_object_set (source, "rank", rank, NULL); GRL_DEBUG ("Source rank '%s' : %d", grl_source_get_id (source), rank); } |