Fixed the final two synchronous calls I could find
[jamaendo] / jamaui / showalbum.py
index 07a0e6d..7d0eed3 100644 (file)
@@ -34,9 +34,11 @@ from settings import settings
 from postoffice import postoffice
 import util
 import logging
+import thread
+import gobject
 from albumlist import TrackList
 from playlists import add_to_playlist
-from fetcher import fetcher
+from fetcher import Fetcher
 
 import webbrowser
 
@@ -123,10 +125,10 @@ class ShowAlbum(hildon.StackableWindow):
         if self.fetcher:
             self.fetcher.stop()
             self.fetcher = None
-        self.fetcher = Fetcher(jamaendo.starred_radios, self,
-                               on_item = self.on_radio_result,
-                               on_ok = self.on_radio_complete,
-                               on_fail = self.on_radio_complete)
+        self.fetcher = Fetcher(lambda: jamaendo.get_tracks(self.album.ID), self,
+                               on_item = self.on_track_result,
+                               on_ok = self.on_track_complete,
+                               on_fail = self.on_track_complete)
         self.fetcher.start()
 
     def on_track_result(self, wnd, item):
@@ -143,7 +145,6 @@ class ShowAlbum(hildon.StackableWindow):
         if albumid == self.album.ID and size == 300:
             self.cover.set_from_file(cover)
 
-
     def on_add_to_playlist(self, button, user_data=None):
         add_to_playlist(self, self.tracklist)
 
@@ -160,8 +161,19 @@ class ShowAlbum(hildon.StackableWindow):
         return btn
 
     def on_goto_artist(self, btn):
-        artist = jamaendo.get_artist(int(self.album.artist_id))
-        self.open_item(artist)
+        def threadfun(wnd, artist_id):
+            try:
+                artist = jamaendo.get_artist(artist_id)
+                def oncomplete(wnd, artist):
+                    wnd.open_item(artist)
+                    hildon.hildon_gtk_window_set_progress_indicator(wnd, 0)
+                gobject.idle_add(oncomplete, wnd, artist)
+            except:
+                def onfail(wnd):
+                    hildon.hildon_gtk_window_set_progress_indicator(wnd, 0)
+                gobject.idle_add(onfail, wnd)
+        hildon.hildon_gtk_window_set_progress_indicator(self, 1)
+        thread.start_new_thread(threadfun, (self, int(self.album.artist_id)))
 
     def on_download(self, btn):
         banner = hildon.hildon_banner_show_information(self, '', "Opening in web browser")