[gnome-music] grilo: unregister unwanted sources



commit 83fb8bbc5ad3d6d452d7aabd563f502ef75ca334
Author: Marinus Schraal <mschraal src gnome org>
Date:   Tue May 24 11:50:45 2016 +0200

    grilo: unregister unwanted sources
    
    To make the net:plaintext filter actually work unregister the sources,
    do the same for the blacklisted sources.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747953

 gnomemusic/grilo.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 86a7eaf..19e5d50 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -172,7 +172,13 @@ class Grilo(GObject.GObject):
 
     @log
     def _on_source_added(self, pluginRegistry, mediaSource):
-        if "net:plaintext" in mediaSource.get_tags():
+        if ("net:plaintext" in mediaSource.get_tags()
+                or mediaSource.get_id() in self.blacklist):
+            try:
+                pluginRegistry.unregister_source(mediaSource)
+            except GLib.GError:
+                logger.error("Failed to unregister %s.",
+                             mediaSource.get_id())
             return
 
         id = mediaSource.get_id()
@@ -199,8 +205,8 @@ class Grilo(GObject.GObject):
                 self.sources[id] = mediaSource
                 self.emit('new-source-added', mediaSource)
 
-            elif (id not in self.blacklist) and (ops & Grl.SupportedOps.SEARCH) and \
-                 (mediaSource.get_supported_media() & Grl.MediaType.AUDIO):
+            elif (ops & Grl.SupportedOps.SEARCH
+                  and mediaSource.get_supported_media() & Grl.MediaType.AUDIO):
                 logger.debug("source %s is searchable", id)
                 self.sources[id] = mediaSource
                 self.emit('new-source-added', mediaSource)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]