Trying once more to improve icon loading...
This commit is contained in:
parent
8fcef82b42
commit
c95ef55124
Binary file not shown.
@ -143,8 +143,22 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-new</property>
|
<property name="stock">gtk-new</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkPopover" id="taskbarMenu">
|
<object class="GtkWindow" id="taskbarMenu">
|
||||||
<property name="can_focus">False</property>
|
<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>
|
<child>
|
||||||
<object class="GtkButtonBox">
|
<object class="GtkButtonBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -281,8 +295,12 @@
|
|||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
<property name="window_position">center</property>
|
<property name="window_position">center</property>
|
||||||
|
<property name="destroy_with_parent">True</property>
|
||||||
<property name="type_hint">splashscreen</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="decorated">False</property>
|
||||||
|
<property name="deletable">False</property>
|
||||||
<property name="gravity">center</property>
|
<property name="gravity">center</property>
|
||||||
<signal name="focus-out-event" handler="closePopup" swapped="no"/>
|
<signal name="focus-out-event" handler="closePopup" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
|
@ -63,8 +63,6 @@ class TaskbarSignals:
|
|||||||
|
|
||||||
def setScreenSignals(self):
|
def setScreenSignals(self):
|
||||||
self.SCREEN.connect("active-workspace-changed", self.activeWorkspaceChanged)
|
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-opened", self.windowOpened)
|
||||||
self.SCREEN.connect("window-closed", self.windowClosed)
|
self.SCREEN.connect("window-closed", self.windowClosed)
|
||||||
|
|
||||||
@ -84,8 +82,10 @@ class TaskbarSignals:
|
|||||||
window.activate(1)
|
window.activate(1)
|
||||||
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.RIGHT_BUTTON:
|
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.RIGHT_BUTTON:
|
||||||
self.window = window
|
self.window = window
|
||||||
self.taskbarMenu.set_relative_to(widget)
|
self.taskbarMenu.show()
|
||||||
self.taskbarMenu.popup()
|
|
||||||
|
def hideTaskbarMenu(self, widget, eve):
|
||||||
|
widget.hide()
|
||||||
|
|
||||||
def setPagerWidget(self):
|
def setPagerWidget(self):
|
||||||
pager = wnck.Pager()
|
pager = wnck.Pager()
|
||||||
@ -100,11 +100,13 @@ class TaskbarSignals:
|
|||||||
self.SCREEN = screen
|
self.SCREEN = screen
|
||||||
self.SCREEN.force_update() # (Re)populate screen windows list
|
self.SCREEN.force_update() # (Re)populate screen windows list
|
||||||
self.refreashTaskbar()
|
self.refreashTaskbar()
|
||||||
|
|
||||||
def windowOpened(self, screen, window):
|
def windowOpened(self, screen, window):
|
||||||
self.SCREEN.force_update() # (Re)populate screen windows list
|
self.SCREEN.force_update() # (Re)populate screen windows list
|
||||||
btn = self.createWinBttn(window)
|
btn = self.createWinBttn(window)
|
||||||
self.setupSignals(btn, window)
|
self.setupSignals(btn, window)
|
||||||
self.taskBarButtons.add(btn)
|
self.taskBarButtons.add(btn)
|
||||||
|
|
||||||
def windowClosed(self, screen, window):
|
def windowClosed(self, screen, window):
|
||||||
self.clearChildren(self.taskBarButtons)
|
self.clearChildren(self.taskBarButtons)
|
||||||
self.SCREEN.force_update() # (Re)populate screen windows list
|
self.SCREEN.force_update() # (Re)populate screen windows list
|
||||||
|
@ -38,19 +38,19 @@ class FileHandler:
|
|||||||
def openFile(self, file):
|
def openFile(self, file):
|
||||||
print("Opening: " + file)
|
print("Opening: " + file)
|
||||||
if file.lower().endswith(self.vids):
|
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):
|
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):
|
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):
|
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):
|
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):
|
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:
|
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):
|
def create(self, name, type):
|
||||||
|
@ -40,7 +40,6 @@ class Grid:
|
|||||||
self.imagesFilter = settings.returnImagesFilter()
|
self.imagesFilter = settings.returnImagesFilter()
|
||||||
self.iconFactory = Icon(settings)
|
self.iconFactory = Icon(settings)
|
||||||
self.helperThread = None # Helper thread object
|
self.helperThread = None # Helper thread object
|
||||||
self.toWorkPool = [] # Thread fills pool and gtk empties it
|
|
||||||
self.selectedFiles = []
|
self.selectedFiles = []
|
||||||
self.currentPath = ""
|
self.currentPath = ""
|
||||||
|
|
||||||
@ -52,6 +51,7 @@ class Grid:
|
|||||||
|
|
||||||
# @threaded
|
# @threaded
|
||||||
def setNewDirectory(self, path):
|
def setNewDirectory(self, path):
|
||||||
|
self.store.clear()
|
||||||
self.currentPath = path
|
self.currentPath = path
|
||||||
dirPaths = ['.', '..']
|
dirPaths = ['.', '..']
|
||||||
vids = []
|
vids = []
|
||||||
@ -86,38 +86,17 @@ class Grid:
|
|||||||
files.sort()
|
files.sort()
|
||||||
|
|
||||||
files = dirPaths + vids + images + desktop + files
|
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):
|
def generateGridIcons(self, dirPath, files):
|
||||||
for file in files:
|
for file in files:
|
||||||
image = self.iconFactory.createIcon(dirPath, file)
|
image = self.iconFactory.createIcon(dirPath, file).get_pixbuf()
|
||||||
self.toWorkPool.append([image, file])
|
glib.idle_add(self.addToGrid, (image, file,))
|
||||||
|
|
||||||
|
def addToGrid(self, dataSet):
|
||||||
# NOTE: If nothing else is updating, this function gets called immediatly when return is True.
|
self.store.append([dataSet[0], dataSet[1]])
|
||||||
# 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 iconDblLeftClick(self, widget, item):
|
def iconDblLeftClick(self, widget, item):
|
||||||
try:
|
try:
|
||||||
@ -187,7 +166,7 @@ class Grid:
|
|||||||
|
|
||||||
def returnSelectedFiles(self):
|
def returnSelectedFiles(self):
|
||||||
# NOTE: Just returning selectedFiles looks like it returns a "pointer"
|
# 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.
|
# in this class.
|
||||||
files = []
|
files = []
|
||||||
for file in self.selectedFiles:
|
for file in self.selectedFiles:
|
||||||
@ -195,4 +174,5 @@ class Grid:
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
def returnCurrentPath(self):
|
def returnCurrentPath(self):
|
||||||
return self.currentPath
|
currentPath = self.currentPath
|
||||||
|
return currentPath
|
||||||
|
@ -36,10 +36,9 @@ class Icon:
|
|||||||
fullPath = dir + "/" + file
|
fullPath = dir + "/" + file
|
||||||
return self.getIconImage(file, fullPath)
|
return self.getIconImage(file, fullPath)
|
||||||
|
|
||||||
|
|
||||||
def getIconImage(self, file, fullPath):
|
def getIconImage(self, file, fullPath):
|
||||||
try:
|
try:
|
||||||
thumbnl = None
|
thumbnl = None
|
||||||
|
|
||||||
# Video thumbnail
|
# Video thumbnail
|
||||||
if file.lower().endswith(self.vidsList):
|
if file.lower().endswith(self.vidsList):
|
||||||
@ -49,22 +48,22 @@ class Icon:
|
|||||||
if isfile(hashImgPth) == False:
|
if isfile(hashImgPth) == False:
|
||||||
self.generateVideoThumbnail(fullPath, hashImgPth)
|
self.generateVideoThumbnail(fullPath, hashImgPth)
|
||||||
|
|
||||||
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
|
thumbnl = self.createScaledImage(hashImgPth, self.viIconWH)
|
||||||
# Image Icon
|
# Image Icon
|
||||||
elif file.lower().endswith(self.imagesList):
|
elif file.lower().endswith(self.imagesList):
|
||||||
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
|
thumbnl = self.createScaledImage(fullPath, self.viIconWH)
|
||||||
# .desktop file parsing
|
# .desktop file parsing
|
||||||
elif fullPath.lower().endswith( ('.desktop',) ):
|
elif fullPath.lower().endswith( ('.desktop',) ):
|
||||||
thumbnl = self.parseDesktopFiles(fullPath)
|
thumbnl = self.parseDesktopFiles(fullPath)
|
||||||
# System icons
|
# System icons
|
||||||
else:
|
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...
|
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
|
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
|
return thumbnl
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user