[gnome-music: 1/4] Do model.append() in idle_add to speed up element adding
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music: 1/4] Do model.append() in idle_add to speed up element adding
- Date: Sun, 11 Aug 2013 09:38:54 +0000 (UTC)
commit e5120e2938b398b03e33ad3b0297b77a5daa415c
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Thu Aug 8 14:17:41 2013 +0200
Do model.append() in idle_add to speed up element adding
gnomemusic/view.py | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 96166a0..969936f 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -172,28 +172,29 @@ class ViewContainer(Stack):
if not item:
return
self._offset += 1
- _iter = self._model.append()
artist = item.get_string(Grl.METADATA_KEY_ARTIST)\
or item.get_author()\
or _("Unknown Artist")
title = albumArtCache.get_media_title(item)
item.set_title(title)
- try:
+
+ def add_new_item():
+ _iter = self._model.append()
+ icon_name = self.nowPlayingIconName
if item.get_url():
- self.player.discoverer.discover_uri(item.get_url())
- self._model.set(_iter,
- [0, 1, 2, 3, 4, 5, 7, 8, 9, 10],
- [str(item.get_id()), '', title,
- artist, self._symbolicIcon, item,
- -1, self.nowPlayingIconName, False, False])
- except:
- print('failed to discover url ' + item.get_url())
+ try:
+ self.player.discoverer.discover_uri(item.get_url())
+ except:
+ print('failed to discover url ' + item.get_url())
+ icon_name = self.errorIconName
self._model.set(_iter,
[0, 1, 2, 3, 4, 5, 7, 8, 9, 10],
[str(item.get_id()), '', title,
artist, self._symbolicIcon, item,
- -1, self.errorIconName, False, True])
- GLib.idle_add(self._update_album_art, item, _iter)
+ -1, icon_name, False, icon_name == self.errorIconName])
+ GLib.idle_add(self._update_album_art, item, _iter)
+
+ GLib.idle_add(add_new_item)
def _get_remaining_item_count(self):
count = -1
@@ -214,7 +215,6 @@ class ViewContainer(Stack):
self._on_lookup_ready, itr)
def _update_album_art(self, item, itr):
- self._insert_album_art(item, item, itr)
grilo.get_album_art_for_album_id(
item.get_id(),
lambda source, count, cb_item, x, y, z:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]