[gnome-music/wip/jfelder/searchview-new-style: 1/11] searchview: Limit shown results for artist & album
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/searchview-new-style: 1/11] searchview: Limit shown results for artist & album
- Date: Sat, 3 Aug 2019 18:15:36 +0000 (UTC)
commit d8fa16cd21d8fd495d015ec0e845af5ec5281a62
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jul 31 11:22:24 2019 +0200
searchview: Limit shown results for artist & album
gnomemusic/coremodel.py | 18 ++++++++++++++++++
gnomemusic/views/searchview.py | 31 ++++++++++++++++++++++++++-----
2 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index d71092d2..ff8f5a38 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -107,10 +107,16 @@ class CoreModel(GObject.GObject):
self._album_model)
self._album_search_model.set_filter_func(lambda a: False)
+ self._album_search_filter = Gfm.FilterListModel.new(
+ self._album_search_model)
+
self._artist_search_model = Dazzle.ListModelFilter.new(
self._artist_model)
self._artist_search_model.set_filter_func(lambda a: False)
+ self._artist_search_filter = Gfm.FilterListModel.new(
+ self._artist_search_model)
+
self._playlists_model = Gio.ListStore.new(Playlist)
self._playlists_model_filter = Dazzle.ListModelFilter.new(
self._playlists_model)
@@ -432,12 +438,24 @@ class CoreModel(GObject.GObject):
def albums_search(self):
return self._album_search_model
+ @GObject.Property(
+ type=Gfm.FilterListModel, default=None,
+ flags=GObject.ParamFlags.READABLE)
+ def albums_search_filter(self):
+ return self._album_search_filter
+
@GObject.Property(
type=Dazzle.ListModelFilter, default=None,
flags=GObject.ParamFlags.READABLE)
def artists_search(self):
return self._artist_search_model
+ @GObject.Property(
+ type=Gfm.FilterListModel, default=None,
+ flags=GObject.ParamFlags.READABLE)
+ def artists_search_filter(self):
+ return self._artist_search_filter
+
@GObject.Property(
type=Gtk.ListStore, default=None, flags=GObject.ParamFlags.READABLE)
def songs_gtkliststore(self):
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index a0f0437a..5a8adfe6 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -73,7 +73,24 @@ class SearchView(Gtk.Stack):
self._coremodel = application.props.coremodel
self._model = self._coremodel.props.songs_search
self._album_model = self._coremodel.props.albums_search
+ self._album_filter = self._coremodel.props.albums_search_filter
+ self._album_filter.set_filter_func(
+ self._core_filter, self._album_model, 12)
+
self._artist_model = self._coremodel.props.artists_search
+ self._artist_filter = self._coremodel.props.artists_search_filter
+ self._artist_filter.set_filter_func(
+ self._core_filter, self._artist_model, 6)
+
+ self._songs_listbox.bind_model(self._model, self._create_song_widget)
+
+ self._album_flowbox.bind_model(
+ self._album_filter, self._create_album_widget)
+ self._album_flowbox.connect(
+ "child-activated", self._on_album_activated)
+
+ self._artist_listbox.bind_model(
+ self._artist_filter, self._create_artist_widget)
self._player = self._application.props.player
@@ -101,11 +118,15 @@ class SearchView(Gtk.Stack):
self._search_mode_active = False
# self.connect("notify::search-state", self._on_search_state_changed)
- self._artist_listbox.bind_model(
- self._artist_model, self._create_artist_widget)
- self._songs_listbox.bind_model(self._model, self._create_song_widget)
- self._album_flowbox.bind_model(
- self._album_model, self._create_album_widget)
+ def _core_filter(self, coreitem, coremodel, nr_items):
+ if coremodel.get_n_items() <= 5:
+ return True
+
+ for i in range(nr_items):
+ if coremodel.get_item(i) == coreitem:
+ return True
+
+ return False
def _create_song_widget(self, coresong):
song_widget = SongWidget(coresong)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]