3 # BiaGen - front end to genisoimage
4 # Copyright 2010 V.Harishankar
5 # Licensed under the GNU GPL v3 or above
10 import os
, subprocess
, sys
11 import progress_window
as PW
14 def build_parameters (self
):
15 # executable is genisoimage
16 lst_command
= ["genisoimage",]
18 # set the ISO level parameter
19 lst_command
.append ("-iso-level")
21 # get the radio buttons for iso level
22 level1
= self
.ui
.get_object ("level1")
23 level2
= self
.ui
.get_object ("level2")
24 level3
= self
.ui
.get_object ("level3")
25 level4
= self
.ui
.get_object ("level4")
27 # set the iso level correctly
28 if (level1
.get_active ()): lst_command
.append ("1")
29 elif (level2
.get_active ()): lst_command
.append ("2")
30 elif (level3
.get_active ()): lst_command
.append ("3")
31 else: lst_command
.append ("4")
33 # set ISO long filenames if applicable
34 isolong
= self
.ui
.get_object ("isolong")
35 if (isolong
.get_active ()):
36 lst_command
.append ("-l")
38 # set maximum ISO long filenames if applicable
39 isomaxlong
= self
.ui
.get_object ("isomaxlong")
40 if (isomaxlong
.get_active ()):
41 lst_command
.append ("-max-iso9660-filenames")
43 # if leading dots allowed
44 leadingdots
= self
.ui
.get_object ("leadingdots")
45 if (leadingdots
.get_active ()):
46 lst_command
.append ("-allow-leading-dots")
48 # lowercase ISO filenames
49 lowercase
= self
.ui
.get_object ("lowercase")
50 if (lowercase
.get_active ()):
51 lst_command
.append ("-allow-lowercase")
53 # set joliet if applicable
54 joliet
= self
.ui
.get_object ("usejoliet")
55 if (joliet
.get_active ()):
56 lst_command
.append ("-J")
57 # if joliet long file names is enabled
58 jlong
= self
.ui
.get_object ("jolietlong")
59 if (jlong
.get_active ()):
60 lst_command
.append ("-joliet-long")
62 # set rock ridge extensions if applicable
63 rockridge
= self
.ui
.get_object ("rockridge")
64 if (rockridge
.get_active ()):
65 lst_command
.append ("-r")
66 # if TRANS.TBL is to be generated
67 transtbl
= self
.ui
.get_object ("transtable")
68 if (transtbl
.get_active ()):
69 lst_command
.append ("-T")
71 # set UDF filesystem if applicable
72 udf
= self
.ui
.get_object ("udf")
73 if (udf
.get_active ()):
74 lst_command
.append ("-udf")
76 # set dvd filesystem compatibility if applicable
77 dvdvideo
= self
.ui
.get_object ("dvdvideo")
78 if (dvdvideo
.get_active ()):
79 lst_command
.append ("-dvd-video")
81 # get the dvd volume information
82 volid
= self
.ui
.get_object ("volumeid").get_text ().strip ()
83 if (len (volid
) <> 0):
84 lst_command
.append ("-V")
85 lst_command
.append (volid
)
88 sysid
= self
.ui
.get_object ("systemid").get_text ().strip ()
89 if (len (sysid
) <> 0):
90 lst_command
.append ("-sysid")
91 lst_command
.append (sysid
)
94 # get the publisher id
95 pubid
= self
.ui
.get_object ("publisherid").get_text ().strip ()
96 if (len (pubid
) <> 0):
97 lst_command
.append ("-publisher")
98 lst_command
.append (pubid
)
100 # get the volume set size and volume set #
101 volsize
= self
.ui
.get_object ("volsetsize").get_value_as_int ()
102 volnum
= self
.ui
.get_object ("volseqno").get_value_as_int ()
103 volsetid
= self
.ui
.get_object ("volsetid").get_text ().strip ()
105 # volume size should be > 0 and volume number should be less or equal to volume size
106 if (len (volsetid
) <> 0 and volsize
> 0 and volnum
<= volsize
):
107 lst_command
.append ("-volset")
108 lst_command
.append (volsetid
)
109 lst_command
.append ("-volset-size")
110 lst_command
.append (str (volsize
))
111 lst_command
.append ("-volset-seqno")
112 lst_command
.append (str (volnum
))
114 # get the preparer ID
115 preparer
= self
.ui
.get_object ("preparerid").get_text ().strip ()
116 if (len (preparer
) <> 0):
117 lst_command
.append ("-p")
118 lst_command
.append (preparer
)
120 # get the copyright file
121 copyright
= self
.ui
.get_object ("copyright").get_text ().strip ()
122 if (len (copyright
) <> 0):
123 lst_command
.append ("-copyright")
124 lst_command
.append (copyright
)
126 # get the output file
127 filedlg
= gtk
.FileChooserDialog (title
="Save ISO image", action
=gtk
.FILE_CHOOSER_ACTION_SAVE
,
128 buttons
= (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_SAVE
, gtk
.RESPONSE_OK
))
129 if (filedlg
.run () <> gtk
.RESPONSE_OK
):
131 # if no file is chosen return None
134 lst_command
.append ("-o")
135 lst_command
.append (filedlg
.get_filename ())
138 # return the command list
141 def get_files_set (self
):
142 # get the list of files/folders in a set
145 lststore
= self
.ui
.get_object ("filelist")
147 item
= lststore
.get_iter_first ()
152 data
= lststore
.get (item
, 0)
154 item
= lststore
.iter_next (item
)
158 def on_btn_create_clicked (self
, *args
):
159 file_list
= self
.get_files_set ()
160 if file_list
<> None:
161 cmdlist
= self
.build_parameters ()
163 for file in file_list
:
164 cmdlist
.append (file)
166 wnd
= PW
.BiaGenProgress (self
.ui
, cmdlist
)
168 # display the error message
169 msgdlg
= gtk
.MessageDialog (parent
= self
.ui
.get_object ("main_window"), buttons
= gtk
.BUTTONS_OK
,
170 type = gtk
.MESSAGE_ERROR
, message_format
= "No files/folders chosen to burn")
174 def remove_selected_items (self
):
175 # get the file treeview and liststore
176 file_view
= self
.ui
.get_object ("tree_files")
177 file_list
= self
.ui
.get_object ("filelist")
179 # get the selected rows as paths
180 sel_model
, sel_rows
= file_view
.get_selection ().get_selected_rows ()
182 # store the treeiters from paths
185 iters
.append ( file_list
.get_iter (row
) )
187 # remove the rows (treeiters)
192 def add_item (self
, type):
193 # if the type is 1 create a file open dialog
195 dlg
= gtk
.FileChooserDialog (title
="Add files", action
=gtk
.FILE_CHOOSER_ACTION_OPEN
,
196 buttons
=(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
197 # create a folder open dialog
199 dlg
= gtk
.FileChooserDialog (title
="Add folders", action
=gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
,
200 buttons
=(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
203 dlg
.set_property ("select-multiple", True)
204 if (dlg
.run () == gtk
.RESPONSE_OK
):
205 filelist
= self
.ui
.get_object ("filelist")
207 # get the list of files selected and append it to the view
208 for file in dlg
.get_filenames ():
209 filelist
.append ([file,])
213 def on_btn_add_clicked (self
, *args
):
214 self
.add_item (type=1)
216 def on_btn_remove_clicked (self
, *args
):
217 self
.remove_selected_items ()
219 def on_btn_addfolder_clicked (self
, *args
):
220 self
.add_item (type=0)
222 def on_btn_exit_clicked (self
, *args
):
225 def on_main_window_hide (self
, *args
):
229 gobject
.threads_init ()
230 self
.ui
= gtk
.Builder ()
231 self
.ui
.add_from_file ("main_window.xml")
232 self
.ui
.get_object ("main_window").show ()
234 # set the column 0 to display text of column 0 of liststore
235 col
= self
.ui
.get_object ("tree_files").get_column (0)
236 cell
= gtk
.CellRendererText ()
237 col
.pack_start (cell
)
238 col
.add_attribute (cell
, "text", 0)
240 # set selection mode to multiple
241 sel
= self
.ui
.get_object ("tree_files").get_selection ()
242 sel
.set_mode (gtk
.SELECTION_MULTIPLE
)
244 self
.ui
.connect_signals (self
)