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/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
<child type="center">
|
<child type="center">
|
||||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
<object class="GtkFileChooserButton" id="selectDirDialog">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="action">select-folder</property>
|
<property name="action">select-folder</property>
|
||||||
<property name="filter">Folders</property>
|
<property name="filter">Folders</property>
|
||||||
<property name="title" translatable="yes">Directory Chooser</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -10,59 +10,58 @@ from utils import FileHandler
|
|||||||
|
|
||||||
class GridSignals:
|
class GridSignals:
|
||||||
def __init__(self, settings):
|
def __init__(self, settings):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.filehandler = FileHandler(settings)
|
self.filehandler = FileHandler(settings)
|
||||||
|
|
||||||
self.builder = self.settings.returnBuilder()
|
self.builder = self.settings.returnBuilder()
|
||||||
self.desktop = self.builder.get_object("Desktop")
|
self.gridObj = self.builder.get_object("Desktop")
|
||||||
selectedDirDialog = self.builder.get_object("selectedDirDialog")
|
selectDirDialog = self.builder.get_object("selectDirDialog")
|
||||||
filefilter = self.builder.get_object("Folders")
|
filefilter = self.builder.get_object("Folders")
|
||||||
|
|
||||||
self.desktopPath = self.settings.returnDesktopPath()
|
self.currentPath = self.settings.returnDesktopPath()
|
||||||
self.copyCutArry = []
|
self.copyCutArry = []
|
||||||
self.selectedFiles = []
|
self.selectedFiles = []
|
||||||
self.grid = None
|
self.gridClss = None
|
||||||
self.currentPath = ""
|
|
||||||
self.pasteType = 1 # copy == 1 and cut == 2
|
self.pasteType = 1 # copy == 1 and cut == 2
|
||||||
|
|
||||||
# Add filter to allow only folders to be selected
|
# Add filter to allow only folders to be selected
|
||||||
selectedDirDialog.add_filter(filefilter)
|
selectDirDialog.add_filter(filefilter)
|
||||||
selectedDirDialog.set_filename(self.desktopPath)
|
selectDirDialog.set_filename(self.currentPath)
|
||||||
self.setIconViewDir(selectedDirDialog)
|
self.setNewDirectory(selectDirDialog)
|
||||||
|
|
||||||
|
|
||||||
def setIconViewDir(self, widget, data=None):
|
def setNewDirectory(self, widget, data=None):
|
||||||
newPath = widget.get_filename()
|
newPath = widget.get_filename()
|
||||||
self.grid = Grid(self.desktop, self.settings)
|
self.gridClss = Grid(self.gridObj, self.settings)
|
||||||
self.grid.setIconViewDir(newPath)
|
self.gridClss.setNewDirectory(newPath)
|
||||||
|
|
||||||
|
|
||||||
# File control events
|
# File control events
|
||||||
def create(self, wdget):
|
def create(self, wdget):
|
||||||
self.currentPath = self.grid.returnCurrentPath()
|
self.currentPath = self.gridClss.returnCurrentPath()
|
||||||
fileName = self.builder.get_object("filenameInput").get_text().strip()
|
fileName = self.builder.get_object("filenameInput").get_text().strip()
|
||||||
type = self.builder.get_object("createSwitch").get_state()
|
type = self.builder.get_object("createSwitch").get_state()
|
||||||
|
|
||||||
if fileName != "":
|
if fileName != "":
|
||||||
fileName = self.currentPath + "/" + fileName
|
fileName = self.currentPath + "/" + fileName
|
||||||
status = self.filehandler.create(fileName, type)
|
status = self.filehandler.create(fileName, type)
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.gridClss.setNewDirectory(self.currentPath)
|
||||||
|
|
||||||
def copy(self, widget):
|
def copy(self, widget):
|
||||||
self.pasteType = 1
|
self.pasteType = 1
|
||||||
self.copyCutArry = self.grid.returnSelectedFiles()
|
self.copyCutArry = self.gridClss.returnSelectedFiles()
|
||||||
|
|
||||||
def cut(self, widget):
|
def cut(self, widget):
|
||||||
self.pasteType = 2
|
self.pasteType = 2
|
||||||
self.copyCutArry = self.grid.returnSelectedFiles()
|
self.copyCutArry = self.gridClss.returnSelectedFiles()
|
||||||
|
|
||||||
def paste(self, widget):
|
def paste(self, widget):
|
||||||
self.currentPath = self.grid.returnCurrentPath()
|
self.currentPath = self.gridClss.returnCurrentPath()
|
||||||
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
|
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.gridClss.setNewDirectory(self.currentPath)
|
||||||
if self.pasteType == 2: # cut == 2
|
if self.pasteType == 2: # cut == 2
|
||||||
self.copyCutArry = []
|
self.copyCutArry = []
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ class GridSignals:
|
|||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFiles = []
|
self.selectedFiles = []
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.gridClss.setNewDirectory(self.currentPath)
|
||||||
|
|
||||||
def trash(self, widget):
|
def trash(self, widget):
|
||||||
self.getGridInfo()
|
self.getGridInfo()
|
||||||
@ -80,7 +79,7 @@ class GridSignals:
|
|||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFiles = []
|
self.selectedFiles = []
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.gridClss.setNewDirectory(self.currentPath)
|
||||||
|
|
||||||
def rename(self, widget, data):
|
def rename(self, widget, data):
|
||||||
if data.keyval == 65293: # Enter key press
|
if data.keyval == 65293: # Enter key press
|
||||||
@ -94,8 +93,8 @@ class GridSignals:
|
|||||||
status = self.filehandler.rename(self.selectedFiles[0], newName.strip())
|
status = self.filehandler.rename(self.selectedFiles[0], newName.strip())
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFiles = [newName]
|
self.selectedFiles = [newName]
|
||||||
self.grid.setIconViewDir(self.currentPath)
|
self.gridClss.setNewDirectory(self.currentPath)
|
||||||
|
|
||||||
def getGridInfo(self):
|
def getGridInfo(self):
|
||||||
self.selectedFiles = self.grid.returnSelectedFiles()
|
self.selectedFiles = self.gridClss.returnSelectedFiles()
|
||||||
self.currentPath = self.grid.returnCurrentPath()
|
self.currentPath = self.gridClss.returnCurrentPath()
|
||||||
|
@ -24,8 +24,8 @@ def threaded(fn):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
class Grid:
|
class Grid:
|
||||||
def __init__(self, desktop, settings):
|
def __init__(self, grid, settings):
|
||||||
self.desktop = desktop
|
self.grid = grid
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.fileHandler = FileHandler(self.settings)
|
self.fileHandler = FileHandler(self.settings)
|
||||||
|
|
||||||
@ -33,8 +33,9 @@ class Grid:
|
|||||||
self.usrHome = settings.returnUserHome()
|
self.usrHome = settings.returnUserHome()
|
||||||
self.builder = settings.returnBuilder()
|
self.builder = settings.returnBuilder()
|
||||||
self.ColumnSize = settings.returnColumnSize()
|
self.ColumnSize = settings.returnColumnSize()
|
||||||
self.vidsList = settings.returnVidsFilter()
|
self.vidsFilter = settings.returnVidsFilter()
|
||||||
self.imagesList = settings.returnImagesFilter()
|
self.imagesFilter = settings.returnImagesFilter()
|
||||||
|
self.iconFactory = Icon(settings)
|
||||||
self.gtkLock = False # Thread checks for gtkLock
|
self.gtkLock = False # Thread checks for gtkLock
|
||||||
self.threadLock = False # Gtk checks for thread lock
|
self.threadLock = False # Gtk checks for thread lock
|
||||||
self.helperThread = None # Helper thread object
|
self.helperThread = None # Helper thread object
|
||||||
@ -42,14 +43,14 @@ class Grid:
|
|||||||
self.selectedFiles = []
|
self.selectedFiles = []
|
||||||
self.currentPath = ""
|
self.currentPath = ""
|
||||||
|
|
||||||
self.desktop.set_model(self.store)
|
self.grid.set_model(self.store)
|
||||||
self.desktop.set_pixbuf_column(0)
|
self.grid.set_pixbuf_column(0)
|
||||||
self.desktop.set_text_column(1)
|
self.grid.set_text_column(1)
|
||||||
self.desktop.connect("item-activated", self.iconDblLeftClick)
|
self.grid.connect("item-activated", self.iconDblLeftClick)
|
||||||
self.desktop.connect("button_release_event", self.iconSingleClick, (self.desktop,))
|
self.grid.connect("button_release_event", self.iconSingleClick, (self.grid,))
|
||||||
|
|
||||||
|
|
||||||
def setIconViewDir(self, path):
|
def setNewDirectory(self, path):
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
|
|
||||||
self.currentPath = path
|
self.currentPath = path
|
||||||
@ -65,9 +66,9 @@ class Grid:
|
|||||||
if f.startswith('.'):
|
if f.startswith('.'):
|
||||||
continue
|
continue
|
||||||
if isfile(file):
|
if isfile(file):
|
||||||
if file.lower().endswith(self.vidsList):
|
if file.lower().endswith(self.vidsFilter):
|
||||||
vids.append(f)
|
vids.append(f)
|
||||||
elif file.lower().endswith(self.imagesList):
|
elif file.lower().endswith(self.imagesFilter):
|
||||||
images.append(f)
|
images.append(f)
|
||||||
elif file.lower().endswith((".desktop",)):
|
elif file.lower().endswith((".desktop",)):
|
||||||
desktop.append(f)
|
desktop.append(f)
|
||||||
@ -89,19 +90,19 @@ class Grid:
|
|||||||
|
|
||||||
# Run helper thread...
|
# Run helper thread...
|
||||||
self.threadLock = True
|
self.threadLock = True
|
||||||
self.helperThread = threading.Thread(target=self.generateDirectoryGridIcon, args=(path, files)).start()
|
self.helperThread = threading.Thread(target=self.generateGridIcon, args=(path, files)).start()
|
||||||
glib.idle_add(self.addToGrid, (file,)) # This must stay in the main thread b/c
|
glib.idle_add(self.addToGrid, (file,)) # NOTE: This must stay in the main thread b/c
|
||||||
# gtk isn't thread safe/aware So, we
|
# gtk isn't thread safe/aware So, we
|
||||||
# make a sad lil thread hot potato 'game'
|
# make a sad lil thread hot potato 'game'
|
||||||
# out of this process.
|
# out of this process.
|
||||||
|
|
||||||
|
|
||||||
# @threaded
|
# @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
|
# 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
|
# universaly usable. We can just remove get_pixbuf to get a gtk.Image type
|
||||||
for file in files:
|
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.toWorkPool.append([image.get_pixbuf(), file])
|
||||||
self.threadLock = False
|
self.threadLock = False
|
||||||
self.gtkLock = True
|
self.gtkLock = True
|
||||||
@ -138,14 +139,14 @@ class Grid:
|
|||||||
file = dir + "/" + fileName
|
file = dir + "/" + fileName
|
||||||
|
|
||||||
if fileName == ".":
|
if fileName == ".":
|
||||||
self.setIconViewDir(dir)
|
self.setNewDirectory(dir)
|
||||||
elif fileName == "..":
|
elif fileName == "..":
|
||||||
parentDir = os.path.abspath(os.path.join(dir, os.pardir))
|
parentDir = os.path.abspath(os.path.join(dir, os.pardir))
|
||||||
self.currentPath = parentDir
|
self.currentPath = parentDir
|
||||||
self.setIconViewDir(parentDir)
|
self.setNewDirectory(parentDir)
|
||||||
elif isdir(file):
|
elif isdir(file):
|
||||||
self.currentPath = file
|
self.currentPath = file
|
||||||
self.setIconViewDir(self.currentPath)
|
self.setNewDirectory(self.currentPath)
|
||||||
elif isfile(file):
|
elif isfile(file):
|
||||||
self.fileHandler.openFile(file)
|
self.fileHandler.openFile(file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user