Commit 0376b3d1 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[gui] Memorize previous writtent/opened folders

parent 3bec6ee1
......@@ -41,7 +41,7 @@
"""
Main class for Cadbiom gui
"""
import os
import gtk
import webbrowser
......@@ -98,6 +98,10 @@ class Charter(object):
self.simul_strict = True
self.sim_flat_graph = False
# working folders for FileChooser
self.previously_opened_folder = os.getcwd()
self.previously_written_folder = os.getcwd()
# common clipboard
self.clipboard = ChartClipboard()
# gui
......@@ -654,6 +658,7 @@ class Charter(object):
"""
fch = FileChooser("Export to xml Cadbiom model", "bcx files", "*.bcx")
fch.set_current_name(self.current_edit_mvc.model.name + ".bcx")
fch.set_current_folder(self.previously_written_folder)
fch.do_action(self.create_xml_file)
......@@ -670,6 +675,7 @@ class Charter(object):
mfile = open(xml_file, 'w')
mfile.write(xml.return_xml())
mfile.close()
self.previously_written_folder = os.path.dirname(xml_file)
except XmlException as xec:
cancel_warn(xec.message)
return
......@@ -680,22 +686,25 @@ class Charter(object):
"""
fch = FileChooser("Import xml Cadbiom model", "bcx files", "*.bcx",
save_window=False)
fch.set_current_folder(self.previously_opened_folder)
fch.do_action(self.import_from_xml_file)
def import_from_xml_file(self, ffile):
def import_from_xml_file(self, xml_file):
"""
As it says
"""
self.import_from_xml(ffile, ffile=True)
self.import_from_xml(xml_file, ffile=True)
self.previously_opened_folder = os.path.dirname(xml_file)
def import_from_xml(self, xml_cont, ffile=False):
def import_from_xml(self, xml_file, ffile=False):
"""
open and parse an xml file or from db
"""
if ffile:
parsing = MakeModelFromXmlFile(xml_cont)
parsing = MakeModelFromXmlFile(xml_file)
else:
parsing = MakeModelFromXmlString(xml_cont)
parsing = MakeModelFromXmlString(xml_file)
# chart model
model = parsing.get_model()
model.modified = False
......@@ -708,6 +717,7 @@ class Charter(object):
"""
fch = FileChooser("Import from Cadbiom-chart lang", "cadbiom-l", "*.cal",
save_window=False)
fch.set_current_folder(self.previously_opened_folder)
fch.do_action(self.import_from_cl_file)
def import_from_cl_file(self, ffile):
......@@ -725,6 +735,7 @@ class Charter(object):
if crep.error:
DisplayError(crep, ffile)
return
self.previously_opened_folder = os.path.dirname(ffile)
model = parser.model
self.add_edit_mvc(model.name, model, False)
self.do_layout(None, "hierarchical_LR")
......@@ -751,6 +762,7 @@ class Charter(object):
"""
fch = FileChooser("Export to Cadbiom-chart lang", "cadbiom-l", "*.cal")
fch.set_current_name(self.current_edit_mvc.model.name + ".cal")
fch.set_current_folder(self.previously_written_folder)
fch.do_action(self.compile_to_lang)
def compile_to_lang(self, file_name):
......@@ -762,6 +774,7 @@ class Charter(object):
lvi = LangVisitor(out)
self.current_edit_mvc.model.accept(lvi)
out.close()
self.previously_written_folder = os.path.dirname(file_name)
def show_doc(self, widget):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment