Thumbnail speed improvements

This commit is contained in:
2022-01-19 16:10:43 -06:00
parent 5a9fa8253b
commit 216cc9d34c
9 changed files with 33 additions and 35 deletions

View File

@@ -62,5 +62,5 @@ class Builtins(DBusControllerMixin):
# NOTE: Just reminding myself we can add to builtins two different ways...
# __builtins__.update({"event_system": Builtins()})
builtins.event_system = Builtins()
builtins.event_sleep_time = 0.5
builtins.event_sleep_time = 0.2
builtins.debug = False

View File

@@ -14,7 +14,7 @@ from __builtins__ import Builtins
class Main(Builtins):
def __init__(self, args, unknownargs):
event_system.create_ipc_server()
time.sleep(0.5)
time.sleep(0.2)
if not event_system.is_ipc_alive:
if unknownargs:
for arg in unknownargs:

View File

@@ -17,7 +17,7 @@ def threaded(fn):
class Icon(DesktopIconMixin, VideoIconMixin):
def create_icon(self, dir, file):
full_path = dir + "/" + file
full_path = f"{dir}/{file}"
return self.get_icon_image(dir, file, full_path)
def get_icon_image(self, dir, file, full_path):
@@ -36,22 +36,22 @@ class Icon(DesktopIconMixin, VideoIconMixin):
return None
def create_thumbnail(self, dir, file):
full_path = dir + "/" + file
full_path = f"{dir}/{file}"
try:
file_hash = hashlib.sha256(str.encode(full_path)).hexdigest()
hash_img_pth = self.ABS_THUMBS_PTH + "/" + file_hash + ".jpg"
hash_img_pth = f"{self.ABS_THUMBS_PTH}/{file_hash}.jpg"
if isfile(hash_img_pth) == False:
self.generate_video_thumbnail(full_path, hash_img_pth)
thumbnl = self.create_scaled_image(hash_img_pth, self.VIDEO_ICON_WH)
if thumbnl == None: # If no icon whatsoever, return internal default
thumbnl = GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
thumbnl = GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
return thumbnl
except Exception as e:
print("Thumbnail generation issue:")
print( repr(e) )
return GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
return GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
def create_scaled_image(self, path, wxh):

View File

@@ -20,15 +20,13 @@ def threaded(fn):
class WidgetMixin:
def load_store(self, view, store, save_state=False):
store.clear()
dir = view.get_current_directory()
files = view.get_files()
icon = GdkPixbuf.Pixbuf()
for i, file in enumerate(files):
store.append([icon, file[0]])
store.append([None, file[0]])
self.create_icon(i, view, store, dir, file[0])
# NOTE: Not likely called often from here but it could be useful
@@ -117,7 +115,7 @@ class WidgetMixin:
def create_grid_iconview_widget(self, view, wid):
scroll = Gtk.ScrolledWindow()
grid = Gtk.IconView()
store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
store = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
grid.set_model(store)
grid.set_pixbuf_column(0)
@@ -158,8 +156,8 @@ class WidgetMixin:
def create_grid_treeview_widget(self, view, wid):
scroll = Gtk.ScrolledWindow()
grid = Gtk.TreeView()
store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
# store = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)
store = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
# store = Gtk.TreeStore(GdkPixbuf.Pixbuf or None, str)
column = Gtk.TreeViewColumn("Icons")
icon = Gtk.CellRendererPixbuf()
name = Gtk.CellRendererText()