[grilo] registry: Glob pattern matching for plugin ranks
- From: Victor Toso <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] registry: Glob pattern matching for plugin ranks
- Date: Fri, 3 Aug 2018 20:37:14 +0000 (UTC)
commit d9c8b9f630f56893fd58a6cbda18695182b9f03c
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Jul 31 10:31:39 2018 +0200
registry: Glob pattern matching for plugin ranks
Source names can be constructed partially with unique identifiers, making
it difficult to match directly to the static identifiers in
GRL_PLUGIN_RANKS.
Introduce glob pattern matching for GRL_PLUGIN_RANKS, which allows for
example GRL_PLUGIN_RANKS="grl-lastfm-cover*:3".
Add a short explanation and example to the documentation as well.
https://bugzilla.gnome.org/show_bug.cgi?id=761695
https://gitlab.gnome.org/GNOME/grilo/merge_requests/17
doc/grilo/environment-setup.xml | 16 ++++++++++++++++
src/grl-registry.c | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
---
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..27fd41c 100644
--- a/src/grl-registry.c
+++ b/src/grl-registry.c
@@ -380,9 +380,25 @@ 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;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&iter, registry->priv->ranks);
+
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ if (g_pattern_match_simple (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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]