Fixed Icon generation logic
This commit is contained in:
parent
edeaad3c85
commit
beadd27490
Binary file not shown.
@ -20,8 +20,7 @@ from utils.FileHandler import FileHandler
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
thread = threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
@ -85,10 +84,9 @@ class Grid:
|
||||
desktop.sort()
|
||||
files.sort()
|
||||
|
||||
startVideoIcons = len(dirPaths)
|
||||
files = dirPaths + vids + images + desktop + files
|
||||
self.generateGridIcons(path, files)
|
||||
self.fillVideoIcons(path, vids, startVideoIcons)
|
||||
self.fillVideoIcons(path, vids, len(dirPaths))
|
||||
|
||||
|
||||
@threaded
|
||||
@ -103,7 +101,7 @@ class Grid:
|
||||
|
||||
# Wait till we have a proper index...
|
||||
while len(self.store) < (start + 1):
|
||||
time.sleep(.500)
|
||||
time.sleep(.200)
|
||||
|
||||
i = start
|
||||
for file in files:
|
||||
|
@ -30,6 +30,8 @@ class Icon:
|
||||
self.iconContainerWH = settings.returnContainerWH()
|
||||
self.systemIconImageWH = settings.returnSystemIconImageWH()
|
||||
self.viIconWH = settings.returnVIIconWH()
|
||||
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__)) + "/"
|
||||
self.INTERNAL_ICON_PTH = self.SCRIPT_PTH + "../resources/icons/text.png"
|
||||
|
||||
|
||||
def createIcon(self, dir, file):
|
||||
@ -38,6 +40,7 @@ class Icon:
|
||||
|
||||
def createThumbnail(self, dir, file):
|
||||
fullPath = dir + "/" + file
|
||||
try:
|
||||
# Video thumbnail
|
||||
if file.lower().endswith(self.vidsList):
|
||||
fileHash = hashlib.sha256(str.encode(fullPath)).hexdigest()
|
||||
@ -48,20 +51,25 @@ class Icon:
|
||||
|
||||
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
|
||||
|
||||
if thumbnl == None: # If no icon, try stock file icon...
|
||||
thumbnl = gtk.Image.new_from_icon_name("gtk-file", gtk.IconSize.LARGE_TOOLBAR)
|
||||
|
||||
if thumbnl == None: # If no icon whatsoever, return internal default
|
||||
thumbnl = gtk.Image.new_from_file("resources/icons/bin.png")
|
||||
thumbnl = gtk.Image.new_from_file(self.SCRIPT_PTH + "../resources/icons/video.png")
|
||||
|
||||
return thumbnl
|
||||
except Exception as e:
|
||||
print("Thumbnail generation issue:")
|
||||
print(e)
|
||||
return gtk.Image.new_from_file(self.SCRIPT_PTH + "../resources/icons/video.png")
|
||||
|
||||
|
||||
def getIconImage(self, file, fullPath):
|
||||
try:
|
||||
thumbnl = None
|
||||
|
||||
# Video icon
|
||||
if file.lower().endswith(self.vidsList):
|
||||
thumbnl = gtk.Image.new_from_file(self.SCRIPT_PTH + "../resources/icons/video.png")
|
||||
# Image Icon
|
||||
if file.lower().endswith(self.imagesList):
|
||||
elif file.lower().endswith(self.imagesList):
|
||||
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
|
||||
# .desktop file parsing
|
||||
elif fullPath.lower().endswith( ('.desktop',) ):
|
||||
@ -70,16 +78,14 @@ class Icon:
|
||||
else:
|
||||
thumbnl = self.getSystemThumbnail(fullPath, self.systemIconImageWH[0])
|
||||
|
||||
if thumbnl == None: # If no icon, try stock file icon...
|
||||
thumbnl = gtk.Image.new_from_icon_name("gtk-file", gtk.IconSize.LARGE_TOOLBAR)
|
||||
|
||||
if thumbnl == None: # If no icon whatsoever, return internal default
|
||||
thumbnl = gtk.Image.new_from_file("resources/icons/bin.png")
|
||||
thumbnl = gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
||||
|
||||
return thumbnl
|
||||
except Exception as e:
|
||||
print("Icon generation issue:")
|
||||
print(e)
|
||||
return gtk.Image.new_from_file("resources/icons/bin.png")
|
||||
return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
||||
|
||||
|
||||
def parseDesktopFiles(self, fullPath):
|
||||
@ -132,6 +138,7 @@ class Icon:
|
||||
|
||||
return self.createScaledImage(altIconPath, self.systemIconImageWH)
|
||||
except Exception as e:
|
||||
print(".desktop icon generation issue:")
|
||||
print(e)
|
||||
return None
|
||||
|
||||
@ -152,6 +159,7 @@ class Icon:
|
||||
else:
|
||||
return None
|
||||
except Exception as e:
|
||||
print("system icon generation issue:")
|
||||
print(e)
|
||||
return None
|
||||
|
||||
@ -162,6 +170,7 @@ class Icon:
|
||||
scaledPixBuf = pixbuf.scale_simple(wxh[0], wxh[1], 2) # 2 = BILINEAR and is best by default
|
||||
return gtk.Image.new_from_pixbuf(scaledPixBuf)
|
||||
except Exception as e:
|
||||
print("Image Scaling Issue:")
|
||||
print(e)
|
||||
return None
|
||||
|
||||
@ -170,4 +179,5 @@ class Icon:
|
||||
proc = subprocess.Popen([self.thubnailGen, "-t", "65%", "-s", "300", "-c", "jpg", "-i", fullPath, "-o", hashImgPth])
|
||||
proc.wait()
|
||||
except Exception as e:
|
||||
print("Video thumbnail generation issue in thread:")
|
||||
print(e)
|
||||
|
Loading…
Reference in New Issue
Block a user