[gnome-music/wip/mschraal/albumwidget-corealbum-property: 1/2] albumwidget: Make corealbum a RW property




commit 6b63704e307499aab6b438117dc1693d12d70eae
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Aug 4 16:30:09 2021 +0200

    albumwidget: Make corealbum a RW property
    
    Making corealbum a writeable property replaces the update function.

 gnomemusic/views/albumsview.py    |  4 ++--
 gnomemusic/views/searchview.py    |  2 +-
 gnomemusic/widgets/albumwidget.py | 27 ++++++++++++++-------------
 3 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 533e35947..36ec7f8b5 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -163,7 +163,7 @@ class AlbumsView(Gtk.Stack):
         if (not self.props.search_mode_active
                 and self._headerbar.props.stack.props.visible_child == self
                 and self.get_visible_child() == self._album_widget):
-            self._set_album_headerbar(self._album_widget.props.album)
+            self._set_album_headerbar(self._album_widget.props.corealbum)
 
     def _create_widget(self, corealbum):
         album_widget = AlbumCover(corealbum)
@@ -197,7 +197,7 @@ class AlbumsView(Gtk.Stack):
             return
 
         # Update and display the album widget if not in selection mode
-        self._album_widget.update(corealbum)
+        self._album_widget.props.corealbum = corealbum
 
         self._set_album_headerbar(corealbum)
         self.set_visible_child(self._album_widget)
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 6dc50a325..f4ec3a575 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -352,7 +352,7 @@ class SearchView(Gtk.Stack):
             return
 
         # Update and display the album widget if not in selection mode
-        self._album_widget.update(corealbum)
+        self._album_widget.props.corealbum = corealbum
 
         self.props.state = SearchView.State.ALBUM
         self._headerbar.props.state = HeaderBar.State.SEARCH
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 60e5ba15b..e1f9825bd 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -78,10 +78,21 @@ class AlbumWidget(Gtk.Box):
 
         self.connect("notify::selection-mode", self._on_selection_mode_changed)
 
-    def update(self, corealbum):
-        """Update the album widget.
+    @GObject.Property(
+        type=CoreAlbum, default=None, flags=GObject.ParamFlags.READWRITE)
+    def corealbum(self):
+        """Get the current CoreAlbum.
+
+        :returns: The current CoreAlbum
+        :rtype: CoreAlbum
+        """
+        return self._corealbum
+
+    @corealbum.setter  # type:ignore
+    def corealbum(self, corealbum):
+        """Update CoreAlbum used for AlbumWidget.
 
-        :param CoreAlbum album: The CoreAlbum object
+        :param CoreAlbum corealbum: The CoreAlbum object
         """
         if self._corealbum:
             self._corealbum.disconnect(self._duration_signal_id)
@@ -180,13 +191,3 @@ class AlbumWidget(Gtk.Box):
     def _on_selection_mode_changed(self, widget, value):
         if not self.props.selection_mode:
             self.deselect_all()
-
-    @GObject.Property(
-        type=CoreAlbum, default=None, flags=GObject.ParamFlags.READABLE)
-    def album(self):
-        """Get the current album.
-
-        :returns: the current album
-        :rtype: CoreAlbum
-        """
-        return self._corealbum


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