[gnome-music/wip/jfelder/searchview-new-style: 18/21] 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: 18/21] searchview: Display an empty view if there are no results
- Date: Mon, 5 Aug 2019 00:19:17 +0000 (UTC)
commit 37ccdf8f88d49f06cfc21d313cbe7aa1dd46202b
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 f59700e4..9b28bd7a 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]