X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Faa_selection_dialog.py;h=1477b4815a17e2b28ce1edb69e9900cb013693bd;hb=6ba66610d45c6efcecce4d6e66bdae83d5b57278;hp=6d19fcedfe97790b48a45c2ad3cc1b0065964943;hpb=abe62df54a2b596c02c53c05d2341705c1f8e8d8;p=mussorgsky diff --git a/src/aa_selection_dialog.py b/src/aa_selection_dialog.py index 6d19fce..1477b48 100644 --- a/src/aa_selection_dialog.py +++ b/src/aa_selection_dialog.py @@ -1,7 +1,7 @@ import hildon import gtk import gobject -from album_art import MussorgskyAlbumArt +from album_art_thread import MussorgskyAlbumArt class AlbumArtSelectionDialog (gtk.Dialog): @@ -14,6 +14,7 @@ class AlbumArtSelectionDialog (gtk.Dialog): "Select album art", parent, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) + self.DEFAULT_ALBUM = size+1 self.artist = artist self.album = album self.size = size @@ -50,18 +51,38 @@ class AlbumArtSelectionDialog (gtk.Dialog): self.event_boxes.append (event_box) hbox.pack_start (event_box, expand=False, fill=True) + + # default empty option + img = gtk.Image () + img.set_from_icon_name ("mediaplayer_default_album", gtk.ICON_SIZE_MENU) + img.set_pixel_size (124) + #img.set_size_request (124, 124) + self.images.append (img) + + event_box = gtk.EventBox () + event_box.add (img) + event_box.connect ("button-release-event", self.click_on_img, self.DEFAULT_ALBUM) + event_box.set_sensitive (True) + self.event_boxes.append (event_box) + + hbox.pack_start (event_box, expand=False, fill=True) + self.vbox.add (hbox) def __get_alternatives_async (self): counter = 0 for (path, thumb) in self.downloader.get_alternatives (self.album, self.artist, self.size): + print path, thumb if (self.cancel): return False self.paths.insert (counter, (path, thumb)) - print "Setting", thumb, "as image" - self.images[counter].set_from_file (thumb) - self.event_boxes [counter].set_sensitive (True) + if (thumb): + print "Setting", thumb, "as image" + self.images[counter].set_from_file (thumb) + self.event_boxes [counter].set_sensitive (True) + else: + continue counter += 1 while (gtk.events_pending()): gtk.main_iteration() @@ -74,10 +95,15 @@ class AlbumArtSelectionDialog (gtk.Dialog): def click_on_img (self, widget, event, position): - img, thumb = self.paths[position] - self.selection_img, self.selection_thumb = self.downloader.save_alternative (self.artist, - self.album, - img, thumb) + if (position == self.DEFAULT_ALBUM): + self.selection_img = None + self.selection_thumb = None + self.downloader.reset_alternative (self.artist, self.album) + else: + img, thumb = self.paths[position] + self.selection_img, self.selection_thumb = self.downloader.save_alternative (self.artist, + self.album, + img, thumb) self.response (position) def get_selection (self): @@ -104,6 +130,8 @@ if __name__ == "__main__": yield a def save_alternative (self, artist, album, img, thumb): return ("/home/user/.cache/media-art/" + img, "/home/user/.thumbnails/normal/" + thumb) + def reset_alternative (self, artist, album): + print "Removing the album-art and the thumbnail" def clicked_button (self):