[grilo/wip/mschraal/plugin-ranks-glob: 3/3] registry: Glob pattern matching for plugin ranks
- From: Victor Toso <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/wip/mschraal/plugin-ranks-glob: 3/3] registry: Glob pattern matching for plugin ranks
- Date: Wed, 1 Aug 2018 16:53:15 +0000 (UTC)
commit e071c61ea50096b40ebba4b6675ea5b7266f6b6d
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".
https://bugzilla.gnome.org/show_bug.cgi?id=761695
src/grl-registry.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/grl-registry.c b/src/grl-registry.c
index a6189b7..8f5008d 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;
+
+ g_hash_table_iter_init(&iter, registry->priv->ranks);
+
+ while (g_hash_table_iter_next (&iter, (gpointer *) &key, NULL)) {
+ if (g_pattern_match_simple ((const gchar*) key, grl_source_get_id (source))) {
+ rank = GPOINTER_TO_INT (g_hash_table_lookup (registry->priv->ranks,
+ (const gchar*) key));
+ 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]