[gnome-music/wip/mschraal/widget-assorted-fixes: 4/5] artistalbumswidget: Remove internal list
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/widget-assorted-fixes: 4/5] artistalbumswidget: Remove internal list
- Date: Thu, 20 Feb 2020 20:16:30 +0000 (UTC)
commit 53dc742e1a0beb87f110db00a9db03a5e2dac722
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Feb 18 13:51:40 2020 +0100
artistalbumswidget: Remove internal list
A list was used to hold all widgets for selection purposes. This is
unneeded as the ListBox already holds all widget references, also
this would not have worked properly with a changing model.
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]