[gnome-music/wip/jfelder/coremodel-playlists-sort: 2/2] coremodel: Fix playlist sorter
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/coremodel-playlists-sort: 2/2] coremodel: Fix playlist sorter
- Date: Sun, 20 Feb 2022 20:35:06 +0000 (UTC)
commit 538438efb9a25f083cac3a5e3f1fc2c6df93e4cd
Author: Jean Felder <jfelder src gnome org>
Date: Sun Feb 20 17:06:38 2022 +0100
coremodel: Fix playlist sorter
Sort functions now rely on the GtkOrdering enum.
gnomemusic/coremodel.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 97a930405..2ab5a59cf 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -214,15 +214,21 @@ class CoreModel(GObject.GObject):
def _playlists_sort(self, playlist_a, playlist_b, data=None):
if playlist_a.props.is_smart:
if not playlist_b.props.is_smart:
- return -1
+ return Gtk.Ordering.SMALLER
return utils.natural_sort_names(
playlist_a.props.title, playlist_b.props.title)
if playlist_b.props.is_smart:
- return 1
+ return Gtk.Ordering.LARGER
- return GLib.DateTime.compare(
+ date_compare = GLib.DateTime.compare(
playlist_b.props.creation_date, playlist_a.props.creation_date)
+ if date_compare == -1:
+ return Gtk.Ordering.SMALLER
+ elif date_compare == 1:
+ return Gtk.Ordering.LARGER
+ else:
+ return Gtk.Ordering.EQUAL
def _set_player_model(self, playlist_type, model):
"""Set the model for PlayerPlaylist to use
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]