[gnome-music/wip/mschraal/glib-logging: 6/9] grlsearchwrapper: Cleanups



commit 4d4ef4ed8565dad675fc4ec1cc5dfd8fb32b4f75
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Jan 27 19:35:22 2020 +0100

    grlsearchwrapper: Cleanups
    
    * Pass application as argument, in line with GrlSearchWrapper.
    * Add docstrings.
    * Remove __repr__.

 gnomemusic/coregrilo.py                      |  2 +-
 gnomemusic/grilowrappers/grlsearchwrapper.py | 25 +++++++++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index ed2c9993..9741d05d 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -149,7 +149,7 @@ class CoreGrilo(GObject.GObject):
                 and source.get_supported_media() & Grl.MediaType.AUDIO
                 and source.supported_operations() & Grl.SupportedOps.SEARCH):
             self._search_wrappers[source.props.source_id] = GrlSearchWrapper(
-                source, self._coremodel, self._coreselection, self)
+                source, self._coremodel, self._application, self)
             print("search source", source)
 
     def _on_source_removed(self, registry, source):
diff --git a/gnomemusic/grilowrappers/grlsearchwrapper.py b/gnomemusic/grilowrappers/grlsearchwrapper.py
index 1b50dcba..8e9a70dc 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -30,6 +30,12 @@ from gnomemusic.coresong import CoreSong
 
 
 class GrlSearchWrapper(GObject.GObject):
+    """Wrapper for a generic Grilo source search.
+
+    Grilo has -besides source specific queries- an option to do a
+    generic source search, if the source supports it. This class wraps
+    such a search.
+    """
 
     METADATA_KEYS = [
         Grl.METADATA_KEY_ALBUM,
@@ -48,14 +54,21 @@ class GrlSearchWrapper(GObject.GObject):
         Grl.METADATA_KEY_URL
     ]
 
-    def __repr__(self):
-        return "<GrlSearchWrapper>"
+    def __init__(self, source, coremodel, application, grilo):
+        """Initialize a search wrapper
+
+        Initialize a generic Grilo source search wrapper.
 
-    def __init__(self, source, coremodel, coreselection, grilo):
+        :param Grl.Source source: The Grilo source to wrap
+        :param CoreModel coremodel: CoreModel instance to use models
+         from
+        :param Application application: Application instance
+        :param CoreGrilo grilo: The CoreGrilo instance
+        """
         super().__init__()
 
         self._coremodel = coremodel
-        self._coreselection = coreselection
+        self._coreselection = application.props.coreselection
         self._grilo = grilo
         self._source = source
 
@@ -75,6 +88,10 @@ class GrlSearchWrapper(GObject.GObject):
             Grl.ResolutionFlags.FAST_ONLY | Grl.ResolutionFlags.IDLE_RELAY)
 
     def search(self, text):
+        """Initiate a search
+
+        :param str text: The text to search
+        """
         with self._song_search_store.freeze_notify():
             self._song_search_store.remove_all()
 


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