[gnome-music/wip/mschraal/albumsview-selection-rework: 3/8] searchview: Route selections via coreobjects




commit 1779ab898e75586a9b411112fe11c0854c603b45
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Sep 11 12:11:57 2021 +0200

    searchview: Route selections via coreobjects
    
    Selection changes were triggered through the widgets. However,
    this is rather the long way around if you want to actually select
    the coreobjects. Also, in GTK4 it is frowned upon cycling through
    widgets to obtain their properties.
    
    Trigger selection changes directly through the coreobjects.

 gnomemusic/views/searchview.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index bea60950d..4083f49b2 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -443,24 +443,23 @@ class SearchView(Gtk.Stack):
         self.props.visible_child = self._all_search_results
         self.props.search_mode_active = False
 
-    def _select_all(self, value):
-        def child_select(child):
-            child.props.selected = value
-
+    def _select_all(self, value: bool) -> None:
         if self.props.state == SearchView.State.MAIN:
             with self._model.freeze_notify():
-                def song_select(child):
-                    child.props.coresong.props.selected = value
-
-                self._songs_listbox.foreach(song_select)
-                self._album_flowbox.foreach(child_select)
-                self._artist_flowbox.foreach(child_select)
+                for coresong in self._model:
+                    coresong.props.selected = value
+                for corealbum in self._album_model:
+                    corealbum.props.selected = value
+                for coreartist in self._artist_model:
+                    coreartist.props.selected = value
         elif self.props.state == SearchView.State.ALL_ALBUMS:
             with self._model.freeze_notify():
-                self._album_all_flowbox.foreach(child_select)
+                for corealbum in self._album_model:
+                    corealbum.props.selected = value
         elif self.props.state == SearchView.State.ALL_ARTISTS:
             with self._model.freeze_notify():
-                self._artist_all_flowbox.foreach(child_select)
+                for corealbum in self._album_model:
+                    corealbum.props.selected = value
         elif self.props.state == SearchView.State.ALBUM:
             view = self._album_widget
             if value is True:


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