[gnome-music/wip/gbsneto/contained-playlists: 29/35] playlists, playlistview: Code cleanup



commit 51b50c70fb918191093f82d8c18abde0775716bb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 1 20:23:53 2016 -0200

    playlists, playlistview: Code cleanup
    
    After so many back and forth of the code, lets cleanup
    the code a little bit.

 gnomemusic/playlists.py          |   17 ++---------------
 gnomemusic/views/playlistview.py |   17 +++++------------
 2 files changed, 7 insertions(+), 27 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 4949635..f64a80c 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -402,7 +402,7 @@ class Playlists(GObject.GObject):
                 new_playlist = Playlist(item.get_id(), utils.get_media_title(item))
                 new_playlist.grilo_item = item
 
-                self.playlists[new_playlist] = new_playlist
+                self.playlists[new_playlist.id] = new_playlist
                 self.emit('playlist-added', new_playlist)
 
         def cursor_callback(cursor, res, data):
@@ -444,7 +444,7 @@ class Playlists(GObject.GObject):
         def update_callback(conn, res, data):
             try:
                 conn.update_finish(res)
-                self.emit('playlist-deleted', self.playlists[playlist.id])
+                self.emit('playlist-deleted', playlist)
                 del self.playlists[playlist.id]
             except GLib.Error as error:
                 logger.warn("Error: %s, %s", error.__class__, error)
@@ -511,19 +511,6 @@ class Playlists(GObject.GObject):
         return self.playlists.values()
 
     @log
-    def is_static_playlist(self, playlist):
-        """Checks whether the given playlist is static or not
-
-        :return: True if the playlist is static
-        :rtype: bool
-        """
-        for static_playlist_id in self._static_playlists.get_ids():
-            if playlist.get_id() == static_playlist_id:
-                return True
-
-        return False
-
-    @log
     def do_get_property(self, property):
         if property.name == 'ready':
             return self.ready
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index cb65294..dc1bf7a 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -422,24 +422,21 @@ class PlaylistView(BaseView):
 
     @log
     def _on_song_added_to_playlist(self, playlists, playlist, item):
-        if self.current_playlist and \
-           playlist.id == self.current_playlist.id:
+        if self.current_playlist == playlist:
             self._add_item_to_model(item, self.model)
 
     @log
     def _on_song_removed_from_playlist(self, playlists, playlist, item):
-        if self.current_playlist and \
-           playlist.id == self.current_playlist.id:
-            model = self.model
-        else:
+        if self.current_playlist != playlist:
             return
 
+        model = self.model
         update_playing_track = False
+
         for row in model:
             if row[5].get_id() == item.get_id():
                 # Is the removed track now being played?
-                if self.current_playlist and \
-                   playlist.id == self.current_playlist.id:
+                if self.current_playlist == playlist:
                     if self.player.currentTrack is not None and self.player.currentTrack.valid():
                         currentTrackpath = self.player.currentTrack.get_path().to_string()
                         if row.path is not None and row.path.to_string() == currentTrackpath:
@@ -468,10 +465,6 @@ class PlaylistView(BaseView):
                 return
 
     @log
-    def populate(self):
-        pass
-
-    @log
     def get_selected_tracks(self, callback):
         callback([self.model.get_value(self.model.get_iter(path), 5)
                   for path in self.view.get_selection()])


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