forked from CreatBot/CreatBotKlipperScreen
print: use the smaller thumb for the list if available
This commit is contained in:
@@ -150,8 +150,11 @@ class KlippyFiles():
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_thumbnail_location(self, filename):
|
||||
def get_thumbnail_location(self, filename, small=False):
|
||||
thumb = self.files[filename]['thumbnails'][0]
|
||||
if small and len(self.files[filename]['thumbnails']) > 1:
|
||||
if self.files[filename]['thumbnails'][0]['width'] > self.files[filename]['thumbnails'][1]['width']:
|
||||
thumb = self.files[filename]['thumbnails'][1]
|
||||
if thumb['local'] is False:
|
||||
return ['http', thumb['path']]
|
||||
return ['file', thumb['path']]
|
||||
|
@@ -57,11 +57,11 @@ class ScreenPanel:
|
||||
def get_content(self):
|
||||
return self.content
|
||||
|
||||
def get_file_image(self, filename, width=1.6, height=1.6):
|
||||
def get_file_image(self, filename, width=1, height=1, small=False):
|
||||
if not self._files.has_thumbnail(filename):
|
||||
return None
|
||||
|
||||
loc = self._files.get_thumbnail_location(filename)
|
||||
loc = self._files.get_thumbnail_location(filename, small)
|
||||
if loc is None:
|
||||
return None
|
||||
if loc[0] == "file":
|
||||
|
@@ -212,7 +212,7 @@ class PrintPanel(ScreenPanel):
|
||||
file.set_vexpand(False)
|
||||
|
||||
icon = Gtk.Image()
|
||||
pixbuf = self.get_file_image(filepath)
|
||||
pixbuf = self.get_file_image(filepath, small=True)
|
||||
if pixbuf is not None:
|
||||
icon.set_from_pixbuf(pixbuf)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user