def artwork_set_image(self, filename, artist, album, path, info_img_only=False): # Note: filename arrives here is in FILESYSTEM_CHARSET, not UTF-8! if (self.status_is_play_or_pause() and self.songinfo and self.songinfo.get('artist') == artist and self.songinfo.get('album') == album): if os.path.exists(filename): # We use try here because the file might exist, but might # still be downloading or corrupt: try: pix = gtk.gdk.pixbuf_new_from_file(filename) except: # If we have a 0-byte file, it should mean that # sonata reset the image file. Otherwise, it's a # bad file and should be removed. if os.stat(filename).st_size != 0: misc.remove_file(filename) return self.currentpb = pix if not info_img_only: # Store in cache cache_key = library_set_data(artist=artist, album=album, path=path) self.set_library_artwork_cached_filename(cache_key, filename) # Artwork for tooltip, left-top of player: (pix1, w, h) = img.get_pixbuf_of_size(pix, 75) pix1 = self.artwork_apply_composite_case(pix1, w, h) pix1 = img.pixbuf_add_border(pix1) pix1 = img.pixbuf_pad(pix1, 77, 77) self.albumimage.set_from_pixbuf(pix1) self.artwork_set_tooltip_art(pix1) del pix1 # Artwork for library, if current song matches: self.library_set_image_for_current_song(cache_key) # Artwork for fullscreen self.fullscreen_cover_art_set_image() # Artwork for info tab: if self.info_imagebox_get_size_request()[0] == -1: fullwidth = self.notebook_get_allocation()[2] - 50 (pix2, w, h) = img.get_pixbuf_of_size(pix, fullwidth) else: (pix2, w, h) = img.get_pixbuf_of_size(pix, 150) pix2 = self.artwork_apply_composite_case(pix2, w, h) pix2 = img.pixbuf_add_border(pix2) self.info_image.set_from_pixbuf(pix2) del pix2 del pix self.lastalbumart = filename self.schedule_gc_collect()
def artwork_set_image(self, filename, artist, album, path, info_img_only=False): # Note: filename arrives here is in FILESYSTEM_CHARSET, not UTF-8! if self.artwork_is_for_playing_song(filename): if os.path.exists(filename): # We use try here because the file might exist, but might # still be downloading or corrupt: try: pix = gtk.gdk.pixbuf_new_from_file(filename) except: # If we have a 0-byte file, it should mean that # sonata reset the image file. Otherwise, it's a # bad file and should be removed. if os.stat(filename).st_size != 0: misc.remove_file(filename) return self.currentpb = pix if not info_img_only: # Store in cache cache_key = library_set_data(artist=artist, album=album, path=path) self.set_library_artwork_cached_filename(cache_key, filename) # Artwork for tooltip, left-top of player: (pix1, w, h) = img.get_pixbuf_of_size(pix, 75) pix1 = self.artwork_apply_composite_case(pix1, w, h) pix1 = img.pixbuf_add_border(pix1) pix1 = img.pixbuf_pad(pix1, 77, 77) self.albumimage.set_from_pixbuf(pix1) self.artwork_set_tooltip_art(pix1) del pix1 # Artwork for library, if current song matches: self.library_set_image_for_current_song(cache_key) # Artwork for fullscreen self.fullscreen_cover_art_set_image() # Artwork for info tab: if self.info_imagebox_get_size_request()[0] == -1: fullwidth = self.notebook_get_allocation()[2] - 50 (pix2, w, h) = img.get_pixbuf_of_size(pix, fullwidth) else: (pix2, w, h) = img.get_pixbuf_of_size(pix, 150) pix2 = self.artwork_apply_composite_case(pix2, w, h) pix2 = img.pixbuf_add_border(pix2) self.info_image.set_from_pixbuf(pix2) del pix2 del pix self.lastalbumart = filename self.schedule_gc_collect()
def fullscreen_cover_art_set_image(self, force_update=False): if self.fullscreenalbumimage.get_property('visible') or force_update: if self.currentpb is None: self.fullscreen_cover_art_reset_image() else: # Artwork for fullscreen cover mode (pix3, w, h) = img.get_pixbuf_of_size(self.currentpb, consts.FULLSCREEN_COVER_SIZE) pix3 = self.artwork_apply_composite_case(pix3, w, h) pix3 = img.pixbuf_pad(pix3, consts.FULLSCREEN_COVER_SIZE, consts.FULLSCREEN_COVER_SIZE) self.fullscreenalbumimage.set_from_pixbuf(pix3) del pix3 self.fullscreen_cover_art_set_text()