[gnome-music/wip/jfelder/searchview-new-style: 12/13] searchview: Display an empty view if there are no results



commit fdbc5c2d586122b3c4ec9113577f4bbbabdad238
Author: Jean Felder <jfelder src gnome org>
Date:   Sun Aug 4 02:38:59 2019 +0200

    searchview: Display an empty view if there are no results

 gnomemusic/views/searchview.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 9ea44a70..cc7ce1a4 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -181,16 +181,31 @@ class SearchView(Gtk.Stack):
         items_found = model.get_n_items() > 0
         self._album_header.props.visible = items_found
         self._album_flowbox.props.visible = items_found
+        self._check_visibility()
 
     def _on_artist_model_items_changed(self, model, position, removed, added):
         items_found = model.get_n_items() > 0
         self._artist_header.props.visible = items_found
         self._artist_flowbox.props.visible = items_found
+        self._check_visibility()
 
     def _on_model_items_changed(self, model, position, removed, added):
         items_found = model.get_n_items() > 0
         self._songs_header.props.visible = items_found
         self._songs_listbox.props.visible = items_found
+        self._check_visibility()
+
+    def _check_visibility(self):
+        if not self.props.search_mode_active:
+            return
+
+        items_found = (self._model.get_n_items() > 0
+                       or self._artist_model.get_n_items() > 0
+                       or self._album_model.get_n_items() > 0)
+        if items_found:
+            self.props.search_state = Search.State.RESULT
+        else:
+            self.props.search_state = Search.State.NO_RESULT
 
     def _song_activated(self, widget, event):
         mod_mask = Gtk.accelerator_get_default_mod_mask()


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