[gnome-music/wip/mschraal/window-template: 8/13] albumwidget: Move property bindings around



commit b689216322879486d3e2989ecc419311449432f0
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue May 14 22:34:44 2019 +0200

    albumwidget: Move property bindings around
    
    Move "selection-mode" and "selected-items-count"  property bindings to the
    widget creator. This removes an argument from the init call.
    Also remove "selection-mode" SYNC_CREATE flag, so it no longer triggers
    updates on widget creation. This made little sense as AlbumWidget is never
    created while in selection mode.

 gnomemusic/views/albumsview.py    |  9 ++++++++-
 gnomemusic/views/searchview.py    |  9 ++++++++-
 gnomemusic/widgets/albumwidget.py | 12 +-----------
 3 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index fdee5c68..a3ae5712 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -46,7 +46,14 @@ class AlbumsView(BaseView):
         super().__init__('albums', _("Albums"), window)
 
         self.player = player
-        self._album_widget = AlbumWidget(player, self)
+
+        self._album_widget = AlbumWidget(player)
+        self._album_widget.bind_property(
+            'selection-mode', self, 'selection-mode',
+            GObject.BindingFlags.BIDIRECTIONAL)
+        self._album_widget.bind_property(
+            'selected-items-count', self, 'selected-items-count')
+
         self.add(self._album_widget)
         self.albums_selected = []
         self.all_items = []
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 6cca22e1..1040f964 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -65,7 +65,14 @@ class SearchView(BaseView):
         self._albums_selected = []
         self._albums = {}
         self._albums_index = 0
-        self._album_widget = AlbumWidget(player, self)
+
+        self._album_widget = AlbumWidget(player)
+        self._album_widget.bind_property(
+            'selection-mode', self, 'selection-mode',
+            GObject.BindingFlags.BIDIRECTIONAL)
+        self._album_widget.bind_property(
+            'selected-items-count', self, 'selected-items-count')
+
         self.add(self._album_widget)
 
         self._artists_albums_selected = []
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index f380ad2e..f0abbefc 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -63,11 +63,10 @@ class AlbumWidget(Gtk.EventBox):
         return '<AlbumWidget>'
 
     @log
-    def __init__(self, player, parent_view):
+    def __init__(self, player):
         """Initialize the AlbumWidget.
 
         :param player: The player object
-        :param parent_view: The view this widget is part of
         """
         super().__init__()
 
@@ -75,7 +74,6 @@ class AlbumWidget(Gtk.EventBox):
         self._songs = []
 
         self._cover_stack.props.size = Art.Size.LARGE
-        self._parent_view = parent_view
         self._player = player
         self._iter_to_clean = None
 
@@ -86,14 +84,6 @@ class AlbumWidget(Gtk.EventBox):
             'selection-mode', self._disc_listbox, 'selection-mode',
             GObject.BindingFlags.BIDIRECTIONAL)
 
-        self.bind_property(
-            'selection-mode', self._parent_view, 'selection-mode',
-            GObject.BindingFlags.BIDIRECTIONAL
-            | GObject.BindingFlags.SYNC_CREATE)
-
-        self.bind_property(
-            'selected-items-count', self._parent_view, 'selected-items-count')
-
     @log
     def _create_model(self):
         """Create the ListStore model for this widget."""


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