[gnome-music/wip/jfelder/searchview-new-style: 14/15] searchview: Display an empty view if there are no results
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/searchview-new-style: 14/15] searchview: Display an empty view if there are no results
- Date: Sun, 4 Aug 2019 01:35:57 +0000 (UTC)
commit 84bef3b4ad645f05e537b5318c64d5c9ab633c1b
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 eb1c418a..70ff5d8a 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -185,16 +185,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]