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

@ -265,47 +265,6 @@
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Original aspect ratio:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_aspect_ratio">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Frames per second:</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label_original_videorate"> <object class="GtkLabel" id="label_original_videorate">
<property name="visible">True</property> <property name="visible">True</property>
@ -333,79 +292,53 @@
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Original aspect ratio:</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Frames per second:</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_aspect_ratio">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label_fps"> <object class="GtkLabel" id="label_fps">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Final size (pixels):</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Estimated final length (MBytes):</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_final_size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_final_length">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing> <packing>
<property name="left_attach">5</property> <property name="left_attach">5</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
@ -413,19 +346,6 @@
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>
@ -1099,16 +1019,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="size_160x128"> <object class="GtkLabel" id="label39">
<property name="label" translatable="yes">160x128</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="yalign">0.52999997138977051</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">size_auto</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -2111,6 +2024,17 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkRadioButton" id="size_176x120">
<property name="label" translatable="yes">160x120</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="yalign">0.52999997138977051</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">size_auto</property>
</object>
<object class="GtkSizeGroup" id="sizegroup1"> <object class="GtkSizeGroup" id="sizegroup1">
<widgets> <widgets>
<widget name="notebook1"/> <widget name="notebook1"/>

View file

@ -556,6 +556,7 @@
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">use_ntsc</property> <property name="group">use_ntsc</property>
<signal name="toggled" handler="on_use_pal_toggled" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -572,6 +573,7 @@
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_use_pal_toggled" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View file

@ -59,3 +59,70 @@ class configuration:
self.help_path="/usr/share/doc/devede_ng" self.help_path="/usr/share/doc/devede_ng"
self.gettext_domain = "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

@ -33,10 +33,40 @@ class file_movie(GObject.GObject):
self.treeiter = None self.treeiter = None
self.builder = 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): def set_type(self,disc_type = None):
if (disc_type != None): if (disc_type != None):
self.disc_type = disc_type 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): def delete_file(self):
@ -68,7 +98,6 @@ class file_movie(GObject.GObject):
def on_button_accept_clicked(self,b): def on_button_accept_clicked(self,b):
self.title_name = self.wtitle.get_text() self.title_name = self.wtitle.get_text()
self.model.set_value(self.treeiter,1,self.title_name) self.model.set_value(self.treeiter,1,self.title_name)
self.on_button_cancel_clicked(None) self.on_button_cancel_clicked(None)

View file

@ -193,9 +193,17 @@ class devede_project:
selection = self.wfiles.get_selection() selection = self.wfiles.get_selection()
selection.mode = Gtk.SelectionMode.SINGLE 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.wmain_window.show_all()
self.set_interface_status(None) 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): def on_wmain_window_delete_event(self,b,e=None):
ask = devede.ask.ask_window(self.config) 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 = devede.project.devede_project(config_data)
mwindow.ask_type() mwindow.ask_type()
Gtk.main() Gtk.main()
config_data.save_config()