PlaylistPanel: implement playing of selected album
This commit is contained in:
parent
950bd54804
commit
b88f1c6e0b
2 changed files with 25 additions and 1 deletions
|
@ -201,6 +201,12 @@ class Client(Base):
|
|||
self._add_action(self._remove_album_from_playlist, album)
|
||||
|
||||
|
||||
def play_album_from_playlist(self, album):
|
||||
"""Play the given album from the playlist."""
|
||||
self._logger.info("play album from playlist")
|
||||
self._add_action(self._play_album_from_playlist, album)
|
||||
|
||||
|
||||
def playpause(self):
|
||||
"""Play or pauses the current state."""
|
||||
self._logger.info("playpause")
|
||||
|
@ -456,6 +462,11 @@ class Client(Base):
|
|||
self._call('command_list_end')
|
||||
|
||||
|
||||
def _play_album_from_playlist(self, album):
|
||||
if album.get_tracks():
|
||||
self._call('playid', album.get_tracks()[0].get_id())
|
||||
|
||||
|
||||
def _playpause(self):
|
||||
"""Action: Perform the real play/pause command."""
|
||||
#status = self._parse_dict(self._call('status'))
|
||||
|
|
|
@ -94,6 +94,7 @@ class Window():
|
|||
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_PLAYLIST].connect('play', self.on_playlist_panel_play)
|
||||
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)
|
||||
|
@ -194,6 +195,10 @@ class Window():
|
|||
self._mcg.remove_album_from_playlist(album)
|
||||
|
||||
|
||||
def on_playlist_panel_play(self, widget, album):
|
||||
self._mcg.play_album_from_playlist(album)
|
||||
|
||||
|
||||
def on_cover_panel_toggle_fullscreen(self, widget):
|
||||
if not self._fullscreened:
|
||||
self._appwindow.fullscreen()
|
||||
|
@ -940,7 +945,8 @@ class CoverPanel(GObject.GObject):
|
|||
class PlaylistPanel(GObject.GObject):
|
||||
__gsignals__ = {
|
||||
'clear-playlist': (GObject.SIGNAL_RUN_FIRST, None, ()),
|
||||
'remove': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,))
|
||||
'remove': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
|
||||
'play': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,))
|
||||
}
|
||||
|
||||
|
||||
|
@ -986,6 +992,9 @@ class PlaylistPanel(GObject.GObject):
|
|||
self._standalone_image = builder.get_object('playlist-standalone-image')
|
||||
# Action bar
|
||||
action_bar = builder.get_object('playlist-standalone-actionbar')
|
||||
play_button = Gtk.Button('play')
|
||||
play_button.connect('clicked', self.on_standalone_play_clicked)
|
||||
action_bar.pack_end(play_button)
|
||||
remove_button = Gtk.Button('remove')
|
||||
remove_button.connect('clicked', self.on_standalone_remove_clicked)
|
||||
action_bar.pack_end(remove_button)
|
||||
|
@ -1045,6 +1054,10 @@ class PlaylistPanel(GObject.GObject):
|
|||
self.emit('remove', self._selected_albums[0])
|
||||
|
||||
|
||||
def on_standalone_play_clicked(self, widget):
|
||||
self.emit('play', self._selected_albums[0])
|
||||
|
||||
|
||||
def set_item_size(self, item_size):
|
||||
if self._item_size != item_size:
|
||||
self._item_size = item_size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue