[gnome-music/wip/mschraal/core: 62/118] artistview: Make it work for all albums
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 62/118] artistview: Make it work for all albums
- Date: Wed, 26 Jun 2019 13:05:13 +0000 (UTC)
commit fe87375f741a77c3c57bcaca56e1c8ff79ca3cd9
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jun 5 23:36:03 2019 +0200
artistview: Make it work for all albums
gnomemusic/coremodel.py | 19 +++++++++++++++++++
gnomemusic/widgets/artistalbumswidget.py | 16 ++++++++++++++++
gnomemusic/widgets/artistalbumwidget.py | 21 +++------------------
3 files changed, 38 insertions(+), 18 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 5d04839c..a3487988 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -140,6 +140,25 @@ class CoreModel(GObject.GObject):
song.props.state = SongWidget.State.PLAYING
self.emit("playlist-loaded")
+ elif playlist_type == PlayerPlaylist.Type.PLAYLIST:
+ self._playlist_model.remove_all()
+
+ for artist_album in model:
+ for disc in artist_album.model:
+ for model_song in disc.model:
+ song = CoreSong(model_song.props.media)
+
+ self._playlist_model.append(song)
+ song.bind_property(
+ "state", model_song, "state",
+ GObject.BindingFlags.SYNC_CREATE)
+
+ media_id = model_song.props.media.get_id()
+ if song.props.media.get_id() == coresong.get_id():
+ song.props.state = SongWidget.State.PLAYING
+
+ self.emit("playlist-loaded")
+
def get_album_disc(self, media, discnr, model):
albums_ids = []
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index 2b5c05a8..5864a634 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -97,6 +97,21 @@ class ArtistAlbumsWidget(Gtk.Box):
# self._player.connect('song-changed', self._update_model)
self.show_all()
+ def _song_activated(self, widget, song_widget):
+ if self.props.selection_mode:
+ return
+
+ self._album = None
+ def _on_playlist_loaded(klass):
+ self._player.play(None, None, song_widget._media)
+ self._player._app._coremodel.disconnect(signal_id)
+
+ signal_id = self._player._app._coremodel.connect(
+ "playlist-loaded", _on_playlist_loaded)
+ self._player._app._coremodel.set_playlist_model(
+ PlayerPlaylist.Type.PLAYLIST, self._album, song_widget._media,
+ self._model)
+
@log
def _create_model(self):
"""Create the ListStore model for this widget."""
@@ -138,6 +153,7 @@ class ArtistAlbumsWidget(Gtk.Box):
self._widgets.append(widget)
widget.connect('songs-loaded', self._on_album_displayed)
+ widget.connect("song-activated", self._song_activated)
@log
def _update_model(self, player):
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 8c31ac64..8841c448 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -29,6 +29,7 @@ from gnomemusic.albumartcache import Art
from gnomemusic.grilo import grilo
from gnomemusic.player import PlayerPlaylist
from gnomemusic.widgets.disclistboxwidget import DiscBox
+from gnomemusic.widgets.songwidget import SongWidget
import gnomemusic.utils as utils
@@ -46,6 +47,7 @@ class ArtistAlbumWidget(Gtk.Box):
selection_mode = GObject.Property(type=bool, default=False)
__gsignals__ = {
+ "song-activated": (GObject.SignalFlags.RUN_FIRST, None, (SongWidget, )),
'songs-loaded': (GObject.SignalFlags.RUN_FIRST, None, ()),
}
@@ -153,24 +155,7 @@ class ArtistAlbumWidget(Gtk.Box):
if self.props.selection_mode:
return
- # self._player.set_playlist(
- # PlayerPlaylist.Type.ARTIST, self._artist, song_widget.model,
- # song_widget.itr)
- # self._player.play()
-
- # return True
-
- self._album = None
- def _on_playlist_loaded(klass):
- self._player.play(None, None, song_widget._media)
- self._player._app._coremodel.disconnect(signal_id)
-
- # coresong = listboxrow.get_child()
- signal_id = self._player._app._coremodel.connect(
- "playlist-loaded", _on_playlist_loaded)
- self._player._app._coremodel.set_playlist_model(
- PlayerPlaylist.Type.ALBUM, self._album, song_widget._media,
- self._model)
+ self.emit("song-activated", song_widget)
@log
def select_all(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]