[gnome-music/wip/mschraal/core: 54/57] blah work gfm
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 54/57] blah work gfm
- Date: Fri, 31 May 2019 09:41:17 +0000 (UTC)
commit 7c72c9ce9f28fb03b2a6581464e00a54d75096d0
Author: Marinus Schraal <mschraal gnome org>
Date: Tue May 14 16:19:20 2019 +0200
blah work gfm
gnomemusic/coremodel.py | 25 +++++++++++++++++++++----
gnomemusic/widgets/songwidget.py | 1 -
2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 7b7255ba..cd0e8775 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -1,9 +1,11 @@
import gi
gi.require_version('Dazzle', '1.0')
-from gi.repository import Dazzle, GObject, Gio
+from gi.repository import Dazzle, GObject, Gio, Gfm
+from gi._gi import pygobject_new_full
from gnomemusic import log
from gnomemusic.coregrilo import CoreGrilo
+from gnomemusic.coresong import CoreSong
from gnomemusic.grilo import grilo
@@ -13,7 +15,8 @@ class CoreModel(GObject.GObject):
def __init__(self):
super().__init__()
- self._model = Gio.ListStore()
+ self._test = Gfm.FilterListModel()
+ self._model = Gio.ListStore.new(CoreSong)
self._album_model = Gio.ListStore()
self._album_store = None
self._hash = {}
@@ -27,22 +30,36 @@ class CoreModel(GObject.GObject):
def get_model(self):
return self._model
+ def _wrap_list_store_sort_func(self, func):
+
+ def wrap(a, b, *user_data):
+ a = pygobject_new_full(a, False)
+ b = pygobject_new_full(b, False)
+ return func(a, b, *user_data)
+
+ return wrap
+
@log
def get_album_model(self, media):
albums_ids = []
model_filter = Dazzle.ListModelFilter.new(self._model)
+ # model_filter = Gfm.FilterListModel.new(self._model)
model_filter.set_filter_func(lambda a: False)
+ model_sort = Gfm.SortListModel.new_for_type(CoreSong)
def _filter_func(core_song):
return core_song.props.media.get_id() in albums_ids
- def _reverse_sort(song_a, song_b):
+ def _reverse_sort(song_a, song_b, data=None):
return song_b.props.track_number - song_a.props.track_number
def _callback(source, dunno, media, something, something2):
if media is None:
model_filter.set_filter_func(_filter_func)
+ model_sort.set_model(model_filter)
+ model_sort.set_sort_func(
+ self._wrap_list_store_sort_func(_reverse_sort))
return
albums_ids.append(media.get_id())
@@ -50,7 +67,7 @@ class CoreModel(GObject.GObject):
# For POC sake, use old grilo
grilo.populate_album_songs(media, _callback)
- return model_filter
+ return model_sort
@log
def get_albums_model(self):
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 498fbbb9..7ef59f81 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -101,7 +101,6 @@ class SongWidget(Gtk.EventBox):
time = utils.seconds_to_string(media.get_duration())
self._duration_label.set_text(time)
- print(media.get_favourite())
# self._star_image.props.favorite = media.get_favourite()
self._select_button.set_visible(False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]