Exemple #1
0
    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 = GdkPixbuf.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.SongRecord(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.calc_info_image_size()
                    fullwidth = max(fullwidth, 150)
                    (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()
Exemple #2
0
    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 = GdkPixbuf.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 = SongRecord(artist=artist,
                                           album=album,
                                           path=path)
                    self.cache.set(cache_key, filename)

                    # Artwork for tooltip, left-top of player:
                    (pix1, w, h) = img.get_pixbuf_of_size(pix, 75)
                    pix1 = img.do_style_cover(self.config, 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)

                self.emit('artwork-changed', pix)
                del pix

                self.lastalbumart = filename

                self.schedule_gc_collect()
Exemple #3
0
    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 = GdkPixbuf.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 = SongRecord(artist=artist, album=album,
                                           path=path)
                    self.cache.set(cache_key, filename)

                    # Artwork for tooltip, left-top of player:
                    (pix1, w, h) = img.get_pixbuf_of_size(pix, 75)
                    pix1 = img.do_style_cover(self.config, 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)

                self.emit('artwork-changed', pix)
                del pix

                self.lastalbumart = filename

                self.schedule_gc_collect()
Exemple #4
0
    def on_artwork_changed(self, artwork_obj, pixbuf):
        if self._imagebox.get_size_request()[0] == -1:
            notebook_width = self.info_song_grid.get_parent().get_allocation().width
            grid = self.info_song_grid
            grid_allocation = grid.get_allocation()
            grid_height = grid_allocation.height
            grid_width = grid.get_preferred_width_for_height(grid_height)[0]
            fullwidth = notebook_width - (grid_width + 120)
            new_width = max(fullwidth, 150)
        else:
            new_width = 150

        (pix2, w, h) = img.get_pixbuf_of_size(pixbuf, new_width)
        pix2 = img.do_style_cover(self.config, pix2, w, h)
        pix2 = img.pixbuf_add_border(pix2)

        self.image.set_from_pixbuf(pix2)
        del pix2
        del pixbuf
Exemple #5
0
    def download_progress(self, dest_filename_curr, i):
        # This populates Main.imagelist for the remote image window
        if os.path.exists(dest_filename_curr):
            pix = GdkPixbuf.Pixbuf.new_from_file(dest_filename_curr)
            pix = pix.scale_simple(148, 148, GdkPixbuf.InterpType.HYPER)
            pix = img.do_style_cover(self.config, pix, 148, 148)
            pix = img.pixbuf_add_border(pix)
            if self.stop_art_update:
                del pix
                return False # don't continue to next image
            self.imagelist_append([i + 1, pix])
            del pix
            self.remotefilelist_append(dest_filename_curr)
            if i == 0:
                self.allow_art_search()

            ui.change_cursor(None)

        return True # continue to next image
Exemple #6
0
    def download_progress(self, dest_filename_curr, i):
        # This populates Main.imagelist for the remote image window
        if os.path.exists(dest_filename_curr):
            pix = GdkPixbuf.Pixbuf.new_from_file(dest_filename_curr)
            pix = pix.scale_simple(148, 148, GdkPixbuf.InterpType.HYPER)
            pix = img.do_style_cover(self.config, pix, 148, 148)
            pix = img.pixbuf_add_border(pix)
            if self.stop_art_update:
                del pix
                return False  # don't continue to next image
            self.imagelist_append([i + 1, pix])
            del pix
            self.remotefilelist_append(dest_filename_curr)
            if i == 0:
                self.allow_art_search()

            ui.change_cursor(None)

        return True  # continue to next image
Exemple #7
0
    def on_artwork_changed(self, artwork_obj, pixbuf):
        if self._imagebox.get_size_request()[0] == -1:
            notebook_width = self.info_song_grid.get_parent().get_allocation(
            ).width
            grid = self.info_song_grid
            grid_allocation = grid.get_allocation()
            grid_height = grid_allocation.height
            grid_width = grid.get_preferred_width_for_height(grid_height)[0]
            fullwidth = notebook_width - (grid_width + 120)
            new_width = max(fullwidth, 150)
        else:
            new_width = 150

        (pix2, w, h) = img.get_pixbuf_of_size(pixbuf, new_width)
        pix2 = img.do_style_cover(self.config, pix2, w, h)
        pix2 = img.pixbuf_add_border(pix2)

        self.image.set_from_pixbuf(pix2)
        del pix2
        del pixbuf