def completed(self, success): if success and self.f.pdf: if self.f.hasUpdatedPDF(): self.f.previewPDF() # should we embed the LilyPond source files in the PDF? from lilykde import pdftk if not self.preview and config("preferences")["embed source files"] == "1" and pdftk.installed(): pdftk.attach_files(self.f.path, 3) else: self.log.msg(_("LilyPond did not write a PDF. " "You probably forgot <b>\layout</b>?")) from lilykde import actions self.log.actions(actions.listActions(self.f, self.preview))
def runAction(url): """ Runs an URL with KRun. If url starts with "email=" or "emailpreview=", it is converted to a mailto: link with the url attached, and opened in the default KDE mailer. If url starts with "print=", the file is directly printed with lpr. If url starts with "embed=", a subroutine in pdftk is called to embed LilyPond documents in the output PDF. """ # hack: prevent QTextView recognizing mailto: urls cos it can't handle # query string url = unicode(url) # url could be a QString m = re.match("([a-z]+)=(.*)", url) if not m: return krun(url) command, url = m.groups() if command == 'print': path = unicode(KURL(url).path()) cmd = splitcommandline(config("commands").get("lpr", "lpr")) cmd.append(path) p = Popen(cmd, stderr=PIPE) if p.wait() != 0: error(_("Printing failed: %s") % p.stderr.read()) else: info(_("The document has been sent to the printer.")) elif command in ('email', 'emailpreview'): if command == "email" or warncontinue(_( "This PDF has been created with point-and-click urls (preview " "mode), which increases the file size dramatically. It's better " "to email documents without point-and-click urls (publish mode), " "because they are much smaller. Continue anyway?")): KApplication.kApplication().invokeMailer( KURL(u"mailto:?attach=%s" % url), "", True) elif command == 'embed': ly = unicode(KURL(url).path()) from lilykde import pdftk pdftk.attach_files(ly)