[gnome-music/wip/jfelder/new-artist-design: 1/6] albumwidget: Do not include a ScrolledWindow




commit 696f8c05a9caf67403515e99d70520da132a7479
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Jul 30 18:08:11 2021 +0200

    albumwidget: Do not include a ScrolledWindow
    
    With the latest mockups, the AlbumWidget and the ArtistAlbumWidget
    become very similar. Therefore, it becomes possible to use AlbumWidget
    inside the ArtistsView. However, in the artists case, the AlbumWidget
    cannot include a ScrolledWindow because the scrollbar from the
    ArtistsView is already used.
    
    This issue is fixed by removed the ScrolledWindow from the
    AlbumWidget. A ScrolledWindow is inserted into the AlbumsView to
    handle the album case.

 data/ui/AlbumWidget.ui            | 240 +++++++++++++++++---------------------
 data/ui/AlbumsView.ui             |  12 ++
 gnomemusic/views/albumsview.py    |   5 +-
 gnomemusic/widgets/albumwidget.py |   2 +-
 4 files changed, 126 insertions(+), 133 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 52a5ec8e9..563386e8b 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -2,161 +2,141 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
-  <template class="AlbumWidget" parent="GtkScrolledWindow">
+  <template class="AlbumWidget" parent="GtkBox">
+    <property name="orientation">vertical</property>
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="hexpand">True</property>
-    <property name="vexpand">True</property>
-    <property name="hscrollbar_policy">never</property>
-    <style>
-      <class name="view"/>
-    </style>
+    <property name="margin-bottom">48</property>
+    <property name="margin-end">160</property>
+    <property name="margin-start">160</property>
+    <property name="margin-top">48</property>
     <child>
-      <object class="GtkViewport" id="_viewport">
+      <object class="GtkBox" id="albumInfo">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="halign">fill</property>
         <property name="hexpand">True</property>
+        <property name="spacing">32</property>
         <child>
-          <object class="GtkBox">
-            <property name="orientation">vertical</property>
+          <object class="ArtStack" id="_art_stack">
             <property name="visible">True</property>
-            <property name="margin-bottom">48</property>
-            <property name="margin-end">160</property>
-            <property name="margin-start">160</property>
-            <property name="margin-top">48</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">start</property>
+            <property name="margin-end">1</property>
+            <property name="margin-start">1</property>
+            <property name="hhomogeneous">False</property>
+            <property name="vhomogeneous">False</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="albumDetails">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">start</property>
+            <property name="orientation">vertical</property>
+            <property name="margin-top">18</property>
+            <child>
+              <object class="GtkLabel" id="_title_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="ellipsize">middle</property>
+                <property name="margin-bottom">18</property>
+                <style>
+                  <class name="title-album"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="_artist_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="ellipsize">middle</property>
+                <property name="margin-bottom">12</property>
+                <style>
+                  <class name="title-artist"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="_released_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="use_markup">True</property>
+                <property name="margin-bottom">12</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
             <child>
-              <object class="GtkBox" id="albumInfo">
+              <object class="GtkLabel" id="_composer_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">fill</property>
-                <property name="hexpand">True</property>
-                <property name="spacing">32</property>
+                <property name="halign">start</property>
+                <property name="ellipsize">end</property>
+                <property name="margin-bottom">12</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="orientation">horizontal</property>
+                <property name="visible">True</property>
+                <property name="spacing">12</property>
+                <property name="margin-top">6</property>
                 <child>
