From c18ee3d29cb7ed5bf70c97a65f6d5823744af0dd Mon Sep 17 00:00:00 2001 From: Harishankar Date: Sat, 29 May 2010 10:42:47 +0530 Subject: [PATCH] Completed the command line options Finished the code for generating the command line options --- biagen | 214 ++++++++++++++++++++++++++++++++++++++++++++++-- main_window.xml | 191 +++++++++++++++++++++++++----------------- 2 files changed, 326 insertions(+), 79 deletions(-) diff --git a/biagen b/biagen index 1e22a93..86a337c 100755 --- a/biagen +++ b/biagen @@ -7,24 +7,217 @@ 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 () diff --git a/main_window.xml b/main_window.xml index 3a670f2..b962acc 100644 --- a/main_window.xml +++ b/main_window.xml @@ -40,6 +40,17 @@ True True filelist + True + 0 + True + 0 + + + True + File/folder + 0 + + @@ -73,6 +84,7 @@ True True True + False @@ -86,6 +98,7 @@ True True True + False @@ -116,7 +129,7 @@ True 5 - 7 + 9 4 @@ -127,57 +140,9 @@ - - - - - - - Level 1 - True - True - False - True - level2 - - - 1 - 2 - - - - - - - Level 2 - True - True - False - True - True - - - 2 - 3 - - - - - - - Level 3 - True - True - False - True - level2 - - - 3 4 - 2 @@ -193,14 +158,14 @@ Microsoft Windows 2 - 4 - 5 + 6 + 7 GTK_FILL - + Joliet long filenames True True @@ -214,8 +179,8 @@ caution 2 4 - 4 - 5 + 6 + 7 GTK_FILL 2 @@ -234,8 +199,8 @@ with caution 2 - 2 - 3 + 4 + 5 GTK_FILL @@ -254,8 +219,8 @@ in filenames in ISO 2 4 - 2 - 3 + 4 + 5 GTK_FILL 2 @@ -274,15 +239,15 @@ extensions 2 - 5 - 6 + 7 + 8 GTK_FILL - UDF filesystem extensions + UDF filesystem extensions (experimental) True True False @@ -293,8 +258,8 @@ directory structure 2 4 - 5 - 6 + 7 + 8 GTK_FILL @@ -307,13 +272,17 @@ directory structure False Use only if you are generating an ISO for -a DVD-video structure +a DVD-video structure +( see genisoimage manual +page for more info on +creating a DVD video +file structure ) True 2 - 6 - 7 + 8 + 9 GTK_FILL @@ -333,8 +302,8 @@ translation 2 4 - 6 - 7 + 8 + 9 GTK_FILL 2 @@ -346,8 +315,8 @@ translation 4 - 1 - 2 + 3 + 4 GTK_FILL 5 @@ -366,8 +335,8 @@ begin with a dot 2 - 3 - 4 + 5 + 6 GTK_FILL @@ -386,13 +355,86 @@ with caution 2 4 - 3 - 4 + 5 + 6 GTK_FILL 2 + + + Level 1 + True + True + False + True + level2 + + + 2 + 1 + 2 + + + + + + + Level 2 + True + True + False + True + True + + + 2 + 4 + 1 + 2 + + + + + + + Level 3 + True + True + False + True + True + level2 + + + 2 + 2 + 3 + + + 2 + + + + + Level 4 + True + True + False + True + True + level2 + + + 2 + 4 + 2 + 3 + + + + 1 @@ -704,6 +746,7 @@ filesystem True True True + False -- 2.20.1