예제 #1
0
    def on_export_html(self, sender: Gtk.Widget = None, event=None) -> None:
        """Export document from storage to local files or web-services.

        :param sender:
        :param event:
        :return:
        """
        doc = self.document_grid.selected_document or self.editor.document
        if not doc:
            return

        dialog = ExportFileDialog(
            _("Export document to file"),
            self,
            Gtk.FileChooserAction.SAVE
        )
        dialog.set_current_name(doc.title)
        export_format = ExportFormat.Html
        dialog.set_format(export_format)
        dialog_result = dialog.run()

        if dialog_result == Gtk.ResponseType.ACCEPT:
            self.header.show_spinner(True)
            basename, ext = os.path.splitext(dialog.get_filename())
            if ext not in export_format[1]:
                ext = export_format[1][0][1:]

            GObjectWorker.call(Exporter.export_html,
                               (basename + ext, doc),
                               callback=self.on_export_callback)

        dialog.destroy()
예제 #2
0
파일: window.py 프로젝트: TenderOwl/Norka
    def on_export_pdf(self, sender: Gtk.Widget = None, event=None) -> None:
        """Export document from storage to local files or web-services.

        :param sender:
        :param event:
        :return:
        """
        doc = self.document_grid.selected_document or self.editor.document
        if not doc:
            return

        dialog = ExportFileDialog(_("Export document to file"), self,
                                  Gtk.FileChooserAction.SAVE)
        dialog.set_current_name(doc.title)
        export_format = ExportFormat.Pdf
        dialog.set_format(export_format)
        dialog_result = dialog.run()

        if dialog_result == Gtk.ResponseType.ACCEPT:
            self.header.show_spinner(True)
            basename, ext = os.path.splitext(dialog.get_filename())
            if ext not in export_format[1]:
                ext = export_format[1][0][1:]

            pdf_exporter = PDFExporter(basename + ext, doc)
            pdf_exporter.connect('finished',
                                 lambda x, path: self.on_export_callback(path))
            pdf_exporter.print()

        dialog.destroy()