def set_recent_files(self, file_name): if file_name in System.get_preferences().recent_files: System.get_preferences().recent_files.remove(file_name) System.get_preferences().recent_files.insert(0, file_name) if len(System.get_preferences().recent_files) > 10: System.get_preferences().recent_files.pop() self.main_window.menu.update_recent_files( System.get_preferences().recent_files) PreferencesPersistence.save(System.get_preferences(), System.get_user_dir())
def exit(self, widget=None, data=None): """ This method close main window. Returns: * **Types** (:class:`boolean<boolean>`) """ PreferencesPersistence.save(System.properties, System.get_user_dir()) if self.main_window.work_area.close_tabs(): Gtk.main_quit() else: return True
def test_load_save(self): System() prefs = System.get_preferences() PreferencesPersistence.save(prefs, "/tmp") PreferencesPersistence.save(prefs, "/etc") PreferencesPersistence.load("/tmp") PreferencesPersistence.load("/not") os.remove("/tmp/" + prefs.conf_file_path) code_template = self.create_code_template() code_template.name = "configuration" CodeTemplatePersistence.save_xml(code_template, "/tmp/") result = PreferencesPersistence.load("/tmp") file_name = "/tmp/" + code_template.name + ".xml" os.remove(file_name)
class TestPreferencesPersistence(TestCase): def setUp(self): """Do the test basic setup.""" self.preferencespersistence = PreferencesPersistence() # ----------------------------------------------------------------------x def test_load(self): self.assertIsNotNone(self.preferencespersistence.load()) # ----------------------------------------------------------------------x def test_save(self): preferences = Preferences() self.assertTrue(self.preferencespersistence.save(preferences)) preferences.type = "teste_preferencespersistence" self.assertTrue(self.preferencespersistence.save(preferences))
def add_recent_files(self, file_name): System.add_recent_files(file_name) self.main_window.menu.update_recent_files() PreferencesPersistence.save(System.get_preferences(), System.get_user_dir())