[gnome-music/wip/mschraal/default-icon-cleanups: 7/25] artistalbumswidget: Use Hdy.Clamp for content size




commit 4b004ad66375b98f16eb036513bc57f3a43a41b3
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Aug 25 01:15:59 2021 +0200

    artistalbumswidget: Use Hdy.Clamp for content size
    
    Related: #464

 data/ui/ArtistAlbumsWidget.ui            | 15 +++++++++++----
 gnomemusic/views/artistsview.py          |  4 ++--
 gnomemusic/widgets/artistalbumswidget.py | 12 +++++++-----
 3 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/ArtistAlbumsWidget.ui b/data/ui/ArtistAlbumsWidget.ui
index 77cf09926..6cc491c8d 100644
--- a/data/ui/ArtistAlbumsWidget.ui
+++ b/data/ui/ArtistAlbumsWidget.ui
@@ -1,10 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.18"/>
-  <template class="ArtistAlbumsWidget" parent="GtkListBox">
+  <template class="ArtistAlbumsWidget" parent="HdyClamp">
+    <property name="maximum-size">1000</property>
+    <property name="orientation">horizontal</property>
     <property name="visible">True</property>
-    <style>
-      <class name="artist-album-widget"/>
-    </style>
+    <child>
+      <object class="GtkListBox" id="_listbox">
+        <property name="visible">True</property>
+        <style>
+          <class name="artist-album-widget"/>
+        </style>
+      </object>
+    </child>
   </template>
 </interface>
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index dbef46b47..f3e1d0640 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -215,11 +215,11 @@ class ArtistsView(Gtk.Paned):
             self._selected_artist = None
 
     def select_all(self):
-        artist_albums = self._artist_view.get_visible_child()
+        artist_albums = self._artist_view.get_visible_child().get_child()
         for row in artist_albums:
             row.get_child().select_all()
 
     def deselect_all(self):
-        artist_albums = self._artist_view.get_visible_child()
+        artist_albums = self._artist_view.get_visible_child().get_child()
         for row in artist_albums:
             row.get_child().deselect_all()
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index eb6291a08..4f213157a 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -25,7 +25,7 @@
 from __future__ import annotations
 import typing
 
-from gi.repository import GObject, Gtk
+from gi.repository import GObject, Gtk, Handy
 
 from gnomemusic.widgets.albumwidget import AlbumWidget
 if typing.TYPE_CHECKING:
@@ -34,7 +34,7 @@ if typing.TYPE_CHECKING:
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/ArtistAlbumsWidget.ui")
-class ArtistAlbumsWidget(Gtk.ListBox):
+class ArtistAlbumsWidget(Handy.Clamp):
     """Widget containing all albums by an artist
 
     A vertical list of AlbumWidget, containing all the albums
@@ -44,6 +44,8 @@ class ArtistAlbumsWidget(Gtk.ListBox):
 
     __gtype_name__ = 'ArtistAlbumsWidget'
 
+    _listbox = Gtk.Template.Child()
+
     selection_mode = GObject.Property(type=bool, default=False)
 
     def __init__(
@@ -60,7 +62,7 @@ class ArtistAlbumsWidget(Gtk.ListBox):
         self._model = coreartist.props.model
         self._player = self._application.props.player
 
-        self.bind_model(self._model, self._add_album)
+        self._listbox.bind_model(self._model, self._add_album)
 
     def _add_album(self, corealbum):
         row = Gtk.ListBoxRow()
@@ -87,14 +89,14 @@ class ArtistAlbumsWidget(Gtk.ListBox):
         def toggle_selection(row: Gtk.ListBoxRow) -> None:
             row.get_child().select_all()
 
-        self.foreach(toggle_selection)
+        self._listbox.foreach(toggle_selection)
 
     def deselect_all(self) -> None:
         """Deselect all items"""
         def toggle_selection(row: Gtk.ListBoxRow) -> None:
             row.get_child().deselect_all()
 
-        self.foreach(toggle_selection)
+        self._listbox.foreach(toggle_selection)
 
     @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]