[gnome-music/wip/mschraal/core: 5/12] songsview: Make favorites work
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 5/12] songsview: Make favorites work
- Date: Thu, 27 Jun 2019 09:34:09 +0000 (UTC)
commit c34105171db31addd8b0718beb6190f376dc441e
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jun 26 23:36:10 2019 +0200
songsview: Make favorites work
gnomemusic/songliststore.py | 2 +-
gnomemusic/views/songsview.py | 2 +-
gnomemusic/widgets/starhandlerwidget.py | 13 +++++++------
3 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/songliststore.py b/gnomemusic/songliststore.py
index 78db9321..7025b84d 100644
--- a/gnomemusic/songliststore.py
+++ b/gnomemusic/songliststore.py
@@ -40,4 +40,4 @@ class SongListStore(Gtk.ListStore):
self.props.model.insert_with_valuesv(
position, [2, 3, 5, 9],
[coresong.props.title, coresong.props.artist, coresong,
- coresong.props.favorite])
+ int(coresong.props.favorite)])
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index d280cb48..f7cf08c7 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -208,7 +208,7 @@ class SongsView(BaseView):
if self.props.selection_mode:
return
- itr = self.model.get_iter(path)
+ itr = self._view.props.model.get_iter(path)
self.player.set_playlist(
PlayerPlaylist.Type.SONGS, None, self.model, itr)
self.player.play()
diff --git a/gnomemusic/widgets/starhandlerwidget.py b/gnomemusic/widgets/starhandlerwidget.py
index 021cfbdd..e42df079 100644
--- a/gnomemusic/widgets/starhandlerwidget.py
+++ b/gnomemusic/widgets/starhandlerwidget.py
@@ -136,21 +136,22 @@ class StarHandlerWidget(object):
@log
def _on_star_toggled(self, widget, path):
"""Called if a star is clicked"""
+ model = self._parent._view.props.model
try:
- _iter = self._parent.model.get_iter(path)
+ _iter = model.get_iter(path)
except ValueError:
return
try:
- if self._parent.model[_iter][self._star_index] == 2:
+ if model[_iter][self._star_index] == 2:
return
except AttributeError:
return
- new_value = not self._parent.model[_iter][self._star_index]
- self._parent.model[_iter][self._star_index] = new_value
- song_item = self._parent.model[_iter][5]
- grilo.toggle_favorite(song_item)
+ new_value = not model[_iter][self._star_index]
+ model[_iter][self._star_index] = new_value
+ coresong = model[_iter][5]
+ coresong.props.favorite = new_value
playlists.update_smart_playlist(SmartPlaylists.Favorites)
# Use this flag to ignore the upcoming _on_item_activated call
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]