aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2021-05-29 22:10:39 +0200
committerPapoteur <papoteur@mageia.org>2021-05-30 19:03:22 +0200
commit88565bc8fa6e05a6baa3859a2e8b369109e519d7 (patch)
tree217e88b890a834a7f93ad866e1a323ba4875defa /lib
parentfdf6e5882cfac7d69cee73b7f1c7c3e1f4cab73f (diff)
downloadisodumper-88565bc8fa6e05a6baa3859a2e8b369109e519d7.tar
isodumper-88565bc8fa6e05a6baa3859a2e8b369109e519d7.tar.gz
isodumper-88565bc8fa6e05a6baa3859a2e8b369109e519d7.tar.bz2
isodumper-88565bc8fa6e05a6baa3859a2e8b369109e519d7.tar.xz
isodumper-88565bc8fa6e05a6baa3859a2e8b369109e519d7.zip
Improve activating/deactivating fields and buttons in the interface.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/isodumper.py132
1 files changed, 86 insertions, 46 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 62b7d94..b67b436 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -238,7 +238,6 @@ class IsoDumper(basedialog.BaseDialog):
self.ima.setLabel(self.ChooseImage)
self.backup_select.setLabel(self.ChooseImage)
self.dialog.recalcLayout()
- self.initial_state()
def update_list_on_event(self):
selitem = self.devicelist.selectedItem().label()
@@ -256,28 +255,40 @@ class IsoDumper(basedialog.BaseDialog):
selitem = self.devicelist.selectedItem()
if selitem is not None:
self.dev = selitem.label()
- for name, path, size in self.list:
- if self.dev.startswith(name + ' (' + path.lstrip()):
- self.deviceSize = size
- self.device_name = name.rstrip().replace(' ', '')
- message = _('Target Device: {}').format(self.dev)
- self.logger(message)
- logging.info(message)
- partitions = self.u.get_partitions(self.dev.split('(')[1].split(')')[0])
- #, verb in singular 3rd person
- self.logger(_("Contents partition(s)"))
- for partition in partitions:
- self.logger(_("{device}: Type={type}, Label={label}").format(device=partition['device'],
- type=partition['type'],
- label=partition['label'],))
- self.partition_cbox.setEnabled()
- self.partition_cbox.setChecked(False)
- self.backup_cbox.setEnabled()
- self.backup_cbox.setChecked(False)
- self.write_cbox.setEnabled()
- self.write_cbox.setChecked(False)
- self.cryptcb.setChecked(False)
+ if self.dev != "":
+ for name, path, size in self.list:
+ if self.dev.startswith(name + ' (' + path.lstrip()):
+ self.deviceSize = size
+ self.device_name = name.rstrip().replace(' ', '')
+ message = _('Target Device: {}').format(self.dev)
+ self.logger(message)
+ logging.info(message)
+ partitions = self.u.get_partitions(self.dev.split('(')[1].split(')')[0])
+ #, verb in singular 3rd person
+ self.logger(_("Contents partition(s)"))
+ for partition in partitions:
+ self.logger(_("{device}: Type={type}, Label={label}").format(device=partition['device'],
+ type=partition['type'],
+ label=partition['label'],))
+ if len(partitions) == 0:
+ #, None refers to partition (no partitions on the selected device)
+ self.logger(_("None"))
+ self.partition_cbox.setEnabled()
+ self.partition_cbox.setChecked(False)
+ self.backup_cbox.setEnabled()
+ self.backup_cbox.setChecked(False)
+ self.write_cbox.setEnabled()
+ self.write_cbox.setChecked(False)
+ self.cryptcb.setChecked(False)
break
+ else:
+ self.partition_cbox.setDisabled()
+ self.partition_cbox.setChecked(False)
+ self.backup_cbox.setDisabled()
+ self.backup_cbox.setChecked(False)
+ self.write_cbox.setDisabled()
+ self.write_cbox.setChecked(False)
+ self.cryptcb.setChecked(False)
@staticmethod
def sizeof_fmt(num):
@@ -298,7 +309,7 @@ class IsoDumper(basedialog.BaseDialog):
self.backup_dest = self.backup_img_name
self.backup_select.setLabel(tail)
self.dialog.recalcLayout()
- self.start_bt.setEnabled()
+ self.interface_active_state()
self.backup_is_selected = True
else:
self.backup_is_selected = False
@@ -386,10 +397,13 @@ class IsoDumper(basedialog.BaseDialog):
self.initial_state()
def initial_state(self):
+ self.update_list()
self.image_is_selected = False
self.backup_is_selected = False
self.backup_select.setDisabled()
self.backup_cbox.setDisabled()
+ self.backup_dest = ""
+ self.backup_select.setLabel(self.ChooseImage)
self.partition_cbox.setDisabled()
self.ima.setDisabled()
self.img_name = ""
@@ -400,12 +414,12 @@ class IsoDumper(basedialog.BaseDialog):
self.progress.setValue(0)
self.progress.setDisabled()
self.refreshbt.setEnabled()
- #self.persistencecb.setChecked(False)
- #self.persistencecb.setDisabled()
self.partition_cb.setDisabled()
self.partition_label.setDisabled()
+ self.partition_label.setValue("")
self.cryptcb.setDisabled()
self.cryptkey.setDisabled()
+ self.cryptkey.setValue("")
self.start_bt.setDisabled()
def raw_format(self, usb_path, fstype, label):
@@ -437,8 +451,6 @@ class IsoDumper(basedialog.BaseDialog):
def backup_go(self):
self.wip_unsensitive()
- self.devicelist.setDisabled()
- self.backup_select.setDisabled()
self.progress.setEnabled()
self.progress.setLabel("Backup")
dest = self.backup_img_name
@@ -455,6 +467,7 @@ class IsoDumper(basedialog.BaseDialog):
self.logger(message)
logging.warning(message)
self.emergency(message)
+ self.initial_state()
else:
self.operation = True
self.returncode = 0
@@ -488,9 +501,6 @@ class IsoDumper(basedialog.BaseDialog):
def do_write(self):
self.wip_unsensitive()
- #self.writebt.setDisabled()
- self.devicelist.setDisabled()
- self.backup_select.setDisabled()
self.progress.setEnabled()
self.progress.setLabel("Writing")
source = self.img_name
@@ -511,7 +521,6 @@ class IsoDumper(basedialog.BaseDialog):
pass
else:
return
- self.ima.setDisabled()
#: don't translate source or target
self.progress.setLabel(_('Writing {source} to {target}').format(source=source.split('/')[-1],
target=target.split('/')[-1]))
@@ -533,7 +542,7 @@ class IsoDumper(basedialog.BaseDialog):
success, message = self.iface.end()
if success:
#: don't translate source or target
- message = _('Image {source} successfully written to {target}').format(source=source.split('/')[-1],
+ message = _('Image {source} written to {target}').format(source=source.split('/')[-1],
target=target)
message += "\n" + _('Bytes written: {}').format(str(b))
self.logger(message)
@@ -554,7 +563,7 @@ class IsoDumper(basedialog.BaseDialog):
self.logger(message)
logging.info(message)
# Add persistent partition if asked
- if self.partition_cbox.isChecked() and self.partition_cb.value() == _("Persistent partition"):
+ if self.partition_cbox.isChecked() and self.partition_cb.value() == "ext4":
self.progress.setLabel(_("Adding persistent partition"))
self.progress.setValue(0)
if self.cryptcb.isChecked():
@@ -688,7 +697,7 @@ class IsoDumper(basedialog.BaseDialog):
def activate_devicelist(self):
self.devicelist.setEnabled()
- message = _('Image ') + ": " + self.img_name
+ message = _('ISO Image to copy: ') + self.img_name
self.logger(message)
logging.warning(message)
@@ -867,8 +876,6 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
self.helpbt.setStretchable(0, True)
self.quitbt = self.factory.createPushButton(self.buttonsbox, _("Quit"))
self.quitbt.setStretchable(0, True)
- # Set the initial state, active, disabled
- self.initial_state()
# Connect events
self.eventManager.addWidgetEvent(self.quitbt, self.confirm_close)
self.eventManager.addWidgetEvent(self.ima, self.ask_image)
@@ -897,7 +904,8 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
self.dialog.destroy()
yui.YUILoader.deleteUI()
exit()
- self.device_selected()
+ # Set the initial state, active, disabled
+ self.initial_state()
self.dialog.recalcLayout()
self.uEventQueue = SimpleQueue()
@@ -931,12 +939,14 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
if self.signature_found:
if not self.signature_checked:
info = Info(_("Warning"), True,
- _("The validation of the GPG signature failed !") + "\n" + _("Do you want to continue?"))
+ _("The validation of the GPG signature of the checksum file failed !") + "\n" + _("Do you want to continue?"))
if self.ask_YesOrNo(info):
pass
else:
self.img_name = ""
return
+ else:
+ self.logger(_("The checksum file is signed"))
else:
info = Info(_("Warning"), True,
_('No GPG signature has been found or the key is expired. Are you sure you want to use this image?'))
@@ -947,24 +957,56 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
return
self.ima.setLabel(os.path.basename(self.img_name))
self.dialog.recalcLayout()
- self.start_bt.setEnabled()
self.activate_devicelist()
self.image_is_selected = True
- #self.persistencecb.setEnabled()
else:
self.image_is_selected = False
+ self.interface_active_state()
+
+ def interface_active_state(self):
+ # Determine the state of the Execute button and others, if they can be active or not
+ if self.devicelist.selectedItem() is not None:
+ self.partition_cbox.setEnabled()
+ self.backup_cbox.setEnabled()
+ self.write_cbox.setEnabled()
+ else:
+ self.partition_cbox.setDisabled()
+ self.partition_cbox.setChecked(False)
+ self.backup_cbox.setDisabled()
+ self.backup_cbox.setChecked(False)
+ self.write_cbox.setDisabled()
+ self.write_cbox.setChecked(False)
+ self.cryptcb.setChecked(False)
+
+ backup_ready = self.backup_cbox.isChecked() and (self.backup_dest != "")
+ write_ready = self.write_cbox.isChecked() and (self.img_name != "")
+ partition_ready = self.partition_cbox.isChecked() and (self.partition_cb.value() == "ext4")
+ crypt_ready = self.cryptcb.isChecked() and (self.cryptkey.value() != "")
+ start_active = backup_ready or write_ready or partition_ready
+ if start_active:
+ self.start_bt.setEnabled()
+ else:
+ self.start_bt.setDisabled()
+ if partition_ready:
+ self.cryptcb.setEnabled()
+ else:
+ self.cryptcb.setDisabled()
+ self.cryptkey.setDisabled()
+
def select_backup(self):
if self.backup_cbox.isChecked():
self.backup_select.setEnabled()
else:
self.backup_select.setDisabled()
+ self.interface_active_state()
def select_write(self):
if self.write_cbox.isChecked():
self.ima.setEnabled()
else:
self.ima.setDisabled()
+ self.interface_active_state()
def select_partition(self):
if self.partition_cbox.isChecked():
@@ -973,8 +1015,7 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
else:
self.partition_cb.setDisabled()
self.partition_label.setDisabled()
- self.cryptcb.setDisabled()
- self.cryptkey.setDisabled()
+ self.interface_active_state()
def select_partition_type(self):
if self.partition_cb.value() in ("ext4" ,"Persistent partition"):
@@ -986,16 +1027,15 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
self.cryptcb.setDisabled()
self.cryptcb.setDisabled()
self.cryptkey.setDisabled()
- if self.partition_cb.value() != "":
- self.start_bt.setEnabled()
- else:
- self.start_bt.setDisabled()
+ self.interface_active_state()
+
def check_encryt(self):
if self.cryptcb.isChecked():
self.cryptkey.setEnabled()
else:
self.cryptkey.setDisabled()
+ self.interface_active_state()
def start(self):
if self.backup_cbox.isChecked():