[gnome-music/wip/mschraal/searchview-rework: 3/15] searchview: Limit shown results for artist & album
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/searchview-rework: 3/15] searchview: Limit shown results for artist & album
- Date: Sat, 3 Aug 2019 10:28:44 +0000 (UTC)
commit 2717deedd36f306e88465ad7156d0a7ddad916e3
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 | 24 ++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 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 9d3e72fe..02886205 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -22,8 +22,6 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-from gi.repository import Gdk, GObject, Gtk
-
from gnomemusic import log
from gnomemusic.player import PlayerPlaylist
from gnomemusic.utils import View
@@ -70,18 +68,26 @@ 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._player = self._application.props.player
self._songs_listbox.bind_model(self._model, self._create_song_widget)
self._album_flowbox.bind_model(
- self._album_model, self._create_album_widget)
+ self._album_filter, self._create_album_widget)
self._album_flowbox.connect(
"child-activated", self._on_album_activated)
self._artist_listbox.bind_model(
- self._artist_model, self._create_artist_widget)
+ self._artist_filter, self._create_artist_widget)
self.show_all()
@@ -109,6 +115,16 @@ class SearchView(Gtk.Stack):
# self.connect("notify::search-state", self._on_search_state_changed)
+ 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]