[gnome-music/wip/mschraal/core: 40/118] artistalbumwidget: Somewhat working albums view (only in search)



commit a1a55c5d09b0453d65dab1b392a2ba0dda96adc3
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri May 31 16:21:10 2019 +0200

    artistalbumwidget: Somewhat working albums view (only in search)

 gnomemusic/widgets/artistalbumswidget.py |  3 ++-
 gnomemusic/widgets/artistalbumwidget.py  | 13 +++++++++----
 gnomemusic/widgets/disclistboxwidget.py  | 16 ++++++++++++++--
 3 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index aa132db7..0c74e4a2 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -94,6 +94,7 @@ class ArtistAlbumsWidget(Gtk.Box):
             self._add_album(album)
 
         self._player.connect('song-changed', self._update_model)
+        self.show_all()
 
     @log
     def _create_model(self):
@@ -124,7 +125,7 @@ class ArtistAlbumsWidget(Gtk.Box):
     def _add_album(self, album):
         widget = ArtistAlbumWidget(
             album, self._player, self._model, self._selection_mode_allowed,
-            self._songs_grid_size_group, self._cover_size_group)
+            self._songs_grid_size_group, self._cover_size_group, self._window)
 
         self.bind_property(
             'selection-mode', widget, 'selection-mode',
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 8d8fda88..980889f9 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -55,7 +55,7 @@ class ArtistAlbumWidget(Gtk.Box):
     @log
     def __init__(
             self, media, player, model, selection_mode_allowed,
-            size_group=None, cover_size_group=None):
+            size_group=None, cover_size_group=None, window=None):
         super().__init__(orientation=Gtk.Orientation.HORIZONTAL)
 
         self._size_group = size_group
@@ -94,12 +94,17 @@ class ArtistAlbumWidget(Gtk.Box):
         if self._cover_size_group:
             self._cover_size_group.add_widget(self._cover_stack)
 
-        grilo.populate_album_songs(self._media, self._add_item)
+        self._listmodel = window._app._coremodel.get_album_model(self._media)
+
+        disc = self._create_disc_box(0, None)
+        self._disc_list_box.add(disc)
+        self._disc_list_box.show()
+        # grilo.populate_album_songs(self._media, self._add_item)
 
     @log
     def _create_disc_box(self, disc_nr, disc_songs):
-        disc_box = DiscBox(self._model)
-        disc_box.set_songs(disc_songs)
+        disc_box = DiscBox(None, self._listmodel)
+        # disc_box.set_songs(disc_songs)
         disc_box.set_disc_number(disc_nr)
         disc_box.props.columns = 2
         disc_box.props.show_durations = False
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 3faa32c7..457da0e2 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -111,7 +111,7 @@ class DiscBox(Gtk.Box):
         return '<DiscBox>'
 
     @log
-    def __init__(self, model=None):
+    def __init__(self, model=None, listmodel=None):
         """Initialize
 
         :param model: The TreeStore to use
@@ -119,7 +119,13 @@ class DiscBox(Gtk.Box):
         super().__init__()
 
         self._model = model
-        self._model.connect('row-changed', self._model_row_changed)
+        if self._model is not None:
+            self._model.connect('row-changed', self._model_row_changed)
+
+        if listmodel is not None:
+            self._listmodel = listmodel
+            self._disc_songs_flowbox.bind_model(
+                self._listmodel, self._create_widget)
 
         self.bind_property(
             'columns', self._disc_songs_flowbox, 'columns',
@@ -193,6 +199,12 @@ class DiscBox(Gtk.Box):
 
         self._disc_songs_flowbox.foreach(child_select_none)
 
+    def _create_widget(self, song):
+        song_widget = SongWidget(song.props.media)
+        self._songs.append(song_widget)
+
+        return song_widget
+
     @log
     def _create_song_widget(self, song):
         """Helper function to create a song widget for a


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]