[gnome-music/wip/jfelder/searchview-new-style: 9/15] searchview: Add view all buttons logic



commit 76a42ce01ac9ebfcf206b6364e919a458510ca92
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Aug 5 20:53:16 2019 +0200

    searchview: Add view all buttons logic
    
    Artists and Albums sections have limit on how large they can
    grow. When, the results in a section exceed the space available,
    clicking on a "view all" button opens a new page with the full
    results.

 data/ui/SearchView.ui          | 62 ++++++++++++++++++++++++++++++++++++++++--
 gnomemusic/views/searchview.py | 32 ++++++++++++++++++++++
 2 files changed, 92 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/SearchView.ui b/data/ui/SearchView.ui
index d4e78911..93bdc27c 100644
--- a/data/ui/SearchView.ui
+++ b/data/ui/SearchView.ui
@@ -56,6 +56,7 @@
                     <property name="image">view_all_image_artist</property>
                     <property name="image_position">right</property>
                     <property name="visible">True</property>
+                    <signal name="button-release-event" handler="_on_all_artists_clicked" swapped="no"/>
                   </object>
                 </child>
               </object>
@@ -105,6 +106,7 @@
                     <property name="image">view_all_image_album</property>
                     <property name="image_position">right</property>
                     <property name="visible">True</property>
+                    <signal name="button-release-event" handler="_on_all_albums_clicked" swapped="no"/>
                   </object>
                 </child>
               </object>
@@ -161,5 +163,61 @@
         </child>
       </object>
     </child>
-  </template>
-</interface>
+    <child>
+      <object class="GtkScrolledWindow" id="_all_search_results">
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="visible">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-left">120</property>
+            <property name="margin-right">120</property>
+            <property name="margin-top">20</property>
+            <property name="orientation">vertical</property>
+            <property name="visible">True</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">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">18</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">6</property>
+                <property name="selection_mode">none</property>
+                <property name="visible">True</property>
+                <signal name="child-activated" handler="_on_album_activated" swapped="no"/>
+                <style>
+                  <class name="content-view"/>
+                </style>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+      </child>h
+    </template>
+  </interface>
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index a7f5b5dd..a29966ac 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -22,6 +22,7 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
+from gettext import gettext as _
 from gi.repository import Gdk, GObject, Gtk
 
 from gnomemusic import log
@@ -51,7 +52,10 @@ class SearchView(Gtk.Stack):
 
     _album_header = Gtk.Template.Child()
     _album_flowbox = Gtk.Template.Child()
+    _album_all_flowbox = Gtk.Template.Child()
+    _all_search_results = Gtk.Template.Child()
     _artist_header = Gtk.Template.Child()
+    _artist_all_flowbox = Gtk.Template.Child()
     _artist_flowbox = Gtk.Template.Child()
     _search_results = Gtk.Template.Child()
     _songs_header = Gtk.Template.Child()
@@ -333,6 +337,34 @@ class SearchView(Gtk.Stack):
         self.set_visible_child(self._artist_albums_widget)
         self.props.search_mode_active = False
 
+    @Gtk.Template.Callback()
+    def _on_all_artists_clicked(self, widget, event, user_data=None):
+        self._headerbar.props.state = HeaderBar.State.SEARCH
+        self._headerbar.props.title = _("Artists Results")
+        self._headerbar.props.subtitle = None
+
+        self._artist_all_flowbox.props.visible = True
+        self._album_all_flowbox.props.visible = False
+        self._artist_all_flowbox.bind_model(
+            self._artist_model, self._create_artist_widget)
+
+        self.props.visible_child = self._all_search_results
+        self.props.search_mode_active = False
+
+    @Gtk.Template.Callback()
+    def _on_all_albums_clicked(self, widget, event, user_data=None):
+        self._headerbar.props.state = HeaderBar.State.SEARCH
+        self._headerbar.props.title = _("Albums Results")
+        self._headerbar.props.subtitle = None
+
+        self._artist_all_flowbox.props.visible = False
+        self._album_all_flowbox.props.visible = True
+        self._album_all_flowbox.bind_model(
+            self._album_model, self._create_album_widget)
+
+        self.props.visible_child = self._all_search_results
+        self.props.search_mode_active = False
+
     def _select_all(self, value):
         with self._model.freeze_notify():
             def song_select(child):


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