[gnome-music/wip/jfelder/reset-playing-state-3-34] coremodel: Reset states when changing player playlist



commit ef4a03a20136e00c9120e7e5a21822faf18ce0c5
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Sep 9 19:23:03 2019 +0200

    coremodel: Reset states when changing player playlist
    
    When changing the player playlist, the state of the coresongs from the
    current model are not updated. Thus, the playing are played states of
    the current model are unchanged. For example; this means that the play
    icon of the current model will still be visible once an other
    model (album, artist, etc) is loaded (the PLAYING state will still be
    set).
    
    Fix the issue by removing the PLAYING and PLAYED states of the
    coresongs from the current model before changing the player model.

 gnomemusic/coremodel.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 0df16163..ef1d67e6 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -246,6 +246,11 @@ class CoreModel(GObject.GObject):
                         | GObject.BindingFlags.SYNC_CREATE)
 
         with model.freeze_notify():
+            played_states = [SongWidget.State.PLAYING, SongWidget.State.PLAYED]
+            for song in self._playlist_model:
+                if song.props.state in played_states:
+                    song.props.state = SongWidget.State.UNPLAYED
+
             self._playlist_model.remove_all()
 
             if playlist_type == PlayerPlaylist.Type.ALBUM:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]