[gnome-music/wip/mschraal/core] coremodel: Sort artists model
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gnome-music/wip/mschraal/core] coremodel: Sort artists model
- Date: Sun, 23 Jun 2019 23:57:38 +0000 (UTC)
commit 23165eddcc2299de7acf40f8e4222ccaa4c43902
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 23 15:25:04 2019 +0200
    coremodel: Sort artists model
 gnomemusic/coremodel.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 24ad6866..dc25ce47 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -53,6 +53,9 @@ class CoreModel(GObject.GObject):
             self._wrap_list_store_sort_func(self._albums_sort))
 
         self._artist_model = Gio.ListStore.new(CoreArtist)
+        self._artist_model_sort = Gfm.SortListModel.new(self._artist_model)
+        self._artist_model_sort.set_sort_func(
+            self._wrap_list_store_sort_func(self._artist_sort))
 
         self._playlist_model = Gio.ListStore.new(CoreSong)
         self._playlist_model_sort = Gfm.SortListModel.new(self._playlist_model)
@@ -79,6 +82,9 @@ class CoreModel(GObject.GObject):
     def _albums_sort(self, album_a, album_b):
         return album_b.props.title.lower() < album_a.props.title.lower()
 
+    def _artist_sort(self, artist_a, artist_b):
+        return artist_b.props.artist.lower() < artist_a.props.artist.lower()
+
     @log
     def get_model(self):
         return self._model
@@ -185,7 +191,7 @@ class CoreModel(GObject.GObject):
         return self._album_model_sort
 
     def get_artists_model(self):
-        return self._artist_model
+        return self._artist_model_sort
 
     def get_artist_albums(self, artist):
         albums = self._grilo.get_artist_albums(artist)
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]