Trying once more to improve icon loading...

This commit is contained in:
Maxim Stewart 2019-10-14 21:40:25 -05:00
parent 8fcef82b42
commit c95ef55124
6 changed files with 49 additions and 50 deletions

Binary file not shown.

View File

@ -143,8 +143,22 @@
<property name="can_focus">False</property>
<property name="stock">gtk-new</property>
</object>
<object class="GtkPopover" id="taskbarMenu">
<object class="GtkWindow" id="taskbarMenu">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">mouse</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">splashscreen</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="decorated">False</property>
<property name="deletable">False</property>
<property name="gravity">north</property>
<signal name="focus-out-event" handler="hideTaskbarMenu" swapped="no"/>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
@ -281,8 +295,12 @@
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">splashscreen</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="decorated">False</property>
<property name="deletable">False</property>
<property name="gravity">center</property>
<signal name="focus-out-event" handler="closePopup" swapped="no"/>
<child>

View File

@ -63,8 +63,6 @@ class TaskbarSignals:
def setScreenSignals(self):
self.SCREEN.connect("active-workspace-changed", self.activeWorkspaceChanged)
# self.SCREEN.connect("application-opened", self.applicationOpened)
# self.SCREEN.connect("application-closed", self.applicationClosed)
self.SCREEN.connect("window-opened", self.windowOpened)
self.SCREEN.connect("window-closed", self.windowClosed)
@ -84,8 +82,10 @@ class TaskbarSignals:
window.activate(1)
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.RIGHT_BUTTON:
self.window = window
self.taskbarMenu.set_relative_to(widget)
self.taskbarMenu.popup()
self.taskbarMenu.show()
def hideTaskbarMenu(self, widget, eve):
widget.hide()
def setPagerWidget(self):
pager = wnck.Pager()
@ -100,11 +100,13 @@ class TaskbarSignals:
self.SCREEN = screen
self.SCREEN.force_update() # (Re)populate screen windows list
self.refreashTaskbar()
def windowOpened(self, screen, window):
self.SCREEN.force_update() # (Re)populate screen windows list
btn = self.createWinBttn(window)
self.setupSignals(btn, window)
self.taskBarButtons.add(btn)
def windowClosed(self, screen, window):
self.clearChildren(self.taskBarButtons)
self.SCREEN.force_update() # (Re)populate screen windows list

View File

@ -38,19 +38,19 @@ class FileHandler:
def openFile(self, file):
print("Opening: " + file)
if file.lower().endswith(self.vids):
subprocess.Popen([self.MEDIAPLAYER, self.MPV_WH, file], stdout=subprocess.PIPE)
subprocess.Popen([self.MEDIAPLAYER, self.MPV_WH, file], stdout=subprocess.PIPE, close_fds=True)
elif file.lower().endswith(self.music):
subprocess.Popen([self.MUSICPLAYER, file], stdout=subprocess.PIPE)
subprocess.Popen([self.MUSICPLAYER, file], stdout=subprocess.PIPE, close_fds=True)
elif file.lower().endswith(self.images):
subprocess.Popen([self.IMGVIEWER, file], stdout=subprocess.PIPE)
subprocess.Popen([self.IMGVIEWER, file], stdout=subprocess.PIPE, close_fds=True)
elif file.lower().endswith(self.txt):
subprocess.Popen([self.TEXTVIEWER, file], stdout=subprocess.PIPE)
subprocess.Popen([self.TEXTVIEWER, file], stdout=subprocess.PIPE, close_fds=True)
elif file.lower().endswith(self.pdf):
subprocess.Popen([self.PDFVIEWER, file], stdout=subprocess.PIPE)
subprocess.Popen([self.PDFVIEWER, file], stdout=subprocess.PIPE, close_fds=True)
elif file.lower().endswith(self.office):
subprocess.Popen([self.OFFICEPROG, file], stdout=subprocess.PIPE)
subprocess.Popen([self.OFFICEPROG, file], stdout=subprocess.PIPE, close_fds=True)
else:
subprocess.Popen(['xdg-open', file], stdout=subprocess.PIPE)
subprocess.Popen(['xdg-open', file], stdout=subprocess.PIPE, close_fds=True)
def create(self, name, type):

