[gnome-music/wip/mschraal/gtk4-pre-squash-backup: 211/254] searchview: Ensure that results are scrollable




commit a832caacb393ca63673afd1ef071ec9b67140703
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Feb 11 17:03:35 2022 +0100

    searchview: Ensure that results are scrollable

 data/ui/SearchView.ui          | 303 +++++++++++++++++++++--------------------
 gnomemusic/views/searchview.py |   3 +-
 2 files changed, 161 insertions(+), 145 deletions(-)
---
diff --git a/data/ui/SearchView.ui b/data/ui/SearchView.ui
index cf0ce2fe0..8baa75fd0 100644
--- a/data/ui/SearchView.ui
+++ b/data/ui/SearchView.ui
@@ -6,134 +6,139 @@
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
         <child>
-          <object class="AdwClamp">
-            <property name="maximum-size">1600</property>
+          <object class="GtkViewport">
+            <property name="scroll-to-focus">True</property>
             <child>
-              <object class="GtkBox" id="container">
-                <property name="halign">fill</property>
-                <property name="hexpand">True</property>
-                <property name="margin-bottom">20</property>
-                <property name="margin-end">120</property>
-                <property name="margin-start">120</property>
-                <property name="margin-top">20</property>
-                <property name="orientation">vertical</property>
+              <object class="AdwClamp">
+                <property name="maximum-size">1600</property>
                 <child>
-                  <object class="GtkBox" id="_artist_header">
+                  <object class="GtkBox" id="container">
                     <property name="halign">fill</property>
                     <property name="hexpand">True</property>
-                    <property name="homogeneous">True</property>
-                    <property name="orientation">horizontal</property>
+                    <property name="margin-bottom">20</property>
+                    <property name="margin-end">120</property>
+                    <property name="margin-start">120</property>
+                    <property name="margin-top">20</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="GtkBox" id="_artist_header">
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="orientation">horizontal</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="focusable">False</property>
+                            <property name="halign">start</property>
+                            <property name="label" translatable="yes">Artists</property>
+                            <style>
+                              <class name="search-header"/>
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="_view_all_artists">
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">View All</property>
+                            <property name="icon-name">go-next-symbolic</property>
+                            <signal name="clicked" handler="_on_all_artists_clicked" swapped="no"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                     <child>
-                      <object class="GtkLabel">
-                        <property name="focusable">False</property>
-                        <property name="halign">start</property>
-                        <property name="label" translatable="yes">Artists</property>
+                      <object class="GtkFlowBox" id="_artist_flowbox">
+                        <property name="column_spacing">6</property>
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="margin-bottom">18</property>
+                        <property name="margin-top">18</property>
+                        <property name="max-children-per-line">6</property>
+                        <property name="min-children-per-line">1</property>
+                        <property name="row_spacing">12</property>
+                        <property name="selection-mode">none</property>
+                        <property name="valign">start</property>
+                        <signal name="child-activated" handler="_on_artist_activated" swapped="no"/>
                         <style>
-                          <class name="search-header"/>
+                          <class name="content-view"/>
                         </style>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkButton" id="_view_all_artists">
-                        <property name="halign">end</property>
-                        <property name="label" translatable="yes">View All</property>
-                        <property name="icon-name">go-next-symbolic</property>
-                        <signal name="clicked" handler="_on_all_artists_clicked" swapped="no"/>
+                      <object class="GtkBox" id="_album_header">
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="orientation">horizontal</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="focusable">False</property>
+                            <property name="halign">start</property>
+                            <property name="label" translatable="yes">Albums</property>
+                            <style>
+                              <class name="search-header"/>
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="_view_all_albums">
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">View All</property>
+                            <property name="icon_name">go-next-symbolic</property>
+                            <signal name="clicked" handler="_on_all_albums_clicked" swapped="no"/>
+                          </object>
+                        </child>
                       </object>
                     </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFlowBox" id="_artist_flowbox">
