[gnome-music/wip/mschraal/artistsview-selection-through-coreobjects: 2/3] artistsview: Route selections via coreobjects




commit b8931bb26c9e4e78ce816ff026ca3494bb1490a8
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Feb 2 23:11:53 2022 +0100

    artistsview: 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/artistsview.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index ecbb0b754..ec48cd31b 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -194,12 +194,14 @@ class ArtistsView(Gtk.Paned):
         if not self._selection_mode:
             self.deselect_all()
 
-    def select_all(self):
-        artist_albums = self._artist_view.get_visible_child().get_child()
-        for row in artist_albums:
-            row.get_child().select_all()
-
-    def deselect_all(self):
-        artist_albums = self._artist_view.get_visible_child().get_child()
-        for row in artist_albums:
-            row.get_child().deselect_all()
+    def select_all(self) -> None:
+        """Select all items"""
+        artist_tile = self._sidebar.get_selected_row()
+        if artist_tile:
+            artist_tile.props.coreartist.props.selected = True
+
+    def deselect_all(self) -> None:
+        """Deselect all items"""
+        artist_tile = self._sidebar.get_selected_row()
+        if artist_tile:
+            artist_tile.props.coreartist.props.selected = False


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