updating icon generation logic

This commit is contained in:
itdominator 2022-03-13 17:45:23 -05:00
parent 681a71d0b1
commit cc6071249e

View File

@ -90,19 +90,23 @@ class Grid:
def generateGridIcons(self, dir, files): 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.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 @threaded
def create_icon(self, i, dir, file): def create_icon(self, i, dir, file):
icon = self.iconFactory.create_icon(dir, file) icon = self.iconFactory.create_icon(dir, file)
fpath = f"{dir}/{file}" GLib.idle_add(self.update_store, *(i, icon, dir, file,))
GLib.idle_add(self.update_store, (i, icon, fpath,))
def update_store(self, item): def update_store(self, i, icon, dir, file):
i, icon, fpath = item fpath = f"{dir}/{file}"
itr = self.store.get_iter(i) itr = self.store.get_iter(i)
if not icon: if not icon: