diff --git a/invesalius/invesalius.py b/invesalius/invesalius.py index d7d2246..f4bd176 100755 --- a/invesalius/invesalius.py +++ b/invesalius/invesalius.py @@ -48,11 +48,9 @@ class SplashScreen(wx.SplashScreen): session = Session() if not (session.ReadSession()): - session.CreateItens() + session.CreateItens() - lang = session.GetLanguage() - - if not(lang): + if not(session.ReadLanguage()): ldlg = lang_dlg.LanguageDialog() @@ -67,6 +65,7 @@ class SplashScreen(wx.SplashScreen): _ = i18n.InstallLanguage(lang) else: + lang = session.GetLanguage() _ = i18n.InstallLanguage(lang) if (lang.startswith('pt')): #Necessy, pt noted as pt_BR @@ -105,22 +104,14 @@ class SplashScreen(wx.SplashScreen): self.fc.Stop() session = Session() - if not (session.ReadSession()): - session.CreateItens() - + #if not (session.ReadSession()): + # session.CreateItens() + lang = session.GetLanguage() + print lang - if not(lang): - - ldlg = lang_dlg.LanguageDialog() - if (ldlg.ShowModal() == wx.ID_OK): - lang = ldlg.GetSelectedLanguage() - session.SetLanguage(lang) - i18n.InstallLanguage(lang) - self.ShowMain() - else: - i18n.InstallLanguage(lang) - self.ShowMain() + i18n.InstallLanguage(lang) + self.ShowMain() def ShowMain(self): diff --git a/invesalius/session.py b/invesalius/session.py index 6500452..fbfa8f3 100644 --- a/invesalius/session.py +++ b/invesalius/session.py @@ -17,7 +17,7 @@ class Session(object): def __init__(self): # ? self.temp_item = False - + ws = self.ws = WriteSession(self) ws.start() @@ -48,6 +48,8 @@ class Session(object): # Recent projects list self.recent_projects = [] + self.CreateSessionFile() + def StopRecording(self, pubsub_evt): self.ws.Stop() @@ -96,6 +98,28 @@ class Session(object): path = os.path.join(dirpath, file) os.remove(path) self.temp_item = False + + def CreateSessionFile(self): + + config = ConfigParser.RawConfigParser() + + config.add_section('session') + config.set('session', 'mode', self.mode) + config.set('session', 'status', self.project_status) + config.set('session','debug', self.debug) + config.set('session', 'language', self.language) + + config.add_section('project') + config.set('project', 'recent_projects', self.recent_projects) + + config.add_section('paths') + config.set('paths','homedir',self.homedir) + config.set('paths','tempdir',self.tempdir) + path = os.path.join(self.homedir , + '.invesalius', 'config.cfg') + configfile = open(path, 'wb') + config.write(configfile) + configfile.close() def __add_to_list(self, item): @@ -133,6 +157,17 @@ class Session(object): def SetLanguage(self, language): self.language = language + def ReadLanguage(self): + config = ConfigParser.ConfigParser() + home_path = os.path.expanduser('~') + path = os.path.join(home_path ,'.invesalius', 'config.cfg') + try: + config.read(path) + self.language = config.get('session','language') + return self.language + except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): + return False + def ReadSession(self): config = ConfigParser.ConfigParser() @@ -151,6 +186,7 @@ class Session(object): except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): return False + class WriteSession(Thread): def __init__ (self, session): -- libgit2 0.21.2