import pygtk
pygtk.require20 ()
import gtk
+import os, subprocess, sys
class BiaGen:
+ def build_parameters (self):
+ # executable is genisoimage
+ lst_command = ["genisoimage",]
+
+ # set the ISO level parameter
+ lst_command.append ("-iso-level")
+
+ # get the radio buttons for iso level
+ level1 = self.ui.get_object ("level1")
+ level2 = self.ui.get_object ("level2")
+ level3 = self.ui.get_object ("level3")
+ level4 = self.ui.get_object ("level4")
+
+ # set the iso level correctly
+ if (level1.get_active ()): lst_command.append ("1")
+ elif (level2.get_active ()): lst_command.append ("2")
+ elif (level3.get_active ()): lst_command.append ("3")
+ else: lst_command.append ("4")
+
+ # set ISO long filenames if applicable
+ isolong = self.ui.get_object ("isolong")
+ if (isolong.get_active ()):
+ lst_command.append ("-l")
+
+ # set maximum ISO long filenames if applicable
+ isomaxlong = self.ui.get_object ("isomaxlong")
+ if (isomaxlong.get_active ()):
+ lst_command.append ("-max-iso9660-filenames")
+
+ # if leading dots allowed
+ leadingdots = self.ui.get_object ("leadingdots")
+ if (leadingdots.get_active ()):
+ lst_command.append ("-allow-leading-dots")
+
+ # lowercase ISO filenames
+ lowercase = self.ui.get_object ("lowercase")
+ if (lowercase.get_active ()):
+ lst_command.append ("-allow-lowercase")
+
+ # set joliet if applicable
+ joliet = self.ui.get_object ("usejoliet")
+ if (joliet.get_active ()):
+ lst_command.append ("-J")
+ # if joliet long file names is enabled
+ jlong = self.ui.get_object ("jolietlong")
+ if (jlong.get_active ()):
+ lst_command.append ("-joliet-long")
+
+ # set rock ridge extensions if applicable
+ rockridge = self.ui.get_object ("rockridge")
+ if (rockridge.get_active ()):
+ lst_command.append ("-r")
+ # if TRANS.TBL is to be generated
+ transtbl = self.ui.get_object ("transtable")
+ if (transtbl.get_active ()):
+ lst_command.append ("-T")
+
+ # set UDF filesystem if applicable
+ udf = self.ui.get_object ("udf")
+ if (udf.get_active ()):
+ lst_command.append ("-udf")
+
+ # set dvd filesystem compatibility if applicable
+ dvdvideo = self.ui.get_object ("dvdvideo")
+ if (dvdvideo.get_active ()):
+ lst_command.append ("-dvd-video")
+
+ # get the dvd volume information
+ volid = self.ui.get_object ("volumeid").get_text ().strip ()
+ if (len (volid) <> 0):
+ lst_command.append ("-V")
+ lst_command.append (volid)
+
+ # get the system id
+ sysid = self.ui.get_object ("systemid").get_text ().strip ()
+ if (len (sysid) <> 0):
+ lst_command.append ("-sysid")
+ lst_command.append (sysid)
+
+
+ # get the publisher id
+ pubid = self.ui.get_object ("publisherid").get_text ().strip ()
+ if (len (pubid) <> 0):
+ lst_command.append ("-publisher")
+ lst_command.append (pubid)
+
+ # get the volume set size and volume set #
+ volsize = self.ui.get_object ("volsetsize").get_value_as_int ()
+ volnum = self.ui.get_object ("volseqno").get_value_as_int ()
+ volsetid = self.ui.get_object ("volsetid").get_text ().strip ()
+
+ # volume size should be > 0 and volume number should be less or equal to volume size
+ if (len (volsetid) <> 0 and volsize > 0 and volnum <= volsize):
+ lst_command.append ("-volset")
+ lst_command.append (volsetid)
+ lst_command.append ("-volset-size")
+ lst_command.append (str (volsize))
+ lst_command.append ("-volset-seqno")
+ lst_command.append (str (volnum))
+
+ # get the preparer ID
+ preparer = self.ui.get_object ("preparerid").get_text ().strip ()
+ if (len (preparer) <> 0):
+ lst_command.append ("-p")
+ lst_command.append (preparer)
+
+ # get the copyright file
+ copyright = self.ui.get_object ("copyright").get_text ().strip ()
+ if (len (copyright) <> 0):
+ lst_command.append ("-copyright")
+ lst_command.append (copyright)
+
+ # get the output file
+ filedlg = gtk.FileChooserDialog (title="Save ISO image", action=gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons= (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK))
+ if (filedlg.run () <> gtk.RESPONSE_OK):
+ filedlg.destroy ()
+ # if no file is chosen return None
+ return None
+ else:
+ lst_command.append ("-o")
+ lst_command.append (filedlg.get_filename ())
+ filedlg.destroy ()
+
+ # return the command list
+ return lst_command
+
+ def get_files_set (self):
+ # get the list of files/folders in a set
+ files = set ()
+
+ lststore = self.ui.get_object ("filelist")
+
+ item = lststore.get_iter_first ()
+ if item == None:
+ return None
+
+ while item <> None:
+ data = lststore.get (item, 0)
+ files.add (data[0])
+ item = lststore.iter_next (item)
+
+ return files
+
+ def on_btn_create_clicked (self, *args):
+ file_list = self.get_files_set ()
+ if file_list <> None:
+ cmdlist = self.build_parameters ()
+ if cmdlist <> None:
+ for file in file_list:
+ cmdlist.append (file)
+
+ print subprocess.list2cmdline (cmdlist)
+ else:
+ # display the error message
+ msgdlg = gtk.MessageDialog (parent = self.ui.get_object ("main_window"), buttons = gtk.BUTTONS_OK,
+ type = gtk.MESSAGE_ERROR, message_format = "No files/folders chosen to burn")
+ msgdlg.run ()
+ msgdlg.destroy ()
+
+ def remove_selected_items (self):
+ # get the file treeview and liststore
+ file_view = self.ui.get_object ("tree_files")
+ file_list = self.ui.get_object ("filelist")
+
+ # get the selected rows as paths
+ sel_model, sel_rows = file_view.get_selection ().get_selected_rows ()
+
+ # store the treeiters from paths
+ iters = []
+ for row in sel_rows:
+ iters.append ( file_list.get_iter (row) )
+
+ # remove the rows (treeiters)
+ for i in iters:
+ if i is not None:
+ file_list.remove (i)
+
def add_item (self, type):
+ # if the type is 1 create a file open dialog
if type == 1:
dlg = gtk.FileChooserDialog (title="Add files", action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ # create a folder open dialog
else:
dlg = gtk.FileChooserDialog (title="Add folders", action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ # select multiple
dlg.set_property ("select-multiple", True)
- dlg.run ()
+ if (dlg.run () == gtk.RESPONSE_OK):
+ filelist = self.ui.get_object ("filelist")
+
+ # get the list of files selected and append it to the view
+ for file in dlg.get_filenames ():
+ filelist.append ([file,])
dlg.destroy ()
def on_btn_add_clicked (self, *args):
self.add_item (type=1)
+ def on_btn_remove_clicked (self, *args):
+ self.remove_selected_items ()
+
+ def on_btn_addfolder_clicked (self, *args):
+ self.add_item (type=0)
+
def on_btn_exit_clicked (self, *args):
gtk.main_quit ()
gtk.main_quit ()
def __init__ (self):
- ui = gtk.Builder ()
- ui.add_from_file ("main_window.xml")
- ui.get_object ("main_window").show ()
- ui.connect_signals (self)
+ self.ui = gtk.Builder ()
+ self.ui.add_from_file ("main_window.xml")
+ self.ui.get_object ("main_window").show ()
+
+ # set the column 0 to display text of column 0 of liststore
+ col = self.ui.get_object ("tree_files").get_column (0)
+ cell = gtk.CellRendererText ()
+ col.pack_start (cell)
+ col.add_attribute (cell, "text", 0)
+
+ # set selection mode to multiple
+ sel = self.ui.get_object ("tree_files").get_selection ()
+ sel.set_mode (gtk.SELECTION_MULTIPLE)
+
+ self.ui.connect_signals (self)
gtk.main ()
BiaGen ()
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">filelist</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">0</property>
+ <property name="rubber_banding">True</property>
+ <property name="tooltip_column">0</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="filename">
+ <property name="resizable">True</property>
+ <property name="title">File/folder</property>
+ <property name="sort_column_id">0</property>
+ </object>
+ </child>
</object>
</child>
</object>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="on_btn_addfolder_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="on_btn_remove_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">5</property>
- <property name="n_rows">7</property>
+ <property name="n_rows">9</property>
<property name="n_columns">4</property>
<child>
<object class="GtkLabel" id="ISO level">
</attributes>
</object>
<packing>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="level1">
- <property name="label" translatable="yes">Level 1</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">level2</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="level2">
- <property name="label" translatable="yes">Level 2</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="level3">
- <property name="label" translatable="yes">Level 3</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">level2</property>
- </object>
- <packing>
- <property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options"></property>
<property name="y_options"></property>
- <property name="y_padding">2</property>
</packing>
</child>
<child>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="joiletlong">
+ <object class="GtkCheckButton" id="jolietlong">
<property name="label" translatable="yes">Joliet long filenames</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">2</property>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">2</property>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="udf">
- <property name="label" translatable="yes">UDF filesystem extensions</property>
+ <property name="label" translatable="yes">UDF filesystem extensions (experimental)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Use only if you are
generating an ISO for
-a DVD-video structure</property>
+a DVD-video structure
+( see genisoimage manual
+page for more info on
+creating a DVD video
+file structure )</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">2</property>
</object>
<packing>
<property name="right_attach">4</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
<property name="y_padding">5</property>
</packing>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkRadioButton" id="level1">
+ <property name="label" translatable="yes">Level 1</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">level2</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="level2">
+ <property name="label" translatable="yes">Level 2</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="level3">
+ <property name="label" translatable="yes">Level 3</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">level2</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ <property name="y_padding">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="level4">
+ <property name="label" translatable="yes">Level 4</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">level2</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="on_btn_create_clicked"/>
</object>
<packing>
<property name="expand">False</property>