[gnome-music/wip/mschraal/widget-assorted-fixes: 2/3] artistalbumswidget: Remove internal variable



commit afabc5b85723f977594aaa1f2be8f196fcd93702
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Feb 18 13:51:40 2020 +0100

    artistalbumswidget: Remove internal variable
    
    A variable was used to hold all widgets for selection purposes. This
    would not have worked with a changing model and is unneeded anyway as
    the ListBox already holds all widgets.
    
    Use the ListBox widgets directly instead.

 gnomemusic/widgets/artistalbumswidget.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index 158d9d9b..42bb42ed 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -50,8 +50,6 @@ class ArtistAlbumsWidget(Gtk.ListBox):
         self._player = self._application.props.player
         self._selection_mode_allowed = selection_mode_allowed
 
-        self._widgets = []
-
         self._cover_size_group = Gtk.SizeGroup.new(
             Gtk.SizeGroupMode.HORIZONTAL)
         self._songs_grid_size_group = Gtk.SizeGroup.new(
@@ -92,20 +90,23 @@ class ArtistAlbumsWidget(Gtk.ListBox):
             | GObject.BindingFlags.SYNC_CREATE)
 
         row.add(widget)
-        self._widgets.append(widget)
         widget.connect("song-activated", self._song_activated)
 
         return row
 
     def select_all(self):
         """Select all items"""
-        for widget in self._widgets:
-            widget.select_all()
+        def toggle_selection(row):
+            row.get_child().select_all()
+
+        self.foreach(toggle_selection)
 
     def deselect_all(self):
         """Deselect all items"""
-        for widget in self._widgets:
-            widget.deselect_all()
+        def toggle_selection(row):
+            row.get_child().deselect_all()
+
+        self.foreach(toggle_selection)
 
     @GObject.Property(type=str, flags=GObject.ParamFlags.READABLE)
     def artist(self):


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