[gnome-music/wip/mschraal/albumsview-selection-rework: 15/21] artistalbumswidget: Route selections via coreobjects
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/albumsview-selection-rework: 15/21] artistalbumswidget: Route selections via coreobjects
- Date: Wed, 2 Feb 2022 10:50:48 +0000 (UTC)
commit 8a0035299c6fc6cba930c27125814600f2231dc3
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Sep 11 02:23:57 2021 +0200
artistalbumswidget: 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/widgets/artistalbumswidget.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index 4f213157a..1f494ae06 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -75,6 +75,9 @@ class ArtistAlbumsWidget(Handy.Clamp):
widget.props.active_coreobject = self._artist
widget.props.show_artist_label = False
+ self._artist.bind_property(
+ "selected", corealbum, "selected",
+ GObject.BindingFlags.SYNC_CREATE)
self.bind_property(
'selection-mode', widget, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL
@@ -86,17 +89,13 @@ class ArtistAlbumsWidget(Handy.Clamp):
def select_all(self) -> None:
"""Select all items"""
- def toggle_selection(row: Gtk.ListBoxRow) -> None:
- row.get_child().select_all()
-
- self._listbox.foreach(toggle_selection)
+ for corealbum in self._model:
+ corealbum.props.selected = True
def deselect_all(self) -> None:
"""Deselect all items"""
- def toggle_selection(row: Gtk.ListBoxRow) -> None:
- row.get_child().deselect_all()
-
- self._listbox.foreach(toggle_selection)
+ for corealbum in self._model:
+ corealbum.props.selected = False
@GObject.Property(type=str, flags=GObject.ParamFlags.READABLE)
def artist(self) -> str:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]