[gnome-music/wip/gbsneto/contained-playlists: 15/29] playlists, playlistview: Fix removing and updating a playlist
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/gbsneto/contained-playlists: 15/29] playlists, playlistview: Fix removing and updating a playlist
- Date: Thu, 1 Dec 2016 23:26:50 +0000 (UTC)
commit dcab27a23cad8d1108219909a7ea316075af518a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Nov 29 13:35:33 2016 +0100
playlists, playlistview: Fix removing and updating a playlist
This commit finishes porting the signals' parameter to be of
Playlist class, and adapt the code to work around that.
gnomemusic/playlists.py | 16 ++++++++++------
gnomemusic/views/playlistview.py | 7 ++++---
gnomemusic/window.py | 2 +-
3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index d1e964e..db4aa1c 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -162,8 +162,8 @@ class StaticPlaylists:
class Playlists(GObject.GObject):
__gsignals__ = {
'playlist-added': (GObject.SignalFlags.RUN_FIRST, None, (Playlist,)),
- 'playlist-deleted': (GObject.SignalFlags.RUN_FIRST, None, (Grl.Media,)),
- 'playlist-updated': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
+ 'playlist-deleted': (GObject.SignalFlags.RUN_FIRST, None, (Playlist,)),
+ 'playlist-updated': (GObject.SignalFlags.RUN_FIRST, None, (Playlist,)),
'song-added-to-playlist': (
GObject.SignalFlags.RUN_FIRST, None, (Grl.Media, Grl.Media)
),
@@ -437,13 +437,17 @@ class Playlists(GObject.GObject):
)
@log
- def delete_playlist(self, item):
+ def delete_playlist(self, playlist):
def update_callback(conn, res, data):
- conn.update_finish(res)
- self.emit('playlist-deleted', item)
+ try:
+ conn.update_finish(res)
+ self.emit('playlist-deleted', self.playlists[playlist.id])
+ del self.playlists[playlist.id]
+ except GLib.Error as error:
+ logger.warn("Error: %s, %s", error.__class__, error)
self.tracker.update_async(
- Query.delete_playlist(item.get_id()), GLib.PRIORITY_LOW,
+ Query.delete_playlist(playlist.id), GLib.PRIORITY_LOW,
None, update_callback, None
)
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index ee4a5bb..93c6cfe 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -292,11 +292,12 @@ class PlaylistView(BaseView):
self.player.set_playing(True)
@log
- def on_playlist_update(self, widget, playlist_id):
+ def on_playlist_update(self, widget, playlist):
_iter = self.playlists_model.get_iter_first()
while _iter:
- playlist = self.playlists_model.get_value(_iter, 5)
- if str(playlist_id) == playlist.id and self.current_playlist == playlist:
+ current_playlist = self.playlists_model.get_value(_iter, 5)
+ if playlist == current_playlist and \
+ self.current_playlist == current_playlist:
path = self.playlists_model.get_path(_iter)
GLib.idle_add(self._on_playlist_activated, None, None, path)
break
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index abf0d50..26772fc 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -359,7 +359,7 @@ class Window(Gtk.ApplicationWindow):
undo_button = Gtk.Button.new_with_mnemonic(_("_Undo"))
label = _("Playlist %s removed" % (
- self.views[3].current_playlist.get_title()))
+ self.views[3].current_playlist.title))
grid.add(Gtk.Label.new(label))
grid.add(undo_button)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]