Resize podcast cover art if it's too big (bug 1110)
Some feeds have cover art bigger than the size of my laptop's screen. Which make the podcast settings dialog really hard to use (close button out of screen). The parameter MAX_SIZE was already defined, and just waiting to be used.
This commit is contained in:
parent
92bf1255c4
commit
40a9d0a2b9
1 changed files with 13 additions and 1 deletions
|
@ -76,7 +76,7 @@ class CoverDownloader(ObservableService):
|
|||
"""
|
||||
|
||||
# Maximum width/height of the cover in pixels
|
||||
MAX_SIZE = 400
|
||||
MAX_SIZE = 360
|
||||
|
||||
def __init__(self):
|
||||
signal_names = ['cover-available', 'cover-removed']
|
||||
|
@ -192,6 +192,18 @@ class CoverDownloader(ObservableService):
|
|||
if pixbuf is None:
|
||||
pixbuf = self.get_default_cover(channel)
|
||||
|
||||
# Resize if width is too large
|
||||
if pixbuf.get_width() > self.MAX_SIZE:
|
||||
f = float(self.MAX_SIZE)/pixbuf.get_width()
|
||||
(width, height) = (int(pixbuf.get_width()*f), int(pixbuf.get_height()*f))
|
||||
pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
|
||||
|
||||
# Resize if height is too large
|
||||
if pixbuf.get_height() > self.MAX_SIZE:
|
||||
f = float(self.MAX_SIZE)/pixbuf.get_height()
|
||||
(width, height) = (int(pixbuf.get_width()*f), int(pixbuf.get_height()*f))
|
||||
pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
|
||||
|
||||
if async:
|
||||
self.notify('cover-available', channel.url, pixbuf)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue