[gnome-music/wip/mschraal/core: 38/92] pass coremodel around and use it in albumwidget2



commit 9c5b29f7ad57afd798fed2b17352628ab0f7da87
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed May 8 20:49:19 2019 +0200

    pass coremodel around and use it in albumwidget2

 gnomemusic/application.py          | 2 +-
 gnomemusic/coremodel.py            | 4 ++++
 gnomemusic/widgets/albumwidget2.py | 9 +++++++++
 gnomemusic/window.py               | 3 +++
 4 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index 5d3eb0a7..4f647628 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -63,7 +63,7 @@ class Application(Gtk.Application):
         self._init_style()
         self._window = None
 
-        coremodel = CoreModel()
+        self._coremodel = CoreModel()
 
         self._settings = Gio.Settings.new('org.gnome.Music')
         self._player = Player(self)
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 95c46a00..75345b81 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -14,3 +14,7 @@ class CoreModel(GObject.GObject):
         self._hash = {}
 
         self._grilo = CoreGrilo(self._model, self._hash)
+
+    @log
+    def get_model(self):
+        return self._model
diff --git a/gnomemusic/widgets/albumwidget2.py b/gnomemusic/widgets/albumwidget2.py
index 4d7762cc..640ec8ee 100644
--- a/gnomemusic/widgets/albumwidget2.py
+++ b/gnomemusic/widgets/albumwidget2.py
@@ -115,6 +115,15 @@ class AlbumWidget2(Gtk.EventBox):
         # self._player.connect('song-changed', self._update_model)
 
         # grilo.populate_album_songs(album, self.add_item)
+        self._listbox.bind_model(
+            self._parent_view._window._app._coremodel.get_model(),
+            self._create_widget)
+
+    @log
+    def _create_widget(self, song):
+        song_widget = SongWidget(song._media)
+
+        return song_widget
 
     @log
     def _set_composer_label(self, album):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 7b7141dc..773c6921 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -79,6 +79,9 @@ class Window(Gtk.ApplicationWindow):
         """
         super().__init__(application=app, title=_("Music"))
 
+        # Hack
+        self._app = app
+
         self._settings = app.props.settings
         self.add_action(self._settings.create_action('repeat'))
         select_all = Gio.SimpleAction.new('select_all', None)


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