Integrating trash option
This commit is contained in:
parent
55d2bc9cd1
commit
77872aca35
@ -82,6 +82,11 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="trashImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="pixbuf">icons/trash.png</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="iconControlsWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resizable">False</property>
|
||||
@ -98,7 +103,7 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
<property name="width_request">500</property>
|
||||
<property name="height_request">26</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
@ -121,6 +126,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Copy...</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="copy" swapped="no"/>
|
||||
@ -137,6 +143,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Cut...</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="cut" swapped="no"/>
|
||||
@ -153,6 +160,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Paste...</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="paste" swapped="no"/>
|
||||
@ -163,13 +171,29 @@
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Trash</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">trashImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="trashFiles" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">65</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="deleteFiles" swapped="no"/>
|
||||
@ -178,7 +202,7 @@
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
BIN
src/pytop-0.0.1/Pytop/resources/icons/trash.png
Normal file
BIN
src/pytop-0.0.1/Pytop/resources/icons/trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 989 B |
@ -56,6 +56,15 @@ class GridSignals:
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
|
||||
|
||||
def trashFiles(self, widget):
|
||||
self.getGridInfo()
|
||||
status = self.filehandler.moveToTrash(self.selectedFiles)
|
||||
|
||||
if status == 0:
|
||||
self.selectedFiles = []
|
||||
self.grid.setIconViewDir(self.currentPath)
|
||||
|
||||
|
||||
def deleteFiles(self, widget):
|
||||
self.getGridInfo()
|
||||
status = self.filehandler.deleteFiles(self.selectedFiles)
|
||||
|
@ -69,13 +69,32 @@ class FileHandler:
|
||||
print(e)
|
||||
return 1
|
||||
|
||||
def moveToTrash(arg):
|
||||
def dedupPathIter(self, toBeTrashPath):
|
||||
i = 0
|
||||
duplicateFix = ""
|
||||
|
||||
if os.path.exists(toBeTrashPath):
|
||||
while os.path.exists(toBeTrashPath + duplicateFix) == True:
|
||||
i+=1
|
||||
duplicateFix = "-" + str(i)
|
||||
|
||||
return duplicateFix
|
||||
|
||||
|
||||
def moveToTrash(self, toTrashFiles):
|
||||
try:
|
||||
print("Moving to Trash...")
|
||||
for file in toDeleteFiles:
|
||||
for file in toTrashFiles:
|
||||
print(file)
|
||||
if os.path.exists(file):
|
||||
shutil.move(file, self.TRASHFILESFOLDER)
|
||||
parts = file.split("/")
|
||||
toBeTrashPath = self.TRASHFILESFOLDER + parts[len(parts) - 1]
|
||||
finalForm = file + self.dedupPathIter(toBeTrashPath)
|
||||
|
||||
if finalForm != file:
|
||||
os.rename(file, finalForm)
|
||||
|
||||
shutil.move(finalForm, self.TRASHFILESFOLDER)
|
||||
else:
|
||||
print("The folder/file does not exist")
|
||||
return 1
|
||||
|
@ -110,7 +110,6 @@ class Settings:
|
||||
def returnSystemIconImageWH(self): return self.systemIconImageWxH
|
||||
def returnVIIconWH(self): return self.viIconWxH
|
||||
def isHideHiddenFiles(self): return self.hideHiddenFiles
|
||||
def returnImagesExtensionList(self): return self.imagesExtensionList
|
||||
|
||||
# Filter returns
|
||||
def returnOfficeFilter(self): return self.office
|
||||
|
@ -46,7 +46,7 @@ class Grid:
|
||||
self.desktop.set_pixbuf_column(0)
|
||||
self.desktop.set_text_column(1)
|
||||
self.desktop.connect("item-activated", self.iconDblLeftClick)
|
||||
self.desktop.connect("button_press_event", self.iconClickRight, (self.desktop,))
|
||||
self.desktop.connect("button_press_event", self.iconRightClick, (self.desktop,))
|
||||
|
||||
|
||||
def setIconViewDir(self, path):
|
||||
@ -151,7 +151,7 @@ class Grid:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def iconClickRight(self, widget, eve, rclicked_icon):
|
||||
def iconRightClick(self, widget, eve, rclicked_icon):
|
||||
try:
|
||||
if eve.type == gdk.EventType.BUTTON_PRESS and eve.button == 3:
|
||||
input = self.builder.get_object("iconRenameInput")
|
||||
|
Loading…
Reference in New Issue
Block a user