Completed delete and rename actions.
This commit is contained in:
parent
7fa8d2081e
commit
36d45d1bdf
Binary file not shown.
@ -31,9 +31,7 @@ class Events:
|
|||||||
selectedDirDialog.add_filter(filefilter)
|
selectedDirDialog.add_filter(filefilter)
|
||||||
selectedDirDialog.set_filename(self.desktopPath)
|
selectedDirDialog.set_filename(self.desktopPath)
|
||||||
|
|
||||||
self.grid = None
|
self.grid = None
|
||||||
self.selectedFile = None
|
|
||||||
|
|
||||||
self.setDir(selectedDirDialog)
|
self.setDir(selectedDirDialog)
|
||||||
|
|
||||||
|
|
||||||
@ -44,19 +42,21 @@ class Events:
|
|||||||
# Grid(self.desktop, self.settings).generateDirectoryGrid(newPath)
|
# Grid(self.desktop, self.settings).generateDirectoryGrid(newPath)
|
||||||
|
|
||||||
def showGridControlMenu(self, widget, data=None):
|
def showGridControlMenu(self, widget, data=None):
|
||||||
self.selectedFile = widget
|
|
||||||
popover = self.builder.get_object("gridControlMenu")
|
popover = self.builder.get_object("gridControlMenu")
|
||||||
popover.show_all()
|
popover.show_all()
|
||||||
popover.popup()
|
popover.popup()
|
||||||
|
|
||||||
|
|
||||||
# File control events
|
# File control events
|
||||||
def renameFile(self, widget, data=None):
|
def createFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, widget, data=None):
|
||||||
newName = widget.get_text().strip()
|
newName = widget.get_text().strip()
|
||||||
if data and data.keyval == 65293: # Enter key event
|
if data and data.keyval == 65293: # Enter key event
|
||||||
self.grid.renameFile(newName)
|
self.grid.updateFile(newName)
|
||||||
elif data == None: # Save button 'event'
|
elif data == None: # Save button 'event'
|
||||||
self.grid.renameFile(newName)
|
self.grid.updateFile(newName)
|
||||||
|
|
||||||
def deleteFile(self, widget, data=None):
|
def deleteFile(self, widget, data=None):
|
||||||
self.grid.deleteFile()
|
self.grid.deleteFile()
|
||||||
@ -67,6 +67,9 @@ class Events:
|
|||||||
def cutFile(self):
|
def cutFile(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Webview events
|
# Webview events
|
||||||
def showWebview(self, widget):
|
def showWebview(self, widget):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import subprocess
|
import os, shutil, subprocess
|
||||||
|
|
||||||
|
|
||||||
class FileHandler:
|
class FileHandler:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -23,9 +22,6 @@ class FileHandler:
|
|||||||
self.MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
self.MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
||||||
self.MPV_WH = " -geometry 50%:50% ";
|
self.MPV_WH = " -geometry 50%:50% ";
|
||||||
|
|
||||||
self.selectedFile = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def openFile(self, file):
|
def openFile(self, file):
|
||||||
print("Opening: " + file)
|
print("Opening: " + file)
|
||||||
@ -45,10 +41,14 @@ class FileHandler:
|
|||||||
subprocess.Popen(['xdg-open', file])
|
subprocess.Popen(['xdg-open', file])
|
||||||
|
|
||||||
|
|
||||||
def renameFile(self, oldFileName, newFileName):
|
def createFile(self, newFileName):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, oldFileName, newFileName):
|
||||||
try:
|
try:
|
||||||
print("Renaming...")
|
print("Renaming...")
|
||||||
print(oldFileName + " --> " + newFileName)
|
print(oldFileName + " --> " + newFileName)
|
||||||
|
os.rename(oldFileName, newFileName)
|
||||||
return 0
|
return 0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured renaming the file:")
|
print("An error occured renaming the file:")
|
||||||
@ -59,8 +59,29 @@ class FileHandler:
|
|||||||
try:
|
try:
|
||||||
print("Deleting...")
|
print("Deleting...")
|
||||||
print(toDeleteFile)
|
print(toDeleteFile)
|
||||||
return 0
|
if os.path.exists(toDeleteFile):
|
||||||
|
if os.path.isfile(toDeleteFile):
|
||||||
|
os.remove(toDeleteFile)
|
||||||
|
elif os.path.isdir(toDeleteFile):
|
||||||
|
shutil.rmtree(toDeleteFile)
|
||||||
|
else:
|
||||||
|
print("An error occured deleting the file:")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("The folder/file does not exist")
|
||||||
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured deleting the file:")
|
print("An error occured deleting the file:")
|
||||||
print(e)
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def copyFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cutFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
@ -155,18 +155,29 @@ class Grid:
|
|||||||
|
|
||||||
|
|
||||||
# Pass through file control events
|
# Pass through file control events
|
||||||
def renameFile(self, file):
|
def createFile(arg):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, file):
|
||||||
newName = self.currentPath + "/" + file
|
newName = self.currentPath + "/" + file
|
||||||
status = self.filehandler.renameFile(self.selectedFile, newName)
|
status = self.filehandler.updateFile(self.selectedFile, newName)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFile = newName
|
self.selectedFile = newName
|
||||||
self.generateDirectoryGrid(self.currentPath)
|
self.generateDirectoryGrid(self.currentPath)
|
||||||
|
|
||||||
|
|
||||||
def deleteFile(self):
|
def deleteFile(self):
|
||||||
status = self.filehandler.deleteFile(self.selectedFile)
|
status = self.filehandler.deleteFile(self.selectedFile)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFile = ""
|
self.selectedFile = ""
|
||||||
self.generateDirectoryGrid(self.currentPath)
|
self.generateDirectoryGrid(self.currentPath)
|
||||||
|
|
||||||
|
def copyFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cutFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
@ -31,9 +31,7 @@ class Events:
|
|||||||
selectedDirDialog.add_filter(filefilter)
|
selectedDirDialog.add_filter(filefilter)
|
||||||
selectedDirDialog.set_filename(self.desktopPath)
|
selectedDirDialog.set_filename(self.desktopPath)
|
||||||
|
|
||||||
self.grid = None
|
self.grid = None
|
||||||
self.selectedFile = None
|
|
||||||
|
|
||||||
self.setDir(selectedDirDialog)
|
self.setDir(selectedDirDialog)
|
||||||
|
|
||||||
|
|
||||||
@ -44,19 +42,21 @@ class Events:
|
|||||||
# Grid(self.desktop, self.settings).generateDirectoryGrid(newPath)
|
# Grid(self.desktop, self.settings).generateDirectoryGrid(newPath)
|
||||||
|
|
||||||
def showGridControlMenu(self, widget, data=None):
|
def showGridControlMenu(self, widget, data=None):
|
||||||
self.selectedFile = widget
|
|
||||||
popover = self.builder.get_object("gridControlMenu")
|
popover = self.builder.get_object("gridControlMenu")
|
||||||
popover.show_all()
|
popover.show_all()
|
||||||
popover.popup()
|
popover.popup()
|
||||||
|
|
||||||
|
|
||||||
# File control events
|
# File control events
|
||||||
def renameFile(self, widget, data=None):
|
def createFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, widget, data=None):
|
||||||
newName = widget.get_text().strip()
|
newName = widget.get_text().strip()
|
||||||
if data and data.keyval == 65293: # Enter key event
|
if data and data.keyval == 65293: # Enter key event
|
||||||
self.grid.renameFile(newName)
|
self.grid.updateFile(newName)
|
||||||
elif data == None: # Save button 'event'
|
elif data == None: # Save button 'event'
|
||||||
self.grid.renameFile(newName)
|
self.grid.updateFile(newName)
|
||||||
|
|
||||||
def deleteFile(self, widget, data=None):
|
def deleteFile(self, widget, data=None):
|
||||||
self.grid.deleteFile()
|
self.grid.deleteFile()
|
||||||
@ -67,6 +67,9 @@ class Events:
|
|||||||
def cutFile(self):
|
def cutFile(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Webview events
|
# Webview events
|
||||||
def showWebview(self, widget):
|
def showWebview(self, widget):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import subprocess
|
import os, shutil, subprocess
|
||||||
|
|
||||||
|
|
||||||
class FileHandler:
|
class FileHandler:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -23,9 +22,6 @@ class FileHandler:
|
|||||||
self.MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
self.MPLAYER_WH = " -xy 1600 -geometry 50%:50% ";
|
||||||
self.MPV_WH = " -geometry 50%:50% ";
|
self.MPV_WH = " -geometry 50%:50% ";
|
||||||
|
|
||||||
self.selectedFile = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def openFile(self, file):
|
def openFile(self, file):
|
||||||
print("Opening: " + file)
|
print("Opening: " + file)
|
||||||
@ -45,10 +41,14 @@ class FileHandler:
|
|||||||
subprocess.Popen(['xdg-open', file])
|
subprocess.Popen(['xdg-open', file])
|
||||||
|
|
||||||
|
|
||||||
def renameFile(self, oldFileName, newFileName):
|
def createFile(self, newFileName):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, oldFileName, newFileName):
|
||||||
try:
|
try:
|
||||||
print("Renaming...")
|
print("Renaming...")
|
||||||
print(oldFileName + " --> " + newFileName)
|
print(oldFileName + " --> " + newFileName)
|
||||||
|
os.rename(oldFileName, newFileName)
|
||||||
return 0
|
return 0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured renaming the file:")
|
print("An error occured renaming the file:")
|
||||||
@ -59,8 +59,29 @@ class FileHandler:
|
|||||||
try:
|
try:
|
||||||
print("Deleting...")
|
print("Deleting...")
|
||||||
print(toDeleteFile)
|
print(toDeleteFile)
|
||||||
return 0
|
if os.path.exists(toDeleteFile):
|
||||||
|
if os.path.isfile(toDeleteFile):
|
||||||
|
os.remove(toDeleteFile)
|
||||||
|
elif os.path.isdir(toDeleteFile):
|
||||||
|
shutil.rmtree(toDeleteFile)
|
||||||
|
else:
|
||||||
|
print("An error occured deleting the file:")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("The folder/file does not exist")
|
||||||
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occured deleting the file:")
|
print("An error occured deleting the file:")
|
||||||
print(e)
|
print(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def copyFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cutFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
@ -155,18 +155,29 @@ class Grid:
|
|||||||
|
|
||||||
|
|
||||||
# Pass through file control events
|
# Pass through file control events
|
||||||
def renameFile(self, file):
|
def createFile(arg):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updateFile(self, file):
|
||||||
newName = self.currentPath + "/" + file
|
newName = self.currentPath + "/" + file
|
||||||
status = self.filehandler.renameFile(self.selectedFile, newName)
|
status = self.filehandler.updateFile(self.selectedFile, newName)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFile = newName
|
self.selectedFile = newName
|
||||||
self.generateDirectoryGrid(self.currentPath)
|
self.generateDirectoryGrid(self.currentPath)
|
||||||
|
|
||||||
|
|
||||||
def deleteFile(self):
|
def deleteFile(self):
|
||||||
status = self.filehandler.deleteFile(self.selectedFile)
|
status = self.filehandler.deleteFile(self.selectedFile)
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
self.selectedFile = ""
|
self.selectedFile = ""
|
||||||
self.generateDirectoryGrid(self.currentPath)
|
self.generateDirectoryGrid(self.currentPath)
|
||||||
|
|
||||||
|
def copyFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cutFile(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def pasteFile(self):
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user