[gnome-music] Fixing some bugs related to EmptySearh view
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Fixing some bugs related to EmptySearh view
- Date: Thu, 9 Jul 2015 11:15:07 +0000 (UTC)
commit ab6d99fb9449922d4640e4185659df50b302e569
Author: Hapoofesgeli <Hapoofesgeli openmailbox org>
Date: Mon Jul 6 13:28:39 2015 +0430
Fixing some bugs related to EmptySearh view
https://bugzilla.gnome.org/show_bug.cgi?id=744464
gnomemusic/grilo.py | 8 +++++++-
gnomemusic/view.py | 22 +++++++++++++++-------
2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index dac1ab6..e074ab4 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -243,10 +243,16 @@ class Grilo(GObject.GObject):
@log
def search(self, q, callback, data=None):
options = self.options.copy()
+ self._search_callback_counter = 0
@log
def _search_callback(source, param, item, remaining, data, error):
callback(source, param, item, remaining, data)
+ self._search_callback_counter += 1
+
+ @log
+ def _multiple_search_callback(source, param, item, remaining, data, error):
+ callback(source, param, item, remaining, data)
if self.search_source:
if self.search_source.get_id().startswith('grl-upnp'):
@@ -257,7 +263,7 @@ class Grilo(GObject.GObject):
Grl.multiple_search([self.sources[key] for key in self.sources
if key != 'grl-tracker-source'],
q, self.METADATA_KEYS, options,
- _search_callback, data)
+ _multiple_search_callback, data)
@log
def get_album_art_for_item(self, item, callback, data=None):
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 659e0d4..fa21c73 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -1372,6 +1372,8 @@ class Search(ViewContainer):
self.items_selected = []
self.items_selected_callback = None
+ self.found_items_number = None
+
@log
def _no_music_found_callback(self, view):
self.window._stack.set_visible_child_name('emptysearch')
@@ -1442,6 +1444,8 @@ class Search(ViewContainer):
@log
def _add_search_item(self, source, param, item, remaining=0, data=None):
if not item or data != self.model:
+ if grilo._search_callback_counter == 0 and grilo.search_source:
+ self.emit('no-music-found')
return
artist = item.get_string(Grl.METADATA_KEY_ARTIST) \
@@ -1469,6 +1473,17 @@ class Search(ViewContainer):
if data is None:
return
+ model, category = data
+
+ self.found_items_number = (self.model.iter_n_children(self.head_iters[0])+
+ self.model.iter_n_children(self.head_iters[1])+
+ self.model.iter_n_children(self.head_iters[2])+
+ self.model.iter_n_children(self.head_iters[3]))
+
+ if category == 'song' and self.found_items_number == 0 and remaining == 0:
+ if grilo.search_source:
+ self.emit('no-music-found')
+
# We need to remember the view before the search view
if self.window.curr_view != self.window.views[5] and \
self.window.prev_view != self.window.views[5]:
@@ -1478,13 +1493,6 @@ class Search(ViewContainer):
self.window.notification.dismiss()
self.view.show()
- if (self.model.iter_n_children(self.head_iters[0])+
- self.model.iter_n_children(self.head_iters[1])+
- self.model.iter_n_children(self.head_iters[2])+
- self.model.iter_n_children(self.head_iters[3]) == 0) and remaining == 0:
- self.emit('no-music-found')
-
- model, category = data
if not item or model != self.model:
return
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]