Commit a0ed0b16 authored by Jean Felder's avatar Jean Felder Committed by Marinus Schraal

artistsview: Display the albums once all of them are ready

parent 58ae0e02
......@@ -105,6 +105,10 @@ class ArtistsView(BaseView):
vhomogeneous=False)
self._view_container.add(self._view)
empty_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE, hexpand=True)
empty_frame.show()
self._view.add_named(empty_frame, "empty-frame")
@log
def _on_changes_pending(self, data=None):
if (self._init
......@@ -131,11 +135,16 @@ class ArtistsView(BaseView):
artist_albums = ArtistAlbumsWidget(
coreartist, self.player, self._window, False)
artist_albums.connect(
"ready", self._on_artist_albums_ready, coreartist)
self._view.set_visible_child_name("empty-frame")
return
def _on_artist_albums_ready(self, klass, coreartist):
new_artist_albums_widget = Gtk.Frame(
shadow_type=Gtk.ShadowType.NONE, hexpand=True)
new_artist_albums_widget.add(artist_albums)
new_artist_albums_widget.add(klass)
new_artist_albums_widget.show()
self._view.add_named(new_artist_albums_widget, coreartist.props.artist)
scroll_vadjustment = self._view_container.props.vadjustment
scroll_vadjustment.props.value = 0.
......
......@@ -46,6 +46,10 @@ class ArtistAlbumsWidget(Gtk.ListBox):
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
__gsignals__ = {
"ready": (GObject.SignalFlags.RUN_FIRST, None, ()),
}
def __repr__(self):
return '<ArtistAlbumsWidget>'
......@@ -66,6 +70,7 @@ class ArtistAlbumsWidget(Gtk.ListBox):
self._songs_grid_size_group = Gtk.SizeGroup.new(
Gtk.SizeGroupMode.HORIZONTAL)
self._nb_albums_loaded = 0
self._model.props.model.connect_after(
"items-changed", self. _on_model_items_changed)
self.bind_model(self._model, self._add_album)
......@@ -80,7 +85,7 @@ class ArtistAlbumsWidget(Gtk.ListBox):
coremodel = self._player._app.props.coremodel
def _on_playlist_loaded(klass):
def _on_playlist_loaded(artistalbumwidget):
self._player.play(song_widget.props.coresong)
coremodel.disconnect(signal_id)
......@@ -98,10 +103,18 @@ class ArtistAlbumsWidget(Gtk.ListBox):
| GObject.BindingFlags.SYNC_CREATE)
self._widgets.append(widget)
widget.connect("ready", self._on_album_ready)
widget.connect("song-activated", self._song_activated)
return widget
def _on_album_ready(self, artistalbumwidget):
self._nb_albums_loaded += 1
if self._nb_albums_loaded == self._model.get_n_items():
artistalbumwidget.disconnect_by_func(self._on_album_ready)
self._nb_albums_loaded = 0
self.emit("ready")
def _on_model_items_changed(self, model, position, removed, added):
for i in range(model.get_n_items()):
row = self.get_row_at_index(i)
......
......@@ -44,6 +44,7 @@ class ArtistAlbumWidget(Gtk.Box):
selection_mode = GObject.Property(type=bool, default=False)
__gsignals__ = {
"ready": (GObject.SignalFlags.RUN_FIRST, None, ()),
"song-activated": (
GObject.SignalFlags.RUN_FIRST, None, (SongWidget, )
),
......@@ -85,10 +86,12 @@ class ArtistAlbumWidget(Gtk.Box):
if self._cover_size_group:
self._cover_size_group.add_widget(self._cover_stack)
corealbum.props.model.connect_after(
self._nb_disc_box_loaded = 0
self._model = corealbum.props.model
self._model.props.model.connect_after(
"items-changed", self._on_model_items_changed)
self._disc_list_box.bind_model(
corealbum.props.model, self._create_widget)
self._model, self._create_widget)
def _create_widget(self, disc):
disc_box = self._create_disc_box(disc.props.disc_nr, disc.model)
......@@ -101,10 +104,18 @@ class ArtistAlbumWidget(Gtk.Box):
disc_box.props.show_durations = False
disc_box.props.show_favorites = False
disc_box.props.show_song_numbers = True
disc_box.connect("ready", self._on_discbox_ready)
disc_box.connect('song-activated', self._song_activated)
return disc_box
def _on_discbox_ready(self, klass):
self._nb_disc_box_loaded += 1
if self._nb_disc_box_loaded == self._model.get_n_items():
klass.disconnect_by_func(self._on_discbox_ready)
self._nb_disc_box_loaded = 0
self.emit("ready")
def _on_model_items_changed(self, model, position, removed, added):
n_items = model.get_n_items()
if n_items == 1:
......
......@@ -61,6 +61,7 @@ class DiscBox(Gtk.Box):
_list_box = Gtk.Template.Child()
__gsignals__ = {
"ready": (GObject.SignalFlags.RUN_FIRST, None, ()),
'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'song-activated': (GObject.SignalFlags.RUN_FIRST, None, (Gtk.Widget,))
}
......@@ -93,6 +94,8 @@ class DiscBox(Gtk.Box):
self._selected_items = []
self._songs = []
self._model.connect_after(
"items-changed", self._on_model_items_changed)
self._list_box.bind_model(self._model, self._create_widget)
@log
......@@ -141,6 +144,9 @@ class DiscBox(Gtk.Box):
return song_widget
def _on_model_items_changed(self, model, position, removed, added):
self.emit("ready")
@log
def _on_selection_changed(self, widget):
self.emit('selection-changed')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment