From cc6071249e9c5da49d335f7d16bb2e75ff520e50 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 13 Mar 2022 17:45:23 -0500 Subject: [PATCH] updating icon generation logic --- src/Pytop/widgets/grid.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Pytop/widgets/grid.py b/src/Pytop/widgets/grid.py index 392d443..b1069d4 100644 --- a/src/Pytop/widgets/grid.py +++ b/src/Pytop/widgets/grid.py @@ -90,20 +90,24 @@ class Grid: def generateGridIcons(self, dir, files): - for i, file in enumerate(files): + # NOTE: We insure all indecies exist before calling threads that update + # icon positions. In addition, adding the name allows us to see + # the "file" during long or heavy number of icon updates. + for file in files: self.store.append([None, file]) - self.create_icon(i, dir, file) + # Now we update as fast as possible the icons. + for i, file in enumerate(files): + self.create_icon(i, dir, file) @threaded def create_icon(self, i, dir, file): - icon = self.iconFactory.create_icon(dir, file) - fpath = f"{dir}/{file}" - GLib.idle_add(self.update_store, (i, icon, fpath,)) + icon = self.iconFactory.create_icon(dir, file) + GLib.idle_add(self.update_store, *(i, icon, dir, file,)) - def update_store(self, item): - i, icon, fpath = item - itr = self.store.get_iter(i) + def update_store(self, i, icon, dir, file): + fpath = f"{dir}/{file}" + itr = self.store.get_iter(i) if not icon: icon = self.get_system_thumbnail(fpath, self.iconFactory.SYS_ICON_WH[0])