Split thumbnail generation after icons are loaded
This commit is contained in:
parent
c95ef55124
commit
edeaad3c85
Binary file not shown.
@ -20,7 +20,7 @@ from utils.FileHandler import FileHandler
|
|||||||
|
|
||||||
def threaded(fn):
|
def threaded(fn):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
thread = threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@ -85,8 +85,10 @@ class Grid:
|
|||||||
desktop.sort()
|
desktop.sort()
|
||||||
files.sort()
|
files.sort()
|
||||||
|
|
||||||
|
startVideoIcons = len(dirPaths)
|
||||||
files = dirPaths + vids + images + desktop + files
|
files = dirPaths + vids + images + desktop + files
|
||||||
self.generateGridIcons(path, files)
|
self.generateGridIcons(path, files)
|
||||||
|
self.fillVideoIcons(path, vids, startVideoIcons)
|
||||||
|
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
@ -95,9 +97,29 @@ class Grid:
|
|||||||
image = self.iconFactory.createIcon(dirPath, file).get_pixbuf()
|
image = self.iconFactory.createIcon(dirPath, file).get_pixbuf()
|
||||||
glib.idle_add(self.addToGrid, (image, file,))
|
glib.idle_add(self.addToGrid, (image, file,))
|
||||||
|
|
||||||
|
@threaded
|
||||||
|
def fillVideoIcons(self, dirPath, files, start):
|
||||||
|
model = self.grid.get_model()
|
||||||
|
|
||||||
|
# Wait till we have a proper index...
|
||||||
|
while len(self.store) < (start + 1):
|
||||||
|
time.sleep(.500)
|
||||||
|
|
||||||
|
i = start
|
||||||
|
for file in files:
|
||||||
|
image = self.iconFactory.createThumbnail(dirPath, file).get_pixbuf()
|
||||||
|
iter = model.get_iter_from_string(str(i))
|
||||||
|
glib.idle_add(self.replaceInGrid, (iter, image,))
|
||||||
|
i += 1
|
||||||
|
|
||||||
def addToGrid(self, dataSet):
|
def addToGrid(self, dataSet):
|
||||||
self.store.append([dataSet[0], dataSet[1]])
|
self.store.append([dataSet[0], dataSet[1]])
|
||||||
|
|
||||||
|
def replaceInGrid(self, dataSet):
|
||||||
|
# Iter, row column, new pixbuf...
|
||||||
|
self.store.set_value(dataSet[0], 0 , dataSet[1])
|
||||||
|
|
||||||
|
|
||||||
def iconDblLeftClick(self, widget, item):
|
def iconDblLeftClick(self, widget, item):
|
||||||
try:
|
try:
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
|
@ -36,10 +36,8 @@ class Icon:
|
|||||||
fullPath = dir + "/" + file
|
fullPath = dir + "/" + file
|
||||||
return self.getIconImage(file, fullPath)
|
return self.getIconImage(file, fullPath)
|
||||||
|
|
||||||
def getIconImage(self, file, fullPath):
|
def createThumbnail(self, dir, file):
|
||||||
try:
|
fullPath = dir + "/" + file
|
||||||
thumbnl = None
|
|
||||||
|
|
||||||
# Video thumbnail
|
# Video thumbnail
|
||||||
if file.lower().endswith(self.vidsList):
|
if file.lower().endswith(self.vidsList):
|
||||||
fileHash = hashlib.sha256(str.encode(fullPath)).hexdigest()
|
fileHash = hashlib.sha256(str.encode(fullPath)).hexdigest()
|
||||||
@ -49,8 +47,21 @@ class Icon:
|
|||||||
self.generateVideoThumbnail(fullPath, hashImgPth)
|
self.generateVideoThumbnail(fullPath, hashImgPth)
|
||||||
|
|
||||||
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
|
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")
|
||||||
|
|
||||||
|
return thumbnl
|
||||||
|
|
||||||
|
def getIconImage(self, file, fullPath):
|
||||||
|
try:
|
||||||
|
thumbnl = None
|
||||||
|
|
||||||
# Image Icon
|
# Image Icon
|
||||||
elif file.lower().endswith(self.imagesList):
|
if file.lower().endswith(self.imagesList):
|
||||||
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
|
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
|
||||||
# .desktop file parsing
|
# .desktop file parsing
|
||||||
elif fullPath.lower().endswith( ('.desktop',) ):
|
elif fullPath.lower().endswith( ('.desktop',) ):
|
||||||
|
Loading…
Reference in New Issue
Block a user