From f37c9b3c2e7ac95ec6d9f54b261c101bbed75e15 Mon Sep 17 00:00:00 2001 From: papoteur-mga Date: Sun, 29 Jun 2014 11:31:32 +0200 Subject: - added a dialog box to warning against close when operationin action - added close the application when X of the window bar clicked - added file name and device name in the logview when selected - changed a window to a dialog form. - set the user owner of log file and directory - suppress window redraw when closing the logview --- CHANGELOG | 17 ++- lib/isodumper.py | 58 ++++++--- share/isodumper/isodumper.glade | 271 +++++++++++++++++++++++----------------- 3 files changed, 218 insertions(+), 128 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fa75ac5..2fe83b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,10 +5,23 @@ IsoDumper 0.30 ------------ - added function to format the device in Fat32, ntfs or ext4. - separated backup from writing. - + - added a dialog box to warning against close when operationin action + - added close the application when X of the window bar clicked + - added file name and device name in the logview when selected + - changed a window to a dialog form. + - set the user owner of log file and directory + - suppress window redraw when closing the logview + +IsoDumper 0.23 +------------ + - added close the application when X of the window bar clicked + - added file name and device name in the logview when selected + - set the user owner of log file and directory + - suppress window redraw when closing the logview + IsoDumper 0.22 ------------ - - changed a window to a dialog form. + - changed a window in a dialog form. - added default values for the backup name and directory. - improvement to the isodumper icon with a new SVG. - improvement to the Makefile. diff --git a/lib/isodumper.py b/lib/isodumper.py index 388126b..edffd71 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -73,6 +73,7 @@ class IsoDumper: # get glade tree self.gladefile = "/usr/share/isodumper/isodumper.glade" + #self.gladefile = "/documents/isodumper-dev/share/isodumper/isodumper.glade" self.wTree = gtk.glade.XML(self.gladefile) # get globally needed widgets @@ -80,11 +81,15 @@ class IsoDumper: self.devicelist = self.wTree.get_widget("device_combobox") self.logview = self.wTree.get_widget("detail_text") self.log = self.logview.get_buffer() + # set RELEASE number on title and About self.window.set_title(self.window.get_title()+' '+RELEASE) self.wTree.get_widget("about_dialog").set_version(RELEASE) # define size of the selected device self.deviceSize=0 + + # Operation running + self.operation=False # set default file filter to *.img # Added for Mageia : *.iso @@ -105,12 +110,12 @@ class IsoDumper: # set callbacks dict = { "on_main_dialog_destroy" : self.close, - "on_cancel_button_clicked" : self.close, + "on_cancel_button_clicked" : self.confirm_close, "on_emergency_button_clicked" : self.restore, "on_success_button_clicked" : self.close, "on_confirm_cancel_button_clicked": self.restore, "on_filechooserbutton_file_set" : self.activate_devicelist, - "on_detail_expander_activate" : self.expander_control, +# "on_detail_expander_activate" : self.expander_control, "on_device_combobox_changed" : self.device_selected, "on_nodev_close_clicked" : self.close, "on_backup_button_clicked" : self.backup_go, @@ -121,7 +126,9 @@ class IsoDumper: "on_format_button_clicked" : self.format_dialog, "on_format_cancel_clicked" : self.format_cancel, "on_format_go_clicked" : self.do_format, - "on_write_button_clicked" : self.do_write} + "on_write_button_clicked" : self.do_write, + "on_main_dialog_delete_event" : gtk.main_quit, + } self.wTree.signal_autoconnect(dict) self.window.show_all() @@ -146,13 +153,13 @@ class IsoDumper: self.devicelist.append_text(name+' ('+path.lstrip()+') '+sizeM+_('Mb')) self.device_name=name.rstrip().replace(' ', '') dialog.destroy() - - + def device_selected(self, widget): self.dev = self.devicelist.get_active_text() self.backup_select.set_sensitive(True) self.wTree.get_widget("format_button").set_sensitive(True) self.wTree.get_widget("filechooserbutton").set_sensitive(True) + self.logger(_('Target Device: ')+ self.dev) def backup_sel(self,widget): if self.backup_bname.get_current_folder_uri() == None : @@ -185,10 +192,9 @@ class IsoDumper: write_button.set_sensitive(False) self.devicelist.set_sensitive(False) dialog=self.wTree.get_widget("format") - dialog.present() self.wTree.get_widget("format_device").set_text(self.dev) self.wTree.get_widget("format_name").set_text(self.dev.split('(')[0]) - exit_dialog=dialog.show_all() + exit_dialog=dialog.run() if exit_dialog==0: dialog.hide() @@ -213,10 +219,11 @@ class IsoDumper: self.wTree.get_widget("format_button").set_sensitive(True) self.wTree.get_widget("filechooserbutton").set_sensitive(True) self.devicelist.set_sensitive(True) - self.write_logfile() +# self.write_logfile() self.wTree.get_widget("emergency_dialog").hide() def raw_format(self, usb_path, fstype, label): + self.operation=True if os.geteuid() > 0: launcher='pkexec' self.process = Popen([launcher,'/usr/bin/python', '-u', '/usr/lib/isodumper/raw_format.py','-d',usb_path,'-f',fstype, '-l', label, '-u', str(os.geteuid()), '-g', str(os.getgid())], shell=False, stdout=PIPE, preexec_fn=os.setsid) @@ -345,6 +352,7 @@ class IsoDumper: self.emergency() def raw_write(self, source, target, b): + self.operation=True bs=4096*128 try: ifc=io.open(source, "rb",1) @@ -357,6 +365,7 @@ class IsoDumper: except: self.logger(_('You have not the rights for writing on the device')) self.emergency() + self.close('dummy') else: progress = self.wTree.get_widget("progressbar") progress.set_sensitive(True) @@ -413,6 +422,17 @@ class IsoDumper: dialog.hide() + def confirm_close(self, widget): + if self.operation==False: # no writing , backup nor format running + self.close('dummy') + else: # writing , backup nor format running + dialog=self.wTree.get_widget("Quit_warning") + resp = dialog.run() + if resp==-5 : # GTK_RESPONSE_OK + self.close('dummy') + else: + dialog.hide() + def emergency(self): self.final_unsensitive() dialog = self.wTree.get_widget("emergency_dialog") @@ -442,14 +462,22 @@ class IsoDumper: def write_logfile(self): start = self.log.get_start_iter() end = self.log.get_end_iter() + import pwd + pw = pwd.getpwnam(self.user) + uid = pw.pw_uid + gid= pw.pw_gid if (self.user != 'root') and (self.user !=''): home='/home/'+self.user else: home='/root' if not(os.path.isdir(home+'/.isodumper')): os.mkdir(home+'/.isodumper') + os.chown(home+'/.isodumper',uid, gid) logfile=open(home+'/.isodumper/isodumper.log',"w") logfile.write(self.log.get_text(start, end, False)) + logfile.close() + + os.chown(home+'/.isodumper/isodumper.log',uid, gid) print self.log.get_text(start, end, False) def logger(self, text): @@ -464,15 +492,17 @@ class IsoDumper: self.img_name = self.chooser.get_filename() write_button = self.wTree.get_widget("write_button") write_button.set_sensitive(True) - + self.logger(_('Image ')+": "+ self.img_name) + self.chooser.set_tooltip_text(self.img_name) + def activate_backup(self, widget): self.backup_img_name = self.backup_dir.get_filename() - def expander_control(self, widget): - # this is darn ugly but still better than the UI behavior of - # the unexpanded expander which doesnt reset the window size - if widget.get_expanded(): - gobject.timeout_add(130, lambda: self.window.reshow_with_initial_size()) +# def expander_control(self, widget): +# # this is darn ugly but still better than the UI behavior of +# # the unexpanded expander which doesnt reset the window size +# if widget.get_expanded(): +# gobject.timeout_add(130, lambda: self.window.reshow_with_initial_size()) def about(self, widget): about_button = self.wTree.get_widget("about_button") diff --git a/share/isodumper/isodumper.glade b/share/isodumper/isodumper.glade index 6985e4f..480e801 100644 --- a/share/isodumper/isodumper.glade +++ b/share/isodumper/isodumper.glade @@ -2,6 +2,41 @@ + + False + 5 + dialog + True + warning + ok-cancel + Writing is in progress. Exiting will occur that the device will be unusable. +Are you sure you want to quit during writing on the device? + + + True + False + 2 + + + True + False + end + + + + + + + + + True + True + 0 + + + + + False 5 @@ -11,6 +46,7 @@ dialog True IsoDumper + v0.30 © 2013-2014 Mageia A tool for writing ISO images on a USB stick. It's a fork of usb-imagewriter. https://github.com/papoteur-mga/isodumper @@ -409,14 +445,12 @@ Public License instead of this License. + 540 False + True 5 - IsoDumper - True - center-on-parent - 715 - 540 - isodumper + Isodumper + isodumper dialog @@ -664,9 +698,9 @@ Public License instead of this License. <b>Error</b> Something went wrong, please see the details window for the exact error. - - A logfile isodumper.log with the content will be saved in your - homedir/.isodumper when the application is closed. + +The application will be closed with this window, and a logfile + isodumper.log will be saved in your homedir/.isodumper True @@ -685,37 +719,28 @@ Public License instead of this License. - + False - Formatting the device - center - 350 - isodumper - - + 5 + dialog + + True False - - - True - False - label - - - True - True - 0 - - - - + 2 + + True False + end - + + gtk-execute True - False - Label for the device: + True + True + True + True @@ -724,15 +749,13 @@ Public License instead of this License. - + + gtk-undo True True - - 32 - False - False - True - True + True + True + True @@ -744,110 +767,133 @@ Public License instead of this License. True True - 1 + 0 - + True False - - FAT 32 (Windows) + True - True - False - True - The standard. The size of files are limited to 4Gb - True - True + False + label - False - False + True + True 0 - - NTFS (Windows) + True - True - False - True - To handle files bigger than 4Gb - True - format_fat - - - False - False - 1 - - - - - ext4 (Linux) - True - True - False - True - Only for Linux systems - True - format_fat - - - False - False - 2 - - - - - True - True - 2 - - - - - True - False - - - gtk-execute - True - True - True - True - + False + + + True + False + Label for the device: + + + True + True + 0 + + + + + True + True + + 32 + True + False + False + True + True + + + True + True + 1 + + True True - 0 + 1 - - gtk-undo + True - True - True - True - + False + + + FAT 32 (Windows) + True + True + False + True + The standard. The size of files are limited to 4Gb + True + True + + + False + False + 0 + + + + + NTFS (Windows) + True + True + False + True + To handle files bigger than 4Gb + True + format_fat + + + False + False + 1 + + + + + ext4 (Linux) + True + True + False + True + Only for Linux systems + True + format_fat + + + False + False + 2 + + True True - 1 + 2 True True - 3 + 1 @@ -860,6 +906,7 @@ Public License instead of this License. center-always isodumper dialog + True -- cgit v1.2.1