-                  <object class="ArtStack" id="_art_stack">
+                  <object class="GtkButton" id="_play_button">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="halign">center</property>
-                    <property name="valign">start</property>
-                    <property name="margin-end">1</property>
-                    <property name="margin-start">1</property>
-                    <property name="hhomogeneous">False</property>
-                    <property name="vhomogeneous">False</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <property name="image">_play_image</property>
+                    <property name="always_show_image">True</property>
+                    <property name="tooltip-text" translatable="yes">Play</property>
+                    <property name="valign">center</property>
+                    <signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
+                    <style>
+                      <class name="circular"/>
+                    </style>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkBox" id="albumDetails">
+                  <object class="GtkMenuButton" id="_menu_button">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="halign">center</property>
-                    <property name="valign">start</property>
-                    <property name="orientation">vertical</property>
-                    <property name="margin-top">18</property>
-                    <child>
-                      <object class="GtkLabel" id="_title_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="ellipsize">middle</property>
-                        <property name="margin-bottom">18</property>
-                        <style>
-                          <class name="title-album"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="_artist_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="ellipsize">middle</property>
-                        <property name="margin-bottom">12</property>
-                        <style>
-                          <class name="title-artist"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="_released_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="use_markup">True</property>
-                        <property name="margin-bottom">12</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="_composer_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="ellipsize">end</property>
-                        <property name="margin-bottom">12</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="orientation">horizontal</property>
-                        <property name="visible">True</property>
-                        <property name="spacing">12</property>
-                        <property name="margin-top">6</property>
-                        <child>
-                          <object class="GtkButton" id="_play_button">
-                            <property name="visible">True</property>
-                            <property name="can-focus">True</property>
-                            <property name="receives-default">True</property>
-                            <property name="image">_play_image</property>
-                            <property name="always_show_image">True</property>
-                            <property name="tooltip-text" translatable="yes">Play</property>
-                            <property name="valign">center</property>
-                            <signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
-                            <style>
-                              <class name="circular"/>
-                            </style>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkMenuButton" id="_menu_button">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="halign">start</property>
-                            <property name="valign">center</property>
-                            <property name="focus_on_click">False</property>
-                            <property name="menu-model">albumMenu</property>
-                            <property name="direction">none</property>
-                            <property name="use_popover">True</property>
-                            <property name="image">_view_more_image</property>
-                            <style>
-                              <class name="image-button"/>
-                              <class name="circular"/>
-                            </style>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="halign">start</property>
+                    <property name="valign">center</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="menu-model">albumMenu</property>
+                    <property name="direction">none</property>
+                    <property name="use_popover">True</property>
+                    <property name="image">_view_more_image</property>
+                    <style>
+                      <class name="image-button"/>
+                      <class name="circular"/>
+                    </style>
                   </object>
                 </child>
               </object>
             </child>
-            <child>
-              <object class="DiscListBox" id="_disc_list_box">
-                <property name="can_focus">False</property>
-                <property name="margin-top">48</property>
-                <property name="selection_mode">0</property>
-                <property name="visible">True</property>
-              </object>
-            </child>
           </object>
         </child>
       </object>
     </child>
+    <child>
+      <object class="DiscListBox" id="_disc_list_box">
+        <property name="can_focus">False</property>
+        <property name="margin-top">48</property>
+        <property name="selection_mode">0</property>
+        <property name="visible">True</property>
+      </object>
+    </child>
   </template>
   <object class="GtkImage" id="_view_more_image">
     <property name="visible">True</property>
diff --git a/data/ui/AlbumsView.ui b/data/ui/AlbumsView.ui
index 78ad992e6..abd686fa7 100644
--- a/data/ui/AlbumsView.ui
+++ b/data/ui/AlbumsView.ui
@@ -30,6 +30,18 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="GtkScrolledWindow" id="_album_scrolled_window">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="hscrollbar_policy">never</property>
+        <style>
+          <class name="view"/>
+        </style>
+      </object>
+    </child>
   </template>
   <object class="GtkGestureLongPress" id="_flowbox_long_press">
     <property name="propagation-phase">capture</property>
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 533e35947..e95e0f72a 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -49,6 +49,7 @@ class AlbumsView(Gtk.Stack):
     title = GObject.Property(
         type=str, default=_("Albums"), flags=GObject.ParamFlags.READABLE)
 
+    _album_scrolled_window = Gtk.Template.Child()
     _scrolled_window = Gtk.Template.Child()
     _flowbox = Gtk.Template.Child()
     _flowbox_long_press = Gtk.Template.Child()
@@ -88,7 +89,7 @@ class AlbumsView(Gtk.Stack):
             "selection-mode", self, "selection-mode",
             GObject.BindingFlags.BIDIRECTIONAL)
 
-        self.add(self._album_widget)
+        self._album_scrolled_window.add(self._album_widget)
 
         self.connect(
             "notify::search-mode-active", self._on_search_mode_changed)
@@ -200,7 +201,7 @@ class AlbumsView(Gtk.Stack):
         self._album_widget.update(corealbum)
 
         self._set_album_headerbar(corealbum)
-        self.set_visible_child(self._album_widget)
+        self.set_visible_child(self._album_scrolled_window)
 
     def _set_album_headerbar(self, corealbum):
         self._headerbar.props.state = HeaderBar.State.CHILD
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 1a88c47c0..0d3ac7a60 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -41,7 +41,7 @@ if typing.TYPE_CHECKING:
 
 
 @Gtk.Template(resource_path='/org/gnome/Music/ui/AlbumWidget.ui')
-class AlbumWidget(Gtk.ScrolledWindow):
+class AlbumWidget(Gtk.Box):
     """Album widget.
 
     The album widget consists of an image with the album art


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