From fbf6b24389a3a87dca130957220824dfb0cf670f Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Thu, 20 Jun 2019 23:07:30 -0500 Subject: [PATCH] Changed threadding setup --- .../pytop-0-0-1-x64/opt/Pytop/utils/Grid.py | 35 +++++++++++------- src/versions/pytop-0.0.1/Pytop/utils/Grid.py | 35 +++++++++++------- src/versions/pytop-0.0.1/pytop | Bin 0 -> 6168 bytes 3 files changed, 42 insertions(+), 28 deletions(-) create mode 100755 src/versions/pytop-0.0.1/pytop diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py index de42f57..52e4c80 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py @@ -11,7 +11,7 @@ from gi.repository import GLib as glib from gi.repository import GdkPixbuf # Python imports -import os, threading +import os, threading, time from os.path import isdir, isfile, join from os import listdir from .Icon import Icon @@ -48,9 +48,10 @@ class Grid: self.copyCutArry = [] - self.gtkLock = False # Thread checks for gtkLock - self.threadLock = False # Gtk checks for thread lock - self.toWorkPool = [] # Thread fills pool and gtk empties it + self.gtkLock = False # Thread checks for gtkLock + self.threadLock = False # Gtk checks for thread lock + self.helperThread = None # Helper thread object + self.toWorkPool = [] # Thread fills pool and gtk empties it self.setIconViewDir(newPath) @@ -86,26 +87,30 @@ class Grid: images.sort() desktop.sort() files.sort() - files = dirPaths + vids + images + desktop + files - self.generateDirectoryGrid(path, files) # Run helper thread... + + if self.helperThread: + self.helperThread.terminate() + self.helperThread = None + + # Run helper thread... + self.threadLock = True + self.helperThread = threading.Thread(target=self.generateDirectoryGridIcon, args=(path, files)).start() glib.idle_add(self.addToGrid, (file,)) # This must stay in the main thread b/c # gtk isn't thread safe/aware So, we # make a sad lil thread hot potato 'game' # out of this process. - @threaded - def generateDirectoryGrid(self, dirPath, files): + # @threaded + def generateDirectoryGridIcon(self, dirPath, files): # NOTE: We'll be passing pixbuf after retreval to keep Icon.py file more # universaly usable. We can just remove get_pixbuf to get a gtk.Image type for file in files: image = Icon(self.settings).createIcon(dirPath, file) - self.toWorkPool.append([image.get_pixbuf(), file]) self.threadLock = False self.gtkLock = True - storageQue.clear() def addToGrid(self, args): @@ -128,11 +133,13 @@ class Grid: self.toWorkPool.clear() self.gtkLock = False self.threadLock = True + time.sleep(.005) # Fixes refresh and up icon not being added. return True def setIconSelectionArray(self, widget, data=None): - os.system('cls||clear') - print(data) + pass + # os.system('cls||clear') + # print(data) def iconLeftClickEventManager(self, widget, item): try: @@ -190,14 +197,14 @@ class Grid: if status == 0: self.selectedFile = newName - self.generateDirectoryGrid(self.currentPath) + self.setIconViewDir(self.currentPath) def deleteFile(self): status = self.filehandler.deleteFile(self.selectedFile) if status == 0: self.selectedFile = "" - self.generateDirectoryGrid(self.currentPath) + self.setIconViewDir(self.currentPath) def copyFile(self): pass diff --git a/src/versions/pytop-0.0.1/Pytop/utils/Grid.py b/src/versions/pytop-0.0.1/Pytop/utils/Grid.py index de42f57..52e4c80 100644 --- a/src/versions/pytop-0.0.1/Pytop/utils/Grid.py +++ b/src/versions/pytop-0.0.1/Pytop/utils/Grid.py @@ -11,7 +11,7 @@ from gi.repository import GLib as glib from gi.repository import GdkPixbuf # Python imports -import os, threading +import os, threading, time from os.path import isdir, isfile, join from os import listdir from .Icon import Icon @@ -48,9 +48,10 @@ class Grid: self.copyCutArry = [] - self.gtkLock = False # Thread checks for gtkLock - self.threadLock = False # Gtk checks for thread lock - self.toWorkPool = [] # Thread fills pool and gtk empties it + self.gtkLock = False # Thread checks for gtkLock + self.threadLock = False # Gtk checks for thread lock + self.helperThread = None # Helper thread object + self.toWorkPool = [] # Thread fills pool and gtk empties it self.setIconViewDir(newPath) @@ -86,26 +87,30 @@ class Grid: images.sort() desktop.sort() files.sort() - files = dirPaths + vids + images + desktop + files - self.generateDirectoryGrid(path, files) # Run helper thread... + + if self.helperThread: + self.helperThread.terminate() + self.helperThread = None + + # Run helper thread... + self.threadLock = True + self.helperThread = threading.Thread(target=self.generateDirectoryGridIcon, args=(path, files)).start() glib.idle_add(self.addToGrid, (file,)) # This must stay in the main thread b/c # gtk isn't thread safe/aware So, we # make a sad lil thread hot potato 'game' # out of this process. - @threaded - def generateDirectoryGrid(self, dirPath, files): + # @threaded + def generateDirectoryGridIcon(self, dirPath, files): # NOTE: We'll be passing pixbuf after retreval to keep Icon.py file more # universaly usable. We can just remove get_pixbuf to get a gtk.Image type for file in files: image = Icon(self.settings).createIcon(dirPath, file) - self.toWorkPool.append([image.get_pixbuf(), file]) self.threadLock = False self.gtkLock = True - storageQue.clear() def addToGrid(self, args): @@ -128,11 +133,13 @@ class Grid: self.toWorkPool.clear() self.gtkLock = False self.threadLock = True + time.sleep(.005) # Fixes refresh and up icon not being added. return True def setIconSelectionArray(self, widget, data=None): - os.system('cls||clear') - print(data) + pass + # os.system('cls||clear') + # print(data) def iconLeftClickEventManager(self, widget, item): try: @@ -190,14 +197,14 @@ class Grid: if status == 0: self.selectedFile = newName - self.generateDirectoryGrid(self.currentPath) + self.setIconViewDir(self.currentPath) def deleteFile(self): status = self.filehandler.deleteFile(self.selectedFile) if status == 0: self.selectedFile = "" - self.generateDirectoryGrid(self.currentPath) + self.setIconViewDir(self.currentPath) def copyFile(self): pass diff --git a/src/versions/pytop-0.0.1/pytop b/src/versions/pytop-0.0.1/pytop new file mode 100755 index 0000000000000000000000000000000000000000..50311e98112f448e84624fec80c68f097338c08f GIT binary patch literal 6168 zcmeHLUu;uV7(ea);^3|-f9kem7lmYCcGtleRsP*}Fz(32iK~#n=(??=HEX-Hw{tZH zrvs9zQyzTSlP)Iu?2E}Bh_cLp4?c{9Xrd4&VaY(JOF$qdtbX6Q-?x@BjPbz-v(w!3 zJKvw*`M&e#-rjrO+}GM{x7h?2yVxyIYAe*G%BqDp^0*X9=N2o3E-FQZCn&uzC9Zo4iUj8&FeFmi^7MP#!;C&@y+gtUZ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