PlaylistPanel: implement removing of albums (resolves #3)

This commit is contained in:
coderkun 2016-08-07 21:13:07 +02:00
commit 950bd54804
2 changed files with 27 additions and 1 deletions

View file

@ -195,6 +195,12 @@ class Client(Base):
self._add_action(self._clear_playlist)
def remove_album_from_playlist(self, album):
"""Remove the given album from the playlist."""
self._logger.info("remove album from playlist")
self._add_action(self._remove_album_from_playlist, album)
def playpause(self):
"""Play or pauses the current state."""
self._logger.info("playpause")
@ -443,6 +449,13 @@ class Client(Base):
self._call('clear')
def _remove_album_from_playlist(self, album):
self._call_list('command_list_begin')
for track in album.get_tracks():
self._call_list('deleteid', track.get_id())
self._call('command_list_end')
def _playpause(self):
"""Action: Perform the real play/pause command."""
#status = self._parse_dict(self._call('status'))

View file

@ -93,6 +93,7 @@ class Window():
self._panels[Window._PANEL_INDEX_COVER].connect('tracklist-size-changed', self.on_cover_panel_tracklist_size_changed)
self._panels[Window._PANEL_INDEX_COVER].connect('set-song', self.on_cover_panel_set_song)
self._panels[Window._PANEL_INDEX_PLAYLIST].connect('clear-playlist', self.on_playlist_panel_clear_playlist)
self._panels[Window._PANEL_INDEX_PLAYLIST].connect('remove', self.on_playlist_panel_remove)
self._panels[Window._PANEL_INDEX_LIBRARY].connect('update', self.on_library_panel_update)
self._panels[Window._PANEL_INDEX_LIBRARY].connect('play', self.on_library_panel_play)
self._panels[Window._PANEL_INDEX_LIBRARY].connect('item-size-changed', self.on_library_panel_item_size_changed)
@ -189,6 +190,10 @@ class Window():
self._mcg.clear_playlist()
def on_playlist_panel_remove(self, widget, album):
self._mcg.remove_album_from_playlist(album)
def on_cover_panel_toggle_fullscreen(self, widget):
if not self._fullscreened:
self._appwindow.fullscreen()
@ -934,7 +939,8 @@ class CoverPanel(GObject.GObject):
class PlaylistPanel(GObject.GObject):
__gsignals__ = {
'clear-playlist': (GObject.SIGNAL_RUN_FIRST, None, ())
'clear-playlist': (GObject.SIGNAL_RUN_FIRST, None, ()),
'remove': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,))
}
@ -980,6 +986,9 @@ class PlaylistPanel(GObject.GObject):
self._standalone_image = builder.get_object('playlist-standalone-image')
# Action bar
action_bar = builder.get_object('playlist-standalone-actionbar')
remove_button = Gtk.Button('remove')
remove_button.connect('clicked', self.on_standalone_remove_clicked)
action_bar.pack_end(remove_button)
def get(self):
@ -1032,6 +1041,10 @@ class PlaylistPanel(GObject.GObject):
self._appwindow.set_titlebar(self._headerbar)
def on_standalone_remove_clicked(self, widget):
self.emit('remove', self._selected_albums[0])
def set_item_size(self, item_size):
if self._item_size != item_size:
self._item_size = item_size