Added support for reading the base config

This commit is contained in:
Sergio Costas 2014-07-13 20:50:02 +02:00
parent ae172c785f
commit d4ed74ae5f
6 changed files with 164 additions and 133 deletions

View file

@ -59,3 +59,70 @@ class configuration:
self.help_path="/usr/share/doc/devede_ng"
self.gettext_domain = "devede_ng"
self.PAL = True
self.tmp_folder = "/var/tmp"
self.multicore = True
self.final_folder = None
self.sub_language = None
self.sub_codepage = None
config_path = os.path.join(os.environ.get("HOME"),".devede")
try:
config_data = open(config_path,"r")
for linea in config_data:
linea = linea.strip()
if linea == "":
continue
if linea[0] == "#":
continue
if linea[:13]=="video_format:":
if linea[13:].strip() =="pal":
self.PAL=True
continue
if linea[13:].strip()=="ntsc":
self.PAL=False
continue
if linea[:12]=="temp_folder:":
self.tmp_folder=linea[12:].strip()
if linea[:10]=="multicore:":
if linea[10:].strip()=="1":
self.multicore = False
else:
self.multicore = True
if linea[:13]=="final_folder:":
self.final_folder=linea[13:].strip()
if linea[:13]=="sub_language:":
self.sub_language=linea[13:].strip()
if linea[:13]=="sub_codepage:":
self.sub_codepage=linea[13:].strip()
config_data.close()
except:
pass
def save_config(self):
config_path = os.path.join(os.environ.get("HOME"),".devede")
try:
config_data = open(config_path,"w")
config_data.write("video_format:")
if (self.PAL):
config_data.write("pal\n")
else:
config_data.write("ntsc\n")
if (self.tmp_folder != None):
config_data.write("temp_folder:"+str(self.tmp_folder)+"\n")
config_data.write("multicore:")
if (self.multicore):
config_data.write("2\n")
else:
config_data.write("1\n")
if (self.final_folder != None):
config_data.write("final_folder:"+str(self.final_folder)+"\n")
if (self.sub_language != None):
config_data.write("sub_language:"+str(self.sub_language)+"\n")
if (self.sub_codepage != None):
config_data.write("sub_codepage:"+str(self.sub_codepage)+"\n")
config_data.close()
except:
pass

View file

@ -32,12 +32,42 @@ class file_movie(GObject.GObject):
self.model = None
self.treeiter = None
self.builder = None
self.video_rate = 0
self.audio_rate = 0
self.final_size = None
self.aspect_ratio = None
def set_type(self,disc_type = None):
if (disc_type != None):
self.disc_type = disc_type
if (disc_type == "dvd"):
self.video_rate = 5000
self.audio_rate = 224
self.final_size = "size_auto"
self.aspect_ratio = "aspect_auto"
elif (disc_type == "vcd"):
self.video_rate = 1152
self.audio_rate = 224
self.final_size = "size_352x288"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "svcd"):
self.video_rate = 2000
self.audio_rate = 224
self.final_size = "size_480x576"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "cvd"):
self.video_rate = 2000
self.audio_rate = 224
self.final_size = "size_352x576"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "divx"):
self.video_rate = 5000
self.audio_rate = 224
self.final_size = "size_auto"
self.aspect_ratio = "aspect_auto"
def delete_file(self):
@ -67,8 +97,7 @@ class file_movie(GObject.GObject):
self.wtitle.set_text(self.title_name)
def on_button_accept_clicked(self,b):
self.title_name = self.wtitle.get_text()
self.model.set_value(self.treeiter,1,self.title_name)
self.on_button_cancel_clicked(None)

View file

@ -193,9 +193,17 @@ class devede_project:
selection = self.wfiles.get_selection()
selection.mode = Gtk.SelectionMode.SINGLE
if (self.config.PAL):
self.wuse_pal.set_active(True)
else:
self.wuse_ntsc.set_active(True)
self.wmain_window.show_all()
self.set_interface_status(None)
def on_use_pal_toggled(self,b):
self.config.PAL = self.wuse_pal.get_active()
def on_wmain_window_delete_event(self,b,e=None):
ask = devede.ask.ask_window(self.config)

View file

@ -46,3 +46,4 @@ Gtk.init(sys.argv)
mwindow = devede.project.devede_project(config_data)
mwindow.ask_type()
Gtk.main()
config_data.save_config()