[gnome-music/wip/gbsneto/contained-playlists: 27/29] playlistview: Select previous playlist if next not available



commit 73cc79d9aae893d5ba849ced15fec0d2a99392e9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 1 21:08:22 2016 -0200

    playlistview: Select previous playlist if next not available
    
    When removing the last playlist of the view, there is no next
    playlist to select, leading us to an invalid state.
    
    Fix that by selecting the previous row when the next is not
    available.

 gnomemusic/views/playlistview.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index 8c73a05..9f40dc8 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -362,6 +362,8 @@ class PlaylistView(BaseView):
         row = self.playlists_sidebar.get_selected_row()
         next_row = self.playlists_sidebar.get_row_at_index(
                                                 self.current_playlist_index + 1)
+        prev_row = self.playlists_sidebar.get_row_at_index(
+                                                self.current_playlist_index - 1)
         self.pl_todelete_index = self.current_playlist_index
         self.pl_todelete_row = row
         self.pl_todelete = row.playlist
@@ -374,6 +376,9 @@ class PlaylistView(BaseView):
         if next_row:
             self.playlists_sidebar.select_row(next_row)
             next_row.emit('activate')
+        elif prev_row:
+            self.playlists_sidebar.select_row(prev_row)
+            prev_row.emit('activate')
 
     @log
     def undo_playlist_deletion(self):


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