def open(self, doc_file='', silent=False): doc_file = doc_file or \ dialogs.get_open_file_name(self.mw, config.open_dir) if doc_file and fsutils.lexists(doc_file) and fsutils.isfile(doc_file): try: doc = SK1Presenter(self, doc_file, silent) except RuntimeError: msg = _('Cannot open file:') msg = "%s\n'%s'" % (msg, doc_file) + '\n' msg += _('The file contains newer SK2 format.\n') msg += _('Try updating sK1 application from ' 'http://www.sk1project.net') dialogs.error_dialog(self.mw, self.appdata.app_name, msg) LOG.error('Cannot open file <%s>: newer SK2 format.', doc_file) return except Exception as e: msg = _('Cannot open file:') msg = "%s\n'%s'" % (msg, doc_file) + '\n' msg += _('The file may be corrupted or not supported format.') msg += '\n' msg += _('Details see in application logs.') dialogs.error_dialog(self.mw, self.appdata.app_name, msg) LOG.error('Cannot open file <%s> %s', doc_file, e) return self.docs.append(doc) config.open_dir = str(os.path.dirname(doc_file)) self.history.add_entry(doc_file) self.set_current_doc(doc) events.emit(events.APP_STATUS, _('Document opened'))
def new_from_template(self): msg = _('Select Template') doc_file = dialogs.get_open_file_name(self.mw, config.template_dir, msg) if fsutils.isfile(doc_file): try: doc = SK1Presenter(self, doc_file, template=True) except Exception as e: msg = _('Cannot parse file:') msg = "%s\n'%s'" % (msg, doc_file) + '\n' msg += _('The file may be corrupted or not supported format') dialogs.error_dialog(self.mw, self.appdata.app_name, msg) LOG.error('Cannot parse file <%s> %s', doc_file, e) return self.docs.append(doc) config.template_dir = str(os.path.dirname(doc_file)) self.set_current_doc(doc) events.emit(events.APP_STATUS, _('New document from template'))
def new(self): doc = SK1Presenter(self) self.docs.append(doc) self.set_current_doc(doc) events.emit(events.APP_STATUS, _('New document created'))