mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 12:12:31 +01:00
feat: delete shortcut
This commit is contained in:
1 parent
96b91fd87c
commit
dfeafc3d28
2 files changed
+20
-16
No files matched your search
@@ -161,9 +161,10 @@ class Shortcuts:
|
|||||||
return NEW_ENTRY
|
return NEW_ENTRY
|
||||||
|
|
||||||
def delete_shortcut(self, start_path: Path) -> None:
|
def delete_shortcut(self, start_path: Path) -> None:
|
||||||
for s in self.shortcuts["shortcuts"]:
|
shortcuts = self.shortcuts["shortcuts"]
|
||||||
if self.shortcuts[s]["StartDir"] == str(start_path):
|
for s in shortcuts:
|
||||||
del self.shortcuts[s]
|
if shortcuts[s]["StartDir"] == str(start_path):
|
||||||
|
del shortcuts[s]
|
||||||
break
|
break
|
||||||
self.save_shortcuts()
|
self.save_shortcuts()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -9,6 +10,7 @@ from dzgui.const.constants import APP_NAME
|
|||||||
from dzgui.strings import uninstall
|
from dzgui.strings import uninstall
|
||||||
from dzgui.util._json import read_json
|
from dzgui.util._json import read_json
|
||||||
from dzgui.util.css import load_css
|
from dzgui.util.css import load_css
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.views.components.box import HBox
|
from dzgui.views.components.box import HBox
|
||||||
from dzgui.views.dialogs.wizard import ScrolledWizardPage, CheckboxWithLabel
|
from dzgui.views.dialogs.wizard import ScrolledWizardPage, CheckboxWithLabel
|
||||||
|
|
||||||
@@ -179,27 +181,29 @@ class UninstallPage(ScrolledWizardPage):
|
|||||||
self.steam_path = Path(steam)
|
self.steam_path = Path(steam)
|
||||||
return Path(steam)
|
return Path(steam)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(format_exception(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def wipe_conf_file(self, box: CheckboxWithPath) -> None:
|
def wipe_conf_file(self, box: CheckboxWithPath) -> None:
|
||||||
if box.get_active():
|
if box.get_active():
|
||||||
path = box.get_conf_path()
|
path = box.get_conf_path()
|
||||||
try:
|
try:
|
||||||
# TODO:
|
if path.is_dir():
|
||||||
# path.unlink()
|
shutil.rmtree(path)
|
||||||
|
else:
|
||||||
|
path.unlink()
|
||||||
print(f"Deleted '{path}'")
|
print(f"Deleted '{path}'")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(format_exception(e))
|
||||||
|
|
||||||
def wipe_steam_shortcut(self) -> None:
|
def wipe_steam_shortcut(self) -> None:
|
||||||
# TODO:
|
if self.steam_path is None:
|
||||||
pass
|
return
|
||||||
# try:
|
try:
|
||||||
# shortcuts = Shortcuts(self.steam_path)
|
shortcuts = Shortcuts(self.steam_path)
|
||||||
# shortcuts.delete_shortcut(self.share)
|
shortcuts.delete_shortcut(self.share)
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# print(e)
|
print(format_exception(e))
|
||||||
|
|
||||||
def wipe_pyapp(self) -> None:
|
def wipe_pyapp(self) -> None:
|
||||||
if self.pyapp is None:
|
if self.pyapp is None:
|
||||||
@@ -212,8 +216,7 @@ class UninstallPage(ScrolledWizardPage):
|
|||||||
self.wipe_conf_file(box)
|
self.wipe_conf_file(box)
|
||||||
if self.steam_box.get_active():
|
if self.steam_box.get_active():
|
||||||
self.wipe_steam_shortcut()
|
self.wipe_steam_shortcut()
|
||||||
# TODO:
|
self.wipe_pyapp()
|
||||||
# self.wipe_pyapp()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user