Ejemplo n.º 1
0
def listActions(lyfile, preview):
    """
    returns a actions list that LogWidget (see widgets.py) can display,
    based on the given LyFile object (see runlily.py) and the preview
    mode (True or False).
    """
    act = actionsConfig()
    actions = []
    if act["open_folder"]:
        actions.append(("file://%s" % lyfile.directory, _("Open folder")))
    if lyfile.hasUpdatedPDF():
        if act["open_pdf"]:
            actions.append(("file://%s" % lyfile.pdf, _("Open PDF")))
        if act["print_pdf"]:
            actions.append(("print=file://%s" % lyfile.pdf, _("Print")))
        if act["email_pdf"]:
            # hack: prevent QTextView from recognizing mailto urls, as
            # it then uses the mailClick signal, which does not give us
            # the query string. Later on, we prepend the "mailto:?" :)
            if preview:
                actions.append(("emailpreview=file://%s" % lyfile.pdf,
                    _("Email PDF (preview)")))
            else:
                actions.append(("email=file://%s" % lyfile.pdf,
                    _("Email PDF")))
        # should we embed the LilyPond source files in the PDF?
        from lilykde import pdftk
        if act["embed_source"] and pdftk.installed() and (preview or
                config("preferences")['embed source files'] != '1'):
            actions.append(("embed=file://%s" % lyfile.path, _("Embed source")))
    midis = lyfile.getUpdated(".midi")
    if act["play_midi"] and midis:
        actions.append(("file://%s" % midis[0], _("Play MIDI")))
        actions.extend([("file://%s" % m, str(n+1))
            for n, m in enumerate(midis[1:])])
    return actions
Ejemplo n.º 2
0
    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))