Ejemplo n.º 1
0
    def open(self, doc_file='', silent=False):
        if not doc_file:
            doc_file = dialogs.get_open_file_name(self.mw, self,
                                                  config.open_dir)
        if os.path.lexists(doc_file) and os.path.isfile(doc_file):
            try:
                doc = PD_Presenter(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)
                self.print_stacktrace()
                return
            except:
                msg = _('Cannot open 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)
                self.print_stacktrace()
                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'))
Ejemplo n.º 2
0
 def new_from_template(self):
     msg = _('Select Template')
     doc_file = dialogs.get_open_file_name(self.mw, self,
                                           config.template_dir, msg)
     if os.path.lexists(doc_file) and os.path.isfile(doc_file):
         try:
             doc = PD_Presenter(self, doc_file, template=True)
         except:
             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)
             self.print_stacktrace()
             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'))
Ejemplo n.º 3
0
 def new(self):
     doc = PD_Presenter(self)
     self.docs.append(doc)
     self.set_current_doc(doc)
     events.emit(events.APP_STATUS, _('New document created'))