[gnome-music/wip/jfelder/gtk4-v3: 86/108] albumsview: Connect checkbox with listmodel selection




commit 2a6ba002af87d924b216f0cf87c62d124c1d04c5
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Feb 9 09:33:24 2022 +0100

    albumsview: Connect checkbox with listmodel selection
    
    This correctly changes the GtkListItem selected state.

 gnomemusic/views/albumsview.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 2df7e8d46..770dd62b6 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -213,3 +213,13 @@ class AlbumsView(Gtk.Stack):
             "active", listitem.props.item, "selected",
             GObject.BindingFlags.SYNC_CREATE
                 | GObject.BindingFlags.BIDIRECTIONAL)
+
+        def on_activated(widget, value):
+            if check.props.active:
+                self._selection_model.select_item(
+                    listitem.get_position(), False)
+            else:
+                self._selection_model.unselect_item(
+                    listitem.get_position())
+
+        check.connect("notify::active", on_activated)


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