diff --git a/usr/lib/sonist/ui/image.py b/usr/lib/sonist/ui/image.py index 2992685..1adbd38 100644 --- a/usr/lib/sonist/ui/image.py +++ b/usr/lib/sonist/ui/image.py @@ -4,9 +4,10 @@ import gi, cairo, math gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk, GdkPixbuf +from utils import empty_pixbuf class ScaleImage(Gtk.Image): - def __init__(self, filepath): + def __init__(self, filepath = empty_pixbuf): Gtk.Image.__init__(self) self.width = None self.height = None @@ -17,7 +18,7 @@ class ScaleImage(Gtk.Image): if type(filepath) == str: self.origin = GdkPixbuf.Pixbuf.new_from_file(filepath) else: - self.origin = filepath + self.origin = filepath or empty_pixbuf if self.width is None: self.pixbuf = self.origin @@ -50,7 +51,7 @@ class ScaleImage(Gtk.Image): w = self.origin.get_width() h = self.origin.get_height() _size = min(w, h) # 按小边裁剪成正方形 - size = min(size, _size) # 缩放按最小值来 + # size = min(size, _size) # 缩放按最小值来 self.width = size self.height = size diff --git a/usr/lib/sonist/window.py b/usr/lib/sonist/window.py index 668ac39..5abffb5 100644 --- a/usr/lib/sonist/window.py +++ b/usr/lib/sonist/window.py @@ -66,7 +66,7 @@ class SonistWindow(Gtk.Window): # 唱片 disk = ScaleImage(image_dict['disk']) handler = ScaleImage(image_dict['handler']) - album = ScaleImage(image_dict['album']) + album = ScaleImage() disk.resize(192, 192) album.clip_resize(128).set_radius(64) @@ -332,8 +332,8 @@ class SonistWindow(Gtk.Window): self.update_album() @idle - def update_album(self, filepath = image_dict['avatar']): - self.set_background_image(filepath) + def update_album(self, filepath = None): + self.set_background_image(filepath or image_dict['album']) self.album.reset(filepath, True).set_radius(64) diff --git a/usr/share/sonist/album.png b/usr/share/sonist/album.png index 55a7ee4..130f214 100644 Binary files a/usr/share/sonist/album.png and b/usr/share/sonist/album.png differ diff --git a/usr/share/sonist/avatar.jpg b/usr/share/sonist/avatar.jpg deleted file mode 100644 index fd9e49c..0000000 Binary files a/usr/share/sonist/avatar.jpg and /dev/null differ