Changed out certain variable names for more generic approach
This commit is contained in:
parent
634de3f6b0
commit
d0d316bb87
Binary file not shown.
@ -31,13 +31,13 @@
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="center">
|
||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<object class="GtkFileChooserButton" id="selectDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="title" translatable="yes">Directory Chooser</property>
|
||||
<signal name="file-set" handler="setIconViewDir" swapped="no"/>
|
||||
<signal name="file-set" handler="setNewDirectory" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -14,32 +14,31 @@ class GridSignals:
|
||||
self.filehandler = FileHandler(settings)
|
||||
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.desktop = self.builder.get_object("Desktop")
|
||||
selectedDirDialog = self.builder.get_object("selectedDirDialog")
|
||||
self.gridObj = self.builder.get_object("Desktop")
|
||||
selectDirDialog = self.builder.get_object("selectDirDialog")
|
||||
filefilter = self.builder.get_object("Folders")
|
||||
|
||||
self.desktopPath = self.settings.returnDesktopPath()
|
||||
self.currentPath = self.settings.returnDesktopPath()
|
||||
self.copyCutArry = []
|
||||
self.selectedFiles = []
|
||||
self.grid = None
|
||||
self.currentPath = ""
|
||||
self.gridClss = None
|
||||
self.pasteType = 1 # copy == 1 and cut == 2
|
||||
|
||||
# Add filter to allow only folders to be selected
|
||||
selectedDirDialog.add_filter(filefilter)
|
||||
selectedDirDialog.set_filename(self.desktopPath)
|
||||
self.setIconViewDir(selectedDirDialog)
|
||||
selectDirDialog.add_filter(filefilter)
|
||||
selectDirDialog.set_filename(self.currentPath)
|
||||
self.setNewDirectory(selectDirDialog)
|
||||
|
||||
|
||||
def setIconViewDir(self, widget, data=None):
|
||||
def setNewDirectory(self, widget, data=None):
|
||||
newPath = widget.get_filename()
|
||||
self.grid = Grid(self.desktop, self.settings)
|
||||
self.grid.setIconViewDir(newPath)
|
||||
self.gridClss = Grid(self.gridObj, self.settings)
|
||||
self.gridClss.setNewDirectory(newPath)
|
||||
|
||||
|
||||
# File control events
|
||||
def create(self, wdget):
|
||||
self.currentPath = self.grid.returnCurrentPath()
|
||||
self.currentPath = self.gridClss.returnCurrentPath()
|
||||
fileName = self.builder.get_object("filenameInput").get_text().strip()
|
||||
type = self.builder.get_object("createSwitch").get_state()
|
||||
|
||||
@ -47,22 +46,22 @@ class GridSignals:
|
||||
fileName = self.currentPath + "/" + fileName
|
||||
status = self.filehandler.create(fileName, type)
|
||||
if status == 0:
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
self.gridClss.setNewDirectory(self.currentPath)
|
||||
|
||||
def copy(self, widget):
|
||||
self.pasteType = 1
|
||||
self.copyCutArry = self.grid.returnSelectedFiles()
|
||||
self.copyCutArry = self.gridClss.returnSelectedFiles()
|
||||
|
||||
def cut(self, widget):
|
||||
self.pasteType = 2
|
||||
self.copyCutArry = self.grid.returnSelectedFiles()
|
||||
self.copyCutArry = self.gridClss.returnSelectedFiles()
|
||||
|
||||
def paste(self, widget):
|
||||
self.currentPath = self.grid.returnCurrentPath()
|
||||
self.currentPath = self.gridClss.returnCurrentPath()
|
||||
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
|
||||
|
||||
if status == 0:
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
self.gridClss.setNewDirectory(self.currentPath)
|
||||
if self.pasteType == 2: # cut == 2
|
||||
self.copyCutArry = []
|
||||
|
||||
@ -72,7 +71,7 @@ class GridSignals:
|
||||
|
||||
if status == 0:
|
||||
self.selectedFiles = []
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
self.gridClss.setNewDirectory(self.currentPath)
|
||||
|
||||
def trash(self, widget):
|
||||
self.getGridInfo()
|
||||
@ -80,7 +79,7 @@ class GridSignals:
|
||||
|
||||
if status == 0:
|
||||
self.selectedFiles = []
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
self.gridClss.setNewDirectory(self.currentPath)
|
||||
|
||||
def rename(self, widget, data):
|
||||
if data.keyval == 65293: # Enter key press
|
||||
@ -94,8 +93,8 @@ class GridSignals:
|
||||
status = self.filehandler.rename(self.selectedFiles[0], newName.strip())
|
||||
if status == 0:
|
||||
self.selectedFiles = [newName]
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
self.gridClss.setNewDirectory(self.currentPath)
|
||||
|
||||
def getGridInfo(self):
|
||||
self.selectedFiles = self.grid.returnSelectedFiles()
|
||||
self.currentPath = self.grid.returnCurrentPath()
|
||||
self.selectedFiles = self.gridClss.returnSelectedFiles()
|
||||
self.currentPath = self.gridClss.returnCurrentPath()
|
||||
|
@ -24,8 +24,8 @@ def threaded(fn):
|
||||
return wrapper
|
||||
|
||||
class Grid:
|
||||
def __init__(self, desktop, settings):
|
||||
self.desktop = desktop
|
||||
def __init__(self, grid, settings):
|
||||
self.grid = grid
|
||||
self.settings = settings
|
||||
self.fileHandler = FileHandler(self.settings)
|
||||
|
||||
@ -33,8 +33,9 @@ class Grid:
|
||||
self.usrHome = settings.returnUserHome()
|
||||
self.builder = settings.returnBuilder()
|
||||
self.ColumnSize = settings.returnColumnSize()
|
||||
self.vidsList = settings.returnVidsFilter()
|
||||
self.imagesList = settings.returnImagesFilter()
|
||||
self.vidsFilter = settings.returnVidsFilter()
|
||||
self.imagesFilter = settings.returnImagesFilter()
|
||||
self.iconFactory = Icon(settings)
|
||||
self.gtkLock = False # Thread checks for gtkLock
|
||||
self.threadLock = False # Gtk checks for thread lock
|
||||
self.helperThread = None # Helper thread object
|
||||
@ -42,14 +43,14 @@ class Grid:
|
||||
self.selectedFiles = []
|
||||
self.currentPath = ""
|
||||
|
||||
self.desktop.set_model(self.store)
|
||||
self.desktop.set_pixbuf_column(0)
|
||||
self.desktop.set_text_column(1)
|
||||
self.desktop.connect("item-activated", self.iconDblLeftClick)
|
||||
self.desktop.connect("button_release_event", self.iconSingleClick, (self.desktop,))
|
||||
self.grid.set_model(self.store)
|
||||
self.grid.set_pixbuf_column(0)
|
||||
self.grid.set_text_column(1)
|
||||
self.grid.connect("item-activated", self.iconDblLeftClick)
|
||||
self.grid.connect("button_release_event", self.iconSingleClick, (self.grid,))
|
||||
|
||||
|
||||
def setIconViewDir(self, path):
|
||||
def setNewDirectory(self, path):
|
||||
self.store.clear()
|
||||
|
||||
self.currentPath = path
|
||||
@ -65,9 +66,9 @@ class Grid:
|
||||
if f.startswith('.'):
|
||||
continue
|
||||
if isfile(file):
|
||||
if file.lower().endswith(self.vidsList):
|
||||
if file.lower().endswith(self.vidsFilter):
|
||||
vids.append(f)
|
||||
elif file.lower().endswith(self.imagesList):
|
||||
elif file.lower().endswith(self.imagesFilter):
|
||||
images.append(f)
|
||||
elif file.lower().endswith((".desktop",)):
|
||||
desktop.append(f)
|
||||
@ -89,19 +90,19 @@ class Grid:
|
||||
|
||||
# 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
|
||||
self.helperThread = threading.Thread(target=self.generateGridIcon, args=(path, files)).start()
|
||||
glib.idle_add(self.addToGrid, (file,)) # NOTE: 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 generateDirectoryGridIcon(self, dirPath, files):
|
||||
def generateGridIcon(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)
|
||||
image = self.iconFactory.createIcon(dirPath, file)
|
||||
self.toWorkPool.append([image.get_pixbuf(), file])
|
||||
self.threadLock = False
|
||||
self.gtkLock = True
|
||||
@ -138,14 +139,14 @@ class Grid:
|
||||
file = dir + "/" + fileName
|
||||
|
||||
if fileName == ".":
|
||||
self.setIconViewDir(dir)
|
||||
self.setNewDirectory(dir)
|
||||
elif fileName == "..":
|
||||
parentDir = os.path.abspath(os.path.join(dir, os.pardir))
|
||||
self.currentPath = parentDir
|
||||
self.setIconViewDir(parentDir)
|
||||
self.setNewDirectory(parentDir)
|
||||
elif isdir(file):
|
||||
self.currentPath = file
|
||||
self.setIconViewDir(self.currentPath)
|
||||
self.setNewDirectory(self.currentPath)
|
||||
elif isfile(file):
|
||||
self.fileHandler.openFile(file)
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user