-                    <property name="column_spacing">6</property>
-                    <property name="halign">fill</property>
-                    <property name="hexpand">True</property>
-                    <property name="homogeneous">True</property>
-                    <property name="margin-bottom">18</property>
-                    <property name="margin-top">18</property>
-                    <property name="max-children-per-line">6</property>
-                    <property name="min-children-per-line">1</property>
-                    <property name="row_spacing">12</property>
-                    <property name="selection-mode">none</property>
-                    <property name="valign">start</property>
-                    <signal name="child-activated" handler="_on_artist_activated" swapped="no"/>
-                    <style>
-                      <class name="content-view"/>
-                    </style>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkBox" id="_album_header">
-                    <property name="halign">fill</property>
-                    <property name="hexpand">True</property>
-                    <property name="homogeneous">True</property>
-                    <property name="orientation">horizontal</property>
                     <child>
-                      <object class="GtkLabel">
-                        <property name="focusable">False</property>
-                        <property name="halign">start</property>
-                        <property name="label" translatable="yes">Albums</property>
+                      <object class="GtkFlowBox" id="_album_flowbox">
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="valign">start</property>
+                        <property name="homogeneous">True</property>
+                        <property name="min_children_per_line">1</property>
+                        <property name="max_children_per_line">6</property>
+                        <property name="margin-bottom">18</property>
+                        <property name="margin-top">18</property>
+                        <property name="row_spacing">12</property>
+                        <property name="column_spacing">6</property>
+                        <property name="selection_mode">none</property>
+                        <signal name="child-activated" handler="_on_album_activated" swapped="no"/>
                         <style>
-                          <class name="search-header"/>
+                          <class name="content-view"/>
                         </style>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkButton" id="_view_all_albums">
-                        <property name="halign">end</property>
-                        <property name="label" translatable="yes">View All</property>
-                        <property name="icon_name">go-next-symbolic</property>
-                        <signal name="clicked" handler="_on_all_albums_clicked" swapped="no"/>
+                      <object class="GtkBox" id="_songs_header">
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="orientation">horizontal</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="focusable">False</property>
+                            <property name="halign">start</property>
+                            <property name="label" translatable="yes">Songs</property>
+                            <style>
+                              <class name="search-header"/>
+                            </style>
+                          </object>
+                        </child>
                       </object>
                     </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFlowBox" id="_album_flowbox">
-                    <property name="halign">fill</property>
-                    <property name="hexpand">True</property>
-                    <property name="valign">start</property>
-                    <property name="homogeneous">True</property>
-                    <property name="min_children_per_line">1</property>
-                    <property name="max_children_per_line">6</property>
-                    <property name="margin-bottom">18</property>
-                    <property name="margin-top">18</property>
-                    <property name="row_spacing">12</property>
-                    <property name="column_spacing">6</property>
-                    <property name="selection_mode">none</property>
-                    <signal name="child-activated" handler="_on_album_activated" swapped="no"/>
-                    <style>
-                      <class name="content-view"/>
-                    </style>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkBox" id="_songs_header">
-                    <property name="halign">fill</property>
-                    <property name="hexpand">True</property>
-                    <property name="homogeneous">True</property>
-                    <property name="orientation">horizontal</property>
                     <child>
-                      <object class="GtkLabel">
-                        <property name="focusable">False</property>
-                        <property name="halign">start</property>
-                        <property name="label" translatable="yes">Songs</property>
+                      <object class="GtkListBox" id="_songs_listbox">
+                        <property name="margin-top">20</property>
+                        <signal name="row-activated" handler="_song_activated" swapped="no"/>
                         <style>
-                          <class name="search-header"/>
+                          <class name="boxed-list"/>
                         </style>
                       </object>
                     </child>
                   </object>
                 </child>
-                <child>
-                  <object class="GtkListBox" id="_songs_listbox">
-                    <property name="margin-top">20</property>
-                    <signal name="row-activated" handler="_song_activated" swapped="no"/>
-                    <style>
-                      <class name="boxed-list"/>
-                    </style>
-                  </object>
-                </child>
               </object>
             </child>
           </object>
@@ -145,53 +150,58 @@
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
         <child>
-          <object class="AdwClamp">
-            <property name="maximum-size">1600</property>
+          <object class="GtkViewport">
+            <property name="scroll-to-focus">True</property>
             <child>
