[gnome-music/wip/mschraal/core: 152/164] coremodel: Implement search machinery
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 152/164] coremodel: Implement search machinery
- Date: Mon, 1 Jul 2019 13:50:57 +0000 (UTC)
commit 91f37b1f5e79e5647476ea0793ecf4667766b11e
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Jul 1 01:02:15 2019 +0200
coremodel: Implement search machinery
gnomemusic/coregrilo.py | 11 ++++++++---
gnomemusic/coremodel.py | 6 ++++--
gnomemusic/grilowrappers/grldleynasource.py | 5 ++++-
gnomemusic/grilowrappers/grltrackersource.py | 6 +++++-
gnomemusic/widgets/searchbar.py | 17 ++++++++++-------
gnomemusic/window.py | 2 +-
6 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index e4e8fb98..844f12ec 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -13,7 +13,7 @@ class CoreGrilo(GObject.GObject):
def __init__(
self, coremodel, model, albums_model, artists_model,
- coreselection):
+ coreselection, song_search_model):
super().__init__()
self._coremodel = coremodel
@@ -22,6 +22,7 @@ class CoreGrilo(GObject.GObject):
self._wrappers = []
self._albums_model = albums_model
self._artists_model = artists_model
+ self._song_search_model = song_search_model
Grl.init(None)
@@ -36,12 +37,12 @@ class CoreGrilo(GObject.GObject):
new_wrapper = GrlTrackerSource(
source, self._model, self._albums_model,
self._artists_model, self._coremodel, self._coreselection,
- self)
+ self, self._song_search_model)
elif source.props.source_id[:10] == "grl-dleyna":
new_wrapper = GrlDLeynaSource(
source, self._model, self._albums_model,
self._artists_model, self._coremodel, self._coreselection,
- self)
+ self, self._song_search_model)
self._wrappers.append(new_wrapper)
print(new_wrapper, "added")
@@ -90,3 +91,7 @@ class CoreGrilo(GObject.GObject):
GLib.idle_add(
self._store_metadata, wrapper.props.source, media, key)
break
+
+ def search(self, text):
+ for wrapper in self._wrappers:
+ wrapper.search(text)
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index ff55956d..95b15a38 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -40,7 +40,6 @@ class CoreModel(GObject.GObject):
self._songliststore = SongListStore(self._model)
self._coreselection = coreselection
-
self._album_model = Gio.ListStore()
self._album_model_sort = Gfm.SortListModel.new(self._album_model)
self._album_model_sort.set_sort_func(
@@ -60,7 +59,7 @@ class CoreModel(GObject.GObject):
print("PLAYLIST_MODEL", self._playlist_model)
self._grilo = CoreGrilo(
self, self._model, self._album_model, self._artist_model,
- self._coreselection)
+ self._coreselection, self._song_search_model)
def _filter_selected(self, coresong):
return coresong.props.selected
@@ -185,3 +184,6 @@ class CoreModel(GObject.GObject):
def get_songs_search_model(self):
return self._song_search_model
+
+ def search(self, text):
+ self._grilo.search(text)
diff --git a/gnomemusic/grilowrappers/grldleynasource.py b/gnomemusic/grilowrappers/grldleynasource.py
index 6a20d57a..248b19e9 100644
--- a/gnomemusic/grilowrappers/grldleynasource.py
+++ b/gnomemusic/grilowrappers/grldleynasource.py
@@ -30,7 +30,7 @@ class GrlDLeynaSource(GObject.GObject):
def __init__(
self, source, model, albums_model, artists_model, coremodel,
- core_selection, grilo):
+ core_selection, grilo, song_search_model):
super().__init__()
self._coremodel = coremodel
@@ -97,3 +97,6 @@ class GrlDLeynaSource(GObject.GObject):
def populate_album_songs(self, media, callback):
pass
+
+ def search(self, text):
+ pass
diff --git a/gnomemusic/grilowrappers/grltrackersource.py b/gnomemusic/grilowrappers/grltrackersource.py
index db5cbd5e..9fdbf327 100644
--- a/gnomemusic/grilowrappers/grltrackersource.py
+++ b/gnomemusic/grilowrappers/grltrackersource.py
@@ -32,7 +32,7 @@ class GrlTrackerSource(GObject.GObject):
def __init__(
self, source, model, albums_model, artists_model, coremodel,
- coreselection, grilo):
+ coreselection, grilo, song_search_model):
super().__init__()
self._coremodel = coremodel
@@ -44,6 +44,7 @@ class GrlTrackerSource(GObject.GObject):
self._album_ids = {}
self._artists_model = artists_model
self._hash = {}
+ self._song_search_model = song_search_model
self._fast_options = Grl.OperationOptions()
self._fast_options.set_resolution_flags(
@@ -474,3 +475,6 @@ class GrlTrackerSource(GObject.GObject):
options = self._fast_options.copy()
self._source.query(query, self.METADATA_KEYS, options, _callback)
+
+ def search(self, text):
+ pass
diff --git a/gnomemusic/widgets/searchbar.py b/gnomemusic/widgets/searchbar.py
index 4d5c07a7..9a6668ea 100644
--- a/gnomemusic/widgets/searchbar.py
+++ b/gnomemusic/widgets/searchbar.py
@@ -337,10 +337,11 @@ class SearchBar(Gtk.SearchBar):
return '<SearchBar>'
@log
- def __init__(self):
+ def __init__(self, application):
"""Initialize the SearchBar"""
super().__init__()
+ self._application = application
self._timeout = None
self._dropdown = DropDown()
@@ -375,15 +376,17 @@ class SearchBar(Gtk.SearchBar):
self._timeout = None
search_term = self._search_entry.get_text()
- if grilo.search_source:
- fields_filter = self._dropdown.search_manager.active
- else:
- fields_filter = 'search_all'
+ # if grilo.search_source:
+ # fields_filter = self._dropdown.search_manager.active
+ # else:
+ # fields_filter = 'search_all'
if search_term != "":
self.props.stack.set_visible_child_name('search')
- view = self.props.stack.get_visible_child()
- view.set_search_text(search_term, fields_filter)
+
+ self._application._coremodel.search(search_term)
+ # view = self.props.stack.get_visible_child()
+ # view.set_search_text(search_term, fields_filter)
else:
self._set_error_style(False)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index f31feee4..d56a1348 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -133,7 +133,7 @@ class Window(Gtk.ApplicationWindow):
@log
def _setup_view(self):
self._search = Search()
- self._searchbar = SearchBar()
+ self._searchbar = SearchBar(self._app)
self._searchbar.props.stack = self._stack
self._headerbar = HeaderBar()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]