diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb index cb9485a..d4ec8e7 100644 Binary files a/bin/pytop-0-0-1-x64.deb and b/bin/pytop-0-0-1-x64.deb differ diff --git a/src/Pytop/widgets/Grid.py b/src/Pytop/widgets/Grid.py index cc55573..4655d87 100644 --- a/src/Pytop/widgets/Grid.py +++ b/src/Pytop/widgets/Grid.py @@ -20,7 +20,7 @@ from utils.FileHandler import FileHandler def threaded(fn): 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 @@ -85,8 +85,10 @@ class Grid: desktop.sort() files.sort() + startVideoIcons = len(dirPaths) files = dirPaths + vids + images + desktop + files self.generateGridIcons(path, files) + self.fillVideoIcons(path, vids, startVideoIcons) @threaded @@ -95,9 +97,29 @@ class Grid: image = self.iconFactory.createIcon(dirPath, file).get_pixbuf() 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): 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): try: model = widget.get_model() diff --git a/src/Pytop/widgets/Icon.py b/src/Pytop/widgets/Icon.py index 75dbf11..be21542 100644 --- a/src/Pytop/widgets/Icon.py +++ b/src/Pytop/widgets/Icon.py @@ -36,21 +36,32 @@ class Icon: fullPath = dir + "/" + file return self.getIconImage(file, fullPath) + def createThumbnail(self, dir, file): + fullPath = dir + "/" + file + # Video thumbnail + if file.lower().endswith(self.vidsList): + fileHash = hashlib.sha256(str.encode(fullPath)).hexdigest() + hashImgPth = self.usrHome + "/.thumbnails/normal/" + fileHash + ".png" + + if isfile(hashImgPth) == False: + self.generateVideoThumbnail(fullPath, hashImgPth) + + 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 - # Video thumbnail - if file.lower().endswith(self.vidsList): - fileHash = hashlib.sha256(str.encode(fullPath)).hexdigest() - hashImgPth = self.usrHome + "/.thumbnails/normal/" + fileHash + ".png" - - if isfile(hashImgPth) == False: - self.generateVideoThumbnail(fullPath, hashImgPth) - - thumbnl = self.createScaledImage(hashImgPth, self.viIconWH) # Image Icon - elif file.lower().endswith(self.imagesList): + if file.lower().endswith(self.imagesList): thumbnl = self.createScaledImage(fullPath, self.viIconWH) # .desktop file parsing elif fullPath.lower().endswith( ('.desktop',) ):