-              <object class="GtkBox">
-                <property name="halign">fill</property>
-                <property name="hexpand">True</property>
-                <property name="margin-bottom">20</property>
-                <property name="margin-end">120</property>
-                <property name="margin-start">120</property>
-                <property name="margin-top">20</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <object class="GtkFlowBox" id="_artist_all_flowbox">
-                    <property name="column_spacing">6</property>
-                    <property name="halign">fill</property>
-                    <property name="hexpand">True</property>
-                    <property name="homogeneous">True</property>
-                    <property name="margin-bottom">18</property>
-                    <property name="margin-top">18</property>
-                    <property name="max-children-per-line">6</property>
-                    <property name="min-children-per-line">1</property>
-                    <property name="row_spacing">12</property>
-                    <property name="selection-mode">none</property>
-                    <property name="valign">start</property>
-                    <signal name="child-activated" handler="_on_artist_activated" swapped="no"/>
-                    <style>
-                      <class name="content-view"/>
-                    </style>
-                  </object>
-                </child>
+              <object class="AdwClamp">
+                <property name="maximum-size">1600</property>
                 <child>
-                  <object class="GtkFlowBox" id="_album_all_flowbox">
+                  <object class="GtkBox">
                     <property name="halign">fill</property>
                     <property name="hexpand">True</property>
-                    <property name="valign">start</property>
-                    <property name="homogeneous">True</property>
-                    <property name="min_children_per_line">1</property>
-                    <property name="max_children_per_line">6</property>
-                    <property name="margin-bottom">18</property>
-                    <property name="margin-top">18</property>
-                    <property name="row_spacing">12</property>
-                    <property name="column_spacing">6</property>
-                    <property name="selection_mode">none</property>
-                    <signal name="child-activated" handler="_on_album_activated" swapped="no"/>
-                    <style>
-                      <class name="content-view"/>
-                    </style>
+                    <property name="margin-bottom">20</property>
+                    <property name="margin-end">120</property>
+                    <property name="margin-start">120</property>
+                    <property name="margin-top">20</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="GtkFlowBox" id="_artist_all_flowbox">
+                        <property name="column_spacing">6</property>
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="margin-bottom">18</property>
+                        <property name="margin-top">18</property>
+                        <property name="max-children-per-line">6</property>
+                        <property name="min-children-per-line">1</property>
+                        <property name="row_spacing">12</property>
+                        <property name="selection-mode">none</property>
+                        <property name="valign">start</property>
+                        <signal name="child-activated" handler="_on_artist_activated" swapped="no"/>
+                        <style>
+                          <class name="content-view"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkFlowBox" id="_album_all_flowbox">
+                        <property name="halign">fill</property>
+                        <property name="hexpand">True</property>
+                        <property name="valign">start</property>
+                        <property name="homogeneous">True</property>
+                        <property name="min_children_per_line">1</property>
+                        <property name="max_children_per_line">6</property>
+                        <property name="margin-bottom">18</property>
+                        <property name="margin-top">18</property>
+                        <property name="row_spacing">12</property>
+                        <property name="column_spacing">6</property>
+                        <property name="selection_mode">none</property>
+                        <signal name="child-activated" handler="_on_album_activated" swapped="no"/>
+                        <style>
+                          <class name="content-view"/>
+                        </style>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
@@ -203,6 +213,11 @@
     <child>
       <object class="GtkScrolledWindow" id="_scrolled_album_widget">
         <property name="hscrollbar_policy">never</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="scroll-to-focus">True</property>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 5ff2a6ef0..c2469beee 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -132,7 +132,8 @@ class SearchView(Gtk.Stack):
         self._album_widget.bind_property(
             "selection-mode", self, "selection-mode",
             GObject.BindingFlags.BIDIRECTIONAL)
-        self._scrolled_album_widget.set_child(self._album_widget)
+        viewport = self._scrolled_album_widget.get_first_child()
+        viewport.set_child(self._album_widget)
 
         self._scrolled_artist_window: Optional[Gtk.ScrolledWindow] = None
 


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