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
13 def build_parameters (self
):
14 # executable is genisoimage
15 lst_command
= ["genisoimage",]
17 # set the ISO level parameter
18 lst_command
.append ("-iso-level")
20 # get the radio buttons for iso level
21 level1
= self
.ui
.get_object ("level1")
22 level2
= self
.ui
.get_object ("level2")
23 level3
= self
.ui
.get_object ("level3")
24 level4
= self
.ui
.get_object ("level4")
26 # set the iso level correctly
27 if (level1
.get_active ()): lst_command
.append ("1")
28 elif (level2
.get_active ()): lst_command
.append ("2")
29 elif (level3
.get_active ()): lst_command
.append ("3")
30 else: lst_command
.append ("4")
32 # set ISO long filenames if applicable
33 isolong
= self
.ui
.get_object ("isolong")
34 if (isolong
.get_active ()):
35 lst_command
.append ("-l")
37 # set maximum ISO long filenames if applicable
38 isomaxlong
= self
.ui
.get_object ("isomaxlong")
39 if (isomaxlong
.get_active ()):
40 lst_command
.append ("-max-iso9660-filenames")
42 # if leading dots allowed
43 leadingdots
= self
.ui
.get_object ("leadingdots")
44 if (leadingdots
.get_active ()):
45 lst_command
.append ("-allow-leading-dots")
47 # lowercase ISO filenames
48 lowercase
= self
.ui
.get_object ("lowercase")
49 if (lowercase
.get_active ()):
50 lst_command
.append ("-allow-lowercase")
52 # set joliet if applicable
53 joliet
= self
.ui
.get_object ("usejoliet")
54 if (joliet
.get_active ()):
55 lst_command
.append ("-J")
56 # if joliet long file names is enabled
57 jlong
= self
.ui
.get_object ("jolietlong")
58 if (jlong
.get_active ()):
59 lst_command
.append ("-joliet-long")
61 # set rock ridge extensions if applicable
62 rockridge
= self
.ui
.get_object ("rockridge")
63 if (rockridge
.get_active ()):
64 lst_command
.append ("-r")
65 # if TRANS.TBL is to be generated
66 transtbl
= self
.ui
.get_object ("transtable")
67 if (transtbl
.get_active ()):
68 lst_command
.append ("-T")
70 # set UDF filesystem if applicable
71 udf
= self
.ui
.get_object ("udf")
72 if (udf
.get_active ()):
73 lst_command
.append ("-udf")
75 # set dvd filesystem compatibility if applicable
76 dvdvideo
= self
.ui
.get_object ("dvdvideo")
77 if (dvdvideo
.get_active ()):
78 lst_command
.append ("-dvd-video")
80 # get the dvd volume information
81 volid
= self
.ui
.get_object ("volumeid").get_text ().strip ()
82 if (len (volid
) <> 0):
83 lst_command
.append ("-V")
84 lst_command
.append (volid
)
87 sysid
= self
.ui
.get_object ("systemid").get_text ().strip ()
88 if (len (sysid
) <> 0):
89 lst_command
.append ("-sysid")
90 lst_command
.append (sysid
)
93 # get the publisher id
94 pubid
= self
.ui
.get_object ("publisherid").get_text ().strip ()
95 if (len (pubid
) <> 0):
96 lst_command
.append ("-publisher")
97 lst_command
.append (pubid
)
99 # get the volume set size and volume set #
100 volsize
= self
.ui
.get_object ("volsetsize").get_value_as_int ()
101 volnum
= self
.ui
.get_object ("volseqno").get_value_as_int ()
102 volsetid
= self
.ui
.get_object ("volsetid").get_text ().strip ()
104 # volume size should be > 0 and volume number should be less or equal to volume size
105 if (len (volsetid
) <> 0 and volsize
> 0 and volnum
<= volsize
):
106 lst_command
.append ("-volset")
107 lst_command
.append (volsetid
)
108 lst_command
.append ("-volset-size")
109 lst_command
.append (str (volsize
))
110 lst_command
.append ("-volset-seqno")
111 lst_command
.append (str (volnum
))
113 # get the preparer ID
114 preparer
= self
.ui
.get_object ("preparerid").get_text ().strip ()
115 if (len (preparer
) <> 0):
116 lst_command
.append ("-p")
117 lst_command
.append (preparer
)
119 # get the copyright file
120 copyright
= self
.ui
.get_object ("copyright").get_text ().strip ()
121 if (len (copyright
) <> 0):
122 lst_command
.append ("-copyright")
123 lst_command
.append (copyright
)
125 # get the output file
126 filedlg
= gtk
.FileChooserDialog (title
="Save ISO image", action
=gtk
.FILE_CHOOSER_ACTION_SAVE
,
127 buttons
= (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_SAVE
, gtk
.RESPONSE_OK
))
128 if (filedlg
.run () <> gtk
.RESPONSE_OK
):
130 # if no file is chosen return None
133 lst_command
.append ("-o")
134 lst_command
.append (filedlg
.get_filename ())
137 # return the command list
140 def get_files_set (self
):
141 # get the list of files/folders in a set
144 lststore
= self
.ui
.get_object ("filelist")
146 item
= lststore
.get_iter_first ()
151 data
= lststore
.get (item
, 0)
153 item
= lststore
.iter_next (item
)
157 def on_btn_create_clicked (self
, *args
):
158 file_list
= self
.get_files_set ()
159 if file_list
<> None:
160 cmdlist
= self
.build_parameters ()
162 for file in file_list
:
163 cmdlist
.append (file)
165 print subprocess
.list2cmdline (cmdlist
)
167 # display the error message
168 msgdlg
= gtk
.MessageDialog (parent
= self
.ui
.get_object ("main_window"), buttons
= gtk
.BUTTONS_OK
,
169 type = gtk
.MESSAGE_ERROR
, message_format
= "No files/folders chosen to burn")
173 def remove_selected_items (self
):
174 # get the file treeview and liststore
175 file_view
= self
.ui
.get_object ("tree_files")
176 file_list
= self
.ui
.get_object ("filelist")
178 # get the selected rows as paths
179 sel_model
, sel_rows
= file_view
.get_selection ().get_selected_rows ()
181 # store the treeiters from paths
184 iters
.append ( file_list
.get_iter (row
) )
186 # remove the rows (treeiters)
191 def add_item (self
, type):
192 # if the type is 1 create a file open dialog
194 dlg
= gtk
.FileChooserDialog (title
="Add files", action
=gtk
.FILE_CHOOSER_ACTION_OPEN
,
195 buttons
=(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
196 # create a folder open dialog
198 dlg
= gtk
.FileChooserDialog (title
="Add folders", action
=gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
,
199 buttons
=(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
, gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
))
202 dlg
.set_property ("select-multiple", True)
203 if (dlg
.run () == gtk
.RESPONSE_OK
):
204 filelist
= self
.ui
.get_object ("filelist")
206 # get the list of files selected and append it to the view
207 for file in dlg
.get_filenames ():
208 filelist
.append ([file,])
212 def on_btn_add_clicked (self
, *args
):
213 self
.add_item (type=1)
215 def on_btn_remove_clicked (self
, *args
):
216 self
.remove_selected_items ()
218 def on_btn_addfolder_clicked (self
, *args
):
219 self
.add_item (type=0)
221 def on_btn_exit_clicked (self
, *args
):
224 def on_main_window_hide (self
, *args
):
228 self
.ui
= gtk
.Builder ()
229 self
.ui
.add_from_file ("main_window.xml")
230 self
.ui
.get_object ("main_window").show ()
232 # set the column 0 to display text of column 0 of liststore
233 col
= self
.ui
.get_object ("tree_files").get_column (0)
234 cell
= gtk
.CellRendererText ()
235 col
.pack_start (cell
)
236 col
.add_attribute (cell
, "text", 0)
238 # set selection mode to multiple
239 sel
= self
.ui
.get_object ("tree_files").get_selection ()
240 sel
.set_mode (gtk
.SELECTION_MULTIPLE
)
242 self
.ui
.connect_signals (self
)