[gnome-music/wip/jfelder/new-artist-design: 3/6] albumwidget: Add optional size groups




commit 28872aea0c12c7a9a3104753e873da45b5032e4a
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Jul 30 18:39:40 2021 +0200

    albumwidget: Add optional size groups
    
    This allows to have similar sizes for the album cover and the list of
    songs when various AlbumWidget are inserted in the same view.
    This will be used by ArtistAlbumsWidget in a future commit.

 gnomemusic/widgets/albumwidget.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 811915070..5794b36e0 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -62,10 +62,15 @@ class AlbumWidget(Gtk.Box):
     selection_mode = GObject.Property(type=bool, default=False)
     show_artist_label = GObject.Property(type=bool, default=True)
 
-    def __init__(self, application: Application) -> None:
+    def __init__(
+            self, application: Application,
+            size_group: Optional[Gtk.SizeGroup] = None,
+            cover_size_group: Optional[Gtk.SizeGroup] = None) -> None:
         """Initialize the AlbumWidget.
 
         :param GtkApplication application: The application object
+        :param GtkSizeGroup size_group: SizeGroup for the discs
+        :param GtkSizeGroup cover_size_group: SizeGroup for the cover
         """
         super().__init__()
 
@@ -74,6 +79,9 @@ class AlbumWidget(Gtk.Box):
         self._coremodel = self._application.props.coremodel
         self._model_signal_id = 0
 
+        self._size_group = size_group
+        self._cover_size_group = cover_size_group
+
         self._art_stack.props.size = ArtSize.LARGE
         self._player = self._application.props.player
 
@@ -101,6 +109,12 @@ class AlbumWidget(Gtk.Box):
 
         self.insert_action_group("album", action_group)
 
+        if self._size_group:
+            self._size_group.add_widget(self._disc_list_box)
+
+        if self._cover_size_group:
+            self._cover_size_group.add_widget(self._art_stack)
+
     def update(self, corealbum: CoreAlbum) -> None:
         """Update the album widget.
 


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