aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2026-01-05 19:23:31 +0100
committerPapoteur <papoteur@mageia.org>2026-01-05 19:24:48 +0100
commitab0865299d4f6ec01add49e3572b1c15f688bae2 (patch)
tree94bbaa485445074af0bd2e5911c6197eb92236ec /lib
parentb23a4001b2f601905556f67852404273bb88f85b (diff)
downloadisodumper-ab0865299d4f6ec01add49e3572b1c15f688bae2.tar
isodumper-ab0865299d4f6ec01add49e3572b1c15f688bae2.tar.gz
isodumper-ab0865299d4f6ec01add49e3572b1c15f688bae2.tar.bz2
isodumper-ab0865299d4f6ec01add49e3572b1c15f688bae2.tar.xz
isodumper-ab0865299d4f6ec01add49e3572b1c15f688bae2.zip
Add config file, for keeping the last directory used (mga#18267)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/isodumper.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 2ac7feb..0d9297f 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -42,6 +42,8 @@ import yui
import time
import os
+import xdg, xdg.BaseDirectory
+import configparser
import re
import gettext
from subprocess import Popen, PIPE
@@ -381,7 +383,7 @@ class IsoDumper(basedialog.BaseDialog):
def backup_choosed(self):
# Add .img if not specified
self.backup_img_name = yui.YUI.app().askForSaveFileName(
- "", "*.img", _("Backup to:")
+ self.last_dir, "*.img", _("Backup to:")
)
if self.backup_img_name != "":
if not self.backup_img_name.lower().endswith(".img"):
@@ -980,6 +982,17 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
If you say ok here, please <b>do not unplug</b>\
the device during the following operation."
)
+ # Read last path used for ISO images
+ config = configparser.ConfigParser()
+ self.xdg_home = xdg.BaseDirectory.xdg_config_home
+ config_file = os.path.join(self.xdg_home, 'isodumper.rc')
+ try:
+ config.read(config_file)
+ self.last_dir = config['General']['last_directory']
+ except (FileNotFoundError, KeyError):
+ self.last_dir = ""
+
+
"""
Init/Constructor for the 'widgets'
"""
@@ -1160,11 +1173,20 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
if "drives" in a.split("/"):
self.uEventQueue.put({"event": "device-changed", "value": True})
+ def save_last_dir(self, file_name):
+ config = configparser.ConfigParser()
+ config['General'] = {'last_directory': os.path.dirname(file_name)}
+ config_file = os.path.join(self.xdg_home, 'isodumper.rc')
+ with open(config_file, 'w') as f:
+ config.write(f)
+
def ask_image(self):
self.img_name = yui.YUI.app().askForExistingFile(
- "", "*.iso *.img", self.ChooseImage
+ self.last_dir, "*.iso *.img", self.ChooseImage
)
if self.img_name != "":
+ # save the directory
+ self.save_last_dir(self.img_name)
# Check if the image has a signed checksum
self.get_sum(self.img_name)
if self.signature_found: