[gnome-music/wip/jfelder/stop-deleted-playlist] playlistcontrols: Stop a deleted playlist if it is playing



commit 87ef5d9f8f0e41124e74e430c2645ec7c1e73aa3
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Feb 26 21:39:11 2020 +0100

    playlistcontrols: Stop a deleted playlist if it is playing
    
    On a playlist deletion, stop the the player and hide the player
    toolbar if the player playlist is the playlist which is deleted.
    
    This feature was lost during the core rewrite.

 gnomemusic/widgets/playlistcontrols.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index 8fef3b41..4a517814 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -82,6 +82,7 @@ class PlaylistControls(Gtk.Grid):
             return
 
         self._coremodel = application.props.coremodel
+        self._player = application.props.player
         self._window = application.props.window
 
         self._window.add_action(self._delete_action)
@@ -89,17 +90,16 @@ class PlaylistControls(Gtk.Grid):
         self._window.add_action(self._rename_action)
 
     def _on_delete_action(self, menutime, data=None):
+        active_playlist = self._coremodel.props.active_playlist
+        if (active_playlist is not None
+                and active_playlist == self.props.playlist):
+            self._player.stop()
+            self._window.set_player_visible(False)
+
         PlaylistNotification(
             self._window.notifications_popup, self._coremodel,
             PlaylistNotification.Type.PLAYLIST, self.props.playlist)
 
-        # FIXME: Should Check that the playlist is not playing
-        # playlist_id = selection.playlist.props.pl_id
-        # if self._player.playing_playlist(
-        #         PlayerPlaylist.Type.PLAYLIST, playlist_id):
-        #     self._player.stop()
-        #     self._window.set_player_visible(False)
-
     @Gtk.Template.Callback()
     def _on_rename_entry_changed(self, selection):
         selection_length = selection.props.text_length


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