From 6d18a6bc14bc08d336d2c7e43cad5903f9ce2872 Mon Sep 17 00:00:00 2001 From: kramo Date: Fri, 22 Dec 2023 23:12:52 +0100 Subject: [PATCH] Spawn separate threads for thumbnailing --- hyperplane/item.py | 17 ++++++++++++++--- hyperplane/path_bar.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hyperplane/item.py b/hyperplane/item.py index 1a5e457..e69c2fc 100644 --- a/hyperplane/item.py +++ b/hyperplane/item.py @@ -158,7 +158,13 @@ def bind(self) -> None: ) != Gio.FilesystemPreviewType.NEVER ): - generate_thumbnail(self.gfile, self.content_type, self.__thumbnail_cb) + GLib.Thread.new( + None, + generate_thumbnail, + self.gfile, + self.content_type, + self.__thumbnail_cb, + ) else: self.__thumbnail_cb() @@ -264,8 +270,13 @@ def next_files_cb( # Maybe this is the proper way? child_gfile = gfile.get_child(file_info.get_name()) - generate_thumbnail( - child_gfile, content_type, self.__dir_thumbnail_cb, picture + GLib.Thread.new( + None, + generate_thumbnail, + child_gfile, + content_type, + self.__dir_thumbnail_cb, + picture, ) # TODO: Could be oprimized if I called next_files with 3 the first time diff --git a/hyperplane/path_bar.py b/hyperplane/path_bar.py index b7ce409..ef7f91b 100644 --- a/hyperplane/path_bar.py +++ b/hyperplane/path_bar.py @@ -20,7 +20,7 @@ """The path bar in a HypWindow.""" from typing import Optional -from gi.repository import Gdk, GLib, Gtk +from gi.repository import GLib, Gtk from hyperplane import shared from hyperplane.path_segment import HypPathSegment