def save_as(self):
        doc_file = '' + self.current_doc.doc_file
        if not doc_file:
            doc_file = '' + self.current_doc.doc_name
        if not os.path.splitext(doc_file)[1] == sk1doc.DOC_EXTENSION:
            doc_file = os.path.splitext(doc_file)[0] + sk1doc.DOC_EXTENSION
        if not os.path.lexists(os.path.dirname(doc_file)):
            doc_file = os.path.join(config.save_dir,
                                    os.path.basename(doc_file))
        doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
        if doc_file:
            old_file = self.current_doc.doc_file
            old_name = self.current_doc.doc_name
            self.current_doc.set_doc_file(doc_file)
            try:
                self.current_doc.save()
            except IOError:
                self.current_doc.set_doc_file(old_file, old_name)

                first = _('Cannot save document')
                sec = _('Please check file name and write permissions')
                msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

                dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec)

                return False
            config.save_dir = os.path.dirname(doc_file)
            events.emit(events.APP_STATUS, _('Document saved'))
            return True
        else:
            return False
 def open(self):
     doc_file = dialogs.get_open_file_name(self.mw, self, config.open_dir)
     if os.path.lexists(doc_file):
         try:
             doc = DocPresenter(self, doc_file)
         except:
             msg = _('Cannot open file')
             msg = "%s '%s'" % (msg, doc_file)
             sec = _('The file may be corrupted or not supported format')
             dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec)
             return
         self.docs.append(doc)
         self.set_current_doc(doc)
         config.open_dir = os.path.dirname(doc_file)
         events.emit(events.APP_STATUS, _('Document opened'))