[gnome-music/wip/jfelder/musicbrainz-coverart: 2/3] grilo: Watch resolve sources
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/musicbrainz-coverart: 2/3] grilo: Watch resolve sources
- Date: Tue, 2 Apr 2019 09:38:50 +0000 (UTC)
commit ac40aded08954edcc12392aeee232d918d3c4a54
Author: Jean Felder <jfelder src gnome org>
Date: Tue Apr 2 10:38:28 2019 +0200
grilo: Watch resolve sources
Introduce a new signal "new-resolve-source-found" when a RESOLVE
source has been found.
gnomemusic/grilo.py | 15 ++++++++++++---
gnomemusic/widgets/searchbar.py | 6 +++---
2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 6f91c0b9..1e5cdbc6 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -53,7 +53,10 @@ class Grilo(GObject.GObject):
__gsignals__ = {
'ready': (GObject.SignalFlags.RUN_FIRST, None, ()),
'changes-pending': (GObject.SignalFlags.RUN_FIRST, None, ()),
- 'new-source-added': (GObject.SignalFlags.RUN_FIRST, None, (Grl.Source, ))
+ 'new-resolve-source-added': (
+ GObject.SignalFlags.RUN_FIRST, None, (Grl.Source, )),
+ 'new-search-source-added': (
+ GObject.SignalFlags.RUN_FIRST, None, (Grl.Source, ))
}
METADATA_KEYS = [
@@ -265,13 +268,19 @@ class Grilo(GObject.GObject):
elif (id.startswith('grl-upnp')):
logger.debug("found upnp source %s", id)
self.props.sources[id] = mediaSource
- self.emit('new-source-added', mediaSource)
+ self.emit('new-search-source-added', mediaSource)
+
+ elif (ops & Grl.SupportedOps.RESOLVE
+ and mediaSource.get_supported_media() & Grl.MediaType.AUDIO):
+ logger.debug("source %s can be resolved", id)
+ self.props.sources[id] = mediaSource
+ self.emit('new-resolve-source-added', mediaSource)
elif (ops & Grl.SupportedOps.SEARCH
and mediaSource.get_supported_media() & Grl.MediaType.AUDIO):
logger.debug("source %s is searchable", id)
self.props.sources[id] = mediaSource
- self.emit('new-source-added', mediaSource)
+ self.emit('new-search-source-added', mediaSource)
except Exception as e:
logger.debug("Source {}: exception {}".format(id, e))
diff --git a/gnomemusic/widgets/searchbar.py b/gnomemusic/widgets/searchbar.py
index 87b2490b..292cb71d 100644
--- a/gnomemusic/widgets/searchbar.py
+++ b/gnomemusic/widgets/searchbar.py
@@ -118,7 +118,7 @@ class SourceManager(BaseManager):
self.values.append(['grl-tracker-source', _("Local"), ''])
self.props.default_value = 2
- grilo.connect('new-source-added', self._add_new_source)
+ grilo.connect('new-search-source-added', self._add_new_search_source)
@log
def fill_in_values(self, model):
@@ -132,7 +132,7 @@ class SourceManager(BaseManager):
self, 'grl-tracker-source')
@log
- def _add_new_source(self, klass, source):
+ def _add_new_search_source(self, klass, source):
value = [source.get_id(), source.get_name(), '']
iter_ = self._model.append()
self._model[iter_][0, 1, 2] = value
@@ -145,7 +145,7 @@ class SourceManager(BaseManager):
Adds available Grilo sources to the internal model.
"""
for id_ in grilo.props.sources:
- self._add_new_source(None, grilo.props.sources[id_])
+ self._add_new_search_source(None, grilo.props.sources[id_])
@GObject.Property
def active(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]