aboutsummaryrefslogtreecommitdiffstats
path: root/lib/isodumper.py
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageialinux-online.org>2016-04-10 09:39:23 +0200
committerPapoteur <papoteur@mageialinux-online.org>2016-04-10 09:39:23 +0200
commit2e3efaed434a6319a4f93dc52cb7ec08b401b8ae (patch)
tree6e43065d61870e601ffffa8d5f7305b7b7c0143f /lib/isodumper.py
parent418b34ead6b1f4bdfc43b35cb3ea890ee83b0fcd (diff)
downloadisodumper-2e3efaed434a6319a4f93dc52cb7ec08b401b8ae.tar
isodumper-2e3efaed434a6319a4f93dc52cb7ec08b401b8ae.tar.gz
isodumper-2e3efaed434a6319a4f93dc52cb7ec08b401b8ae.tar.bz2
isodumper-2e3efaed434a6319a4f93dc52cb7ec08b401b8ae.tar.xz
isodumper-2e3efaed434a6319a4f93dc52cb7ec08b401b8ae.zip
Better managing grayed or enabled widgets
Deal with device selection Better managing names in file picker buttons reduce the size of dialog windows Clean code
Diffstat (limited to 'lib/isodumper.py')
-rw-r--r--lib/isodumper.py58
1 files changed, 37 insertions, 21 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index df780d9..b6a7d0b 100644
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -193,6 +193,9 @@ class IsoDumper(object):
def update_list(self ):
self.devicelist.deleteAllItems()
self.get_devices()
+ self.img_name = ""
+ self.ima.setLabel(self.ChooseImage)
+ self.backup_select.setLabel(self.ChooseImage)
self.restore()
def device_selected(self):
@@ -204,10 +207,13 @@ class IsoDumper(object):
self.deviceSize=size
self.device_name=name.rstrip().replace(' ', '')
self.logger(_('Target Device: ')+ self.dev)
+ self.formatbt.setEnabled()
+ self.ima.setEnabled()
+ self.backup_select.setEnabled()
break
- self.formatbt.setEnabled()
+
- def backup_sel(self,widget):
+ def backup_sel(self):
if self.backup_bname.get_current_folder_uri() == None :
self.backup_bname.set_current_folder_uri('file:///home/'+self.user)
self.backup_bname.set_current_name(self.device_name+".img")
@@ -247,15 +253,16 @@ class IsoDumper(object):
self.emergency(message)
def restore(self):
- self.backup_select.setEnabled()
+ self.backup_select.setDisabled()
self.backupbt.setDisabled()
- self.formatbt.setEnabled()
+ self.formatbt.setDisabled()
self.ima.setDisabled()
self.writebt.setDisabled()
self.devicelist.setEnabled()
self.progress.setLabel("")
self.progress.setValue(0)
self.progress.setDisabled()
+ self.refreshbt.setEnabled()
def raw_format(self, usb_path, fstype, label):
self.operation=True
@@ -297,7 +304,6 @@ class IsoDumper(object):
self.raw_write(source, dest, self.deviceSize)
if self.returncode==0:
self.success()
- self.restore()
def do_write(self):
@@ -398,7 +404,6 @@ class IsoDumper(object):
self.emergency(message)
self.close()
else:
- self.progress.setEnabled()
self.progress.setLabel(_('Writing ')+source.split('/')[-1]+_(' to ')+target.split('/')[-1])
self.logger(_('Executing copy from ')+source+_(' to ')+target)
steps=list(range(0, b+1, int(b/100)))
@@ -521,6 +526,14 @@ class IsoDumper(object):
self.progress.setDisabled()
self.backup_select.setDisabled()
+ def wip_unsensitive(self):
+ self.ima.setDisabled()
+ self.devicelist.setDisabled()
+ self.writebt.setDisabled()
+ self.backup_select.setDisabled()
+ self.backupbt.setDisabled()
+ self.refreshbt.setDisabled()
+
def close(self):
self.write_logfile()
self.dialog.destroy()
@@ -550,7 +563,6 @@ class IsoDumper(object):
def activate_devicelist(self):
self.devicelist.setEnabled()
-# self.img_name = self.chooser.get_filename()
self.logger(_('Image ')+": "+ self.img_name)
# self.chooser.set_tooltip_text(self.img_name)
@@ -588,6 +600,7 @@ The fields of the main window are as follows:\n\
# Operation running
self.operation=False
+ self.ChooseImage = _("Choose an image")
self.warning = _("Warning\nThis will destroy all data on the target device,\n\
are you sure you want to proceed?\n\
If you say ok here, please <b>do not unplug</b>\
@@ -624,11 +637,12 @@ The fields of the main window are as follows:\n\
self.devicebox = self.atelier.createHBox(self.box)
self.devicebox.setWeight(1,10)
self.devicelist=self.atelier.createComboBox(self.devicebox,_("Device to work on:"),False)
+ self.devicelist.setNotify()
self.devicelist.setStretchable(0,True)
self.writebox = self.atelier.createHBox(self.box)
self.atelier.createLabel(self.writebox,_("Write Image:"))
# add file picker for image file
- self.ima=self.atelier.createPushButton(self.writebox,"Choose an image")
+ self.ima=self.atelier.createPushButton(self.writebox,self.ChooseImage)
self.ima.setStretchable(0,True)
self.ima.setDisabled()
self.atelier.createHStretch(self.writebox)
@@ -637,7 +651,7 @@ The fields of the main window are as follows:\n\
self.backupbox = self.atelier.createHBox(self.box)
self.atelier.createLabel(self.backupbox,_("Backup to:"))
# add file picker for backup file name
- self.backup_select=self.atelier.createPushButton(self.backupbox,_("Choose an image"))
+ self.backup_select=self.atelier.createPushButton(self.backupbox,self.ChooseImage)
self.backup_select.setStretchable(0,True)
self.backup_select.setDisabled()
self.atelier.createHStretch(self.backupbox)
@@ -741,7 +755,7 @@ The fields of the main window are as follows:\n\
dlg.setTitle(info.title)
dlg.setText(info.text, info.richtext)
dlg.setButtonLabel("OK", yui.YMGAMessageBox.B_ONE)
- dlg.setMinSize(100, 10);
+ dlg.setMinSize(50, 10);
return dlg.show() == yui.YMGAMessageBox.B_ONE
def ask_YesOrNo(self, info):
@@ -752,7 +766,7 @@ The fields of the main window are as follows:\n\
dlg.setText(info.text, info.richtext)
dlg.setButtonLabel("Yes", yui.YMGAMessageBox.B_ONE)
dlg.setButtonLabel("No", yui.YMGAMessageBox.B_TWO)
- dlg.setMinSize(70, 8);
+ dlg.setMinSize(50, 8);
return dlg.show() == yui.YMGAMessageBox.B_ONE
def aboutDialog(self):
@@ -770,7 +784,7 @@ The fields of the main window are as follows:\n\
dlg.setText(_("Warning\nNo target devices were found.\nYou need to plug in a USB Key to which the image can be written."))
dlg.setButtonLabel(_("&Refresh"), yui.YMGAMessageBox.B_ONE)
dlg.setButtonLabel(_("Cancel"), yui.YMGAMessageBox.B_TWO)
- dlg.setMinSize(70, 8);
+ dlg.setMinSize(50, 8);
return dlg.show() == yui.YMGAMessageBox.B_ONE
def handleevent(self):
@@ -779,33 +793,35 @@ The fields of the main window are as follows:\n\
event = self.dialog.waitForEvent()
if event.eventType() == yui.YEvent.CancelEvent:
self.close()
- #self.dialog.destroy()
break
if event.widget() == self.quitbt:
self.close()
- #self.dialog.destroy()
break
if event.widget() == self.ima:
self.img_name=yui.YUI.app().askForExistingFile('file:///home/'+self.user,"*.iso *.img","Choose an image")
self.ima.setLabel(self.img_name)
-
+ self.writebt.setEnabled()
self.activate_devicelist()
if event.widget() == self.writebt:
- self.device_selected()
+ self.wip_unsensitive()
self.do_write()
+ self.restore()
if event.widget() == self.backupbt:
- self.device_selected()
- self.backup_go()
+ self.wip_unsensitive()
+ self.backup_go()
+ self.restore()
if event.widget() == self.backup_select:
- self.backup_img_name=yui.YUI.app().askForSaveFileName('file:///home/'+self.user,"*.img","Backup to:")
- if self.backup_img_name != '':
+ self.backup_img_name=yui.YUI.app().askForSaveFileName('file:///home/'+self.user,"*.img","Backup to:")
+ if self.backup_img_name != '':
self.backup_choosed()
if event.widget() == self.formatbt:
- self.device_selected()
+ self.wip_unsensitive()
code,format_type,name = self.ask_format()
if code:
self.do_format(format_type,name)
self.restore()
+ if event.widget() == self.devicelist:
+ self.device_selected()
try:
if event.widget() == self.refreshbt:
self.update_list()