Completed the command line options
authorHarishankar <v.harishankar@gmail.com>
Sat, 29 May 2010 05:12:47 +0000 (10:42 +0530)
committerHarishankar <v.harishankar@gmail.com>
Sat, 29 May 2010 05:12:47 +0000 (10:42 +0530)
Finished the code for generating the command
line options

biagen
main_window.xml

diff --git a/biagen b/biagen
index 1e22a93..86a337c 100755 (executable)
--- a/biagen
+++ b/biagen
 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 ()
 
@@ -32,10 +225,21 @@ class BiaGen:
                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 ()
index 3a670f2..b962acc 100644 (file)
                         <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>
@@ -73,6 +84,7 @@
                         <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>
@@ -86,6 +98,7 @@
                         <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>
@@ -193,14 +158,14 @@ Microsoft Windows</property>
                   </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>
@@ -214,8 +179,8 @@ caution</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>
@@ -234,8 +199,8 @@ with caution</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>
@@ -254,8 +219,8 @@ in filenames in ISO
                   <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>
@@ -274,15 +239,15 @@ extensions</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>
@@ -293,8 +258,8 @@ directory structure</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>
@@ -307,13 +272,17 @@ directory structure</property>
                     <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>
@@ -333,8 +302,8 @@ translation</property>
                   <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>
@@ -346,8 +315,8 @@ translation</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>
@@ -366,8 +335,8 @@ begin with a dot
                   </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>
@@ -386,13 +355,86 @@ with caution</property>
                   <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>
@@ -704,6 +746,7 @@ filesystem</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>