View File

@ -40,7 +40,6 @@ class Grid:
self.imagesFilter = settings.returnImagesFilter()
self.iconFactory = Icon(settings)
self.helperThread = None # Helper thread object
self.toWorkPool = [] # Thread fills pool and gtk empties it
self.selectedFiles = []
self.currentPath = ""
@ -52,6 +51,7 @@ class Grid:
# @threaded
def setNewDirectory(self, path):
self.store.clear()
self.currentPath = path
dirPaths = ['.', '..']
vids = []
@ -86,38 +86,17 @@ class Grid:
files.sort()
files = dirPaths + vids + images + desktop + files
self.store.clear()
self.generateGridIcons(path, files)
# Run helper thread...
self.helperThread = threading.Thread(target=self.generateGridIcons, args=(path, files))
self.helperThread.daemon = True # Set this thread as a Daemon Thread
self.helperThread.start()
# self.generateGridIcons(path, files)
glib.idle_add(self.addToGrid, (files,)) # NOTE: This must stay in the main thread b/c
# gtk isn't thread safe/aware.
# @threaded
@threaded
def generateGridIcons(self, dirPath, files):
for file in files:
image = self.iconFactory.createIcon(dirPath, file)
self.toWorkPool.append([image, file])
image = self.iconFactory.createIcon(dirPath, file).get_pixbuf()
glib.idle_add(self.addToGrid, (image, file,))
# NOTE: If nothing else is updating, this function gets called immediatly when return is True.
# Returning False ends checks and "continues normal flow"
def addToGrid(self, args):
files = args[0]
if len(self.toWorkPool) > 0:
for dataSet in self.toWorkPool:
self.store.append([dataSet[0].get_pixbuf(), dataSet[1]])
self.toWorkPool.clear()
if len(self.store) == len(files): # Processed all files
return False
else: # Check again when idle
return True
def addToGrid(self, dataSet):
self.store.append([dataSet[0], dataSet[1]])
def iconDblLeftClick(self, widget, item):
try:
@ -187,7 +166,7 @@ class Grid:
def returnSelectedFiles(self):
# NOTE: Just returning selectedFiles looks like it returns a "pointer"
# to the children. This mean we lose the list if any left click occures
# to the children. This means we lose the list if any left click occures
# in this class.
files = []
for file in self.selectedFiles:
@ -195,4 +174,5 @@ class Grid:
return files
def returnCurrentPath(self):
return self.currentPath
currentPath = self.currentPath
return currentPath

View File

@ -36,10 +36,9 @@ class Icon:
fullPath = dir + "/" + file
return self.getIconImage(file, fullPath)
def getIconImage(self, file, fullPath):
try:
thumbnl = None
thumbnl = None
# Video thumbnail
if file.lower().endswith(self.vidsList):
@ -49,22 +48,22 @@ class Icon:
if isfile(hashImgPth) == False:
self.generateVideoThumbnail(fullPath, hashImgPth)
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
# Image Icon
elif file.lower().endswith(self.imagesList):
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
# .desktop file parsing
elif fullPath.lower().endswith( ('.desktop',) ):
thumbnl = self.parseDesktopFiles(fullPath)
thumbnl = self.parseDesktopFiles(fullPath)
# System icons
else:
thumbnl = self.getSystemThumbnail(fullPath, self.systemIconImageWH[0])
thumbnl = self.getSystemThumbnail(fullPath, self.systemIconImageWH[0])
if thumbnl == None: # If no icon, try stock file icon...
thumbnl = gtk.Image.new_from_icon_name("gtk-file", gtk.IconSize.LARGE_TOOLBAR)
thumbnl = gtk.Image.new_from_icon_name("gtk-file", gtk.IconSize.LARGE_TOOLBAR)
if thumbnl == None: # If no icon whatsoever, return internal default
thumbnl = gtk.Image.new_from_file("resources/icons/bin.png")
thumbnl = gtk.Image.new_from_file("resources/icons/bin.png")
return thumbnl
except Exception as e: