[gnome-music/wip/mschraal/core: 149/190] searchview: Show songs list



commit 4297952350ae0a786c8c5a3af614577a440c3947
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 30 23:17:16 2019 +0200

    searchview: Show songs list

 gnomemusic/coremodel.py        |  1 +
 gnomemusic/views/searchview.py | 39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 868d8a33..ff55956d 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -55,6 +55,7 @@ class CoreModel(GObject.GObject):
         self._playlist_model_sort = Gfm.SortListModel.new(self._playlist_model)
 
         self._song_search_model = Dazzle.ListModelFilter.new(self._model)
+        self._song_search_model.set_filter_func(lambda a: False)
 
         print("PLAYLIST_MODEL", self._playlist_model)
         self._grilo = CoreGrilo(
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index f2699fd2..340e9fbd 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -37,6 +37,7 @@ from gnomemusic.search import Search
 from gnomemusic.views.baseview import BaseView
 from gnomemusic.widgets.headerbar import HeaderBar
 from gnomemusic.widgets.artistalbumswidget import ArtistAlbumsWidget
+from gnomemusic.widgets.songwidget import SongWidget
 import gnomemusic.utils as utils
 
 
@@ -49,6 +50,7 @@ class SearchView(BaseView):
 
     @log
     def __init__(self, window, player):
+        self._coremodel = window._app._coremodel
         super().__init__('search', None, window)
 
         # self._add_list_renderers()
@@ -84,12 +86,18 @@ class SearchView(BaseView):
         self._search_mode_active = False
         # self.connect("notify::search-state", self._on_search_state_changed)
 
+        self._view.show_all()
+
     @log
     def _setup_view(self):
         view_container = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
         self._box.pack_start(view_container, True, True, 0)
 
-        self._view = Gtk.Box()
+        self._view = Gtk.ListBox()
+
+        self._view.bind_model(
+            self._coremodel.get_songs_search_model(), self._create_song_widget)
+
         # self._view = Gtk.TreeView(
         #     activate_on_single_click=True, can_focus=False,
         #     halign=Gtk.Align.CENTER, headers_visible=False,
@@ -103,7 +111,34 @@ class SearchView(BaseView):
         # self._ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
         # self._ctrl.connect("released", self._on_view_clicked)
 
-        # view_container.add(self._view)
+        view_container.add(self._view)
+
+    def _create_song_widget(self, coresong):
+        song_widget = SongWidget(coresong.props.media)
+
+        coresong.bind_property(
+            "favorite", song_widget, "favorite",
+            GObject.BindingFlags.BIDIRECTIONAL
+            | GObject.BindingFlags.SYNC_CREATE)
+        coresong.bind_property(
+            "selected", song_widget, "selected",
+            GObject.BindingFlags.BIDIRECTIONAL
+            | GObject.BindingFlags.SYNC_CREATE)
+        coresong.bind_property(
+            "state", song_widget, "state",
+            GObject.BindingFlags.BIDIRECTIONAL
+            | GObject.BindingFlags.SYNC_CREATE)
+
+        self.bind_property(
+            "selection-mode", song_widget, "selection-mode",
+            GObject.BindingFlags.BIDIRECTIONAL
+            | GObject.BindingFlags.SYNC_CREATE)
+
+        # song_widget.connect('button-release-event', self._song_activated)
+
+        song_widget.show_all()
+
+        return song_widget
 
     @log
     def _back_button_clicked(self, widget, data=None):


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