示例#1
0
    def effect(self):
        self.is_installed()

        # Find the script node, if present
        for node in self.svg.xpath("//svg:script[@id='JessyInk']"):
            version = node.get("jessyink:version")
            if version:
                self.msg(_(f"JessyInk script version {version} installed."))
            else:
                self.msg(_("JessyInk script installed."))

        slides = []
        master_slide = None

        for node in self.svg.descendants().get(inkex.Layer):
            if node.get("jessyink:master_slide"):
                master_slide = node
            else:
                slides.append(node)

        if master_slide is not None:
            self.msg(_("\nMaster slide:"))
            self.describe_node(master_slide, "\t",\
                ["<the number of the slide>", len(slides), "<the title of the slide>"])

        for i, slide in enumerate(slides):
            self.msg(_("\nSlide {0!s}:").format(i + 1))
            self.describe_node(slide, "\t", [i + 1, len(slides), slide.label])
示例#2
0
    def effect(self):
        self.is_installed()

        if not self.options.layerName:
            raise inkex.AbortExtension(_("Please enter a layer name."))

        node = self.svg.getElement(
            f"//*[@inkscape:groupmode='layer' "
            f"and @inkscape:label='{self.options.layerName}']")
        if node is None:
            raise inkex.AbortExtension(
                _(f"Layer '{self.options.layerName}' not found."))

        if self.options.effectIn == "default":
            node.set("jessyink:transitionIn", None)
        else:
            length = int(self.options.effectInDuration * 1000)
            node.set("jessyink:transitionIn",
                     Style(name=self.options.effectIn, length=length))

        if self.options.effectOut == "default":
            node.set("jessyink:transitionOut", None)
        else:
            length = int(self.options.effectOutDuration * 1000)
            node.set("jessyink:transitionOut",
                     Style(name=self.options.effectOut, length=length))
示例#3
0
    def effect(self):
        self.is_installed()
        # Check version.
        base_view = self.svg.xpath("//sodipodi:namedview[@id='base']")
        if base_view is None:
            raise inkex.AbortExtension(
                _("Could not obtain the selected layer for inclusion of the video element."
                  ))

        layer = self.svg.get_current_layer()
        if layer is None:
            raise inkex.AbortExtension(
                _("Could not obtain the selected layer for inclusion of the video element.\n\n"
                  ))

        template = inkex.load_svg(self.get_resource('jessyink_video.svg'))
        root = template.getroot()

        elem = layer.add(
            root.getElement("//svg:g[@jessyink:element='core.video']").copy())
        node_dict = find_internal_links(elem, root, {})
        delete_ids(elem)

        for node in node_dict.values():
            elem.insert(0, node)

        for node in node_dict.values():
            node.set_id(self.svg.get_unique_id("jessyink.core.video"),
                        backlinks=True)
示例#4
0
    def describe_autotext(self, node, prefix, dat):
        """Display information about auto-texts."""
        auto_texts = {"slide_num": dat[0], "num": dat[1], "title": dat[2]}
        for x, child in enumerate(node.xpath(".//*[@jessyink:autoText]")):
            if not x:
                self.msg(_(f"\n{prefix}Auto-texts:"))

            pid = child.getparent().get("id")
            val = auto_texts[child.get('jessyink:autoText')]
            self.msg(
                _(f'{prefix}\t"{child.text}" (object id "{pid}") will be replaced by "{val}".'
                  ))
示例#5
0
 def describe_transition(self, node, prefix, transition):
     """Display information about transitions."""
     trans = inkex.Style(node.get(f"jessyink:transition{transition}"))
     if trans:
         name = trans["name"]
         if name != "appear" and "length" in trans:
             length = int(trans["length"] / 1000.0)
             self.msg(
                 _(f"{prefix}Transition {transition}: {name} ({length!s} s)"
                   ))
         else:
             self.msg(_(f"{prefix}Transition {transition}: {name}"))
示例#6
0
    def describe_effects(self, node, prefix):
        """Display information about effects."""
        effects = sorted(self.collect_effects(node), key=lambda val: val[0])
        for x, (enum, effect) in enumerate(effects):
            ret = ""

            order = effect[0]["order"]
            if not x:
                ret += _(f"\n{prefix}Initial effect (order number {order}):")
            else:
                ret += _(f"\n{prefix}Effect {enum!s} (order number {order}):")

            for item in effect:
                eid = item["id"]
                if item["type"] == "view":
                    ret += _(
                        f"{prefix}\tView will be set according to object \"{eid}\""
                    )
                else:
                    ret += _(f"{prefix}\tObject \"{eid}\"")

                    if item["direction"] == "in":
                        ret += _(" will appear")
                    elif item["direction"] == "out":
                        ret += _(" will disappear")

                if item["name"] != "appear":
                    ret += _(" using effect \"{0}\"").format(item["name"])

                if "length" in item:
                    ret += _(" in {0!s} s").format(
                        int(item["length"]) / 1000.0)

            self.msg(ret + ".\n")
示例#7
0
    def effect(self):
        self.is_installed()

        rect = self.svg.selected.first()

        if rect is None:
            raise inkex.AbortExtension(
                _("No object selected. Please select the object you want "
                  "to assign a view to and then press apply.\n"))

        if not self.options.removeView:
            view_order = str(self.options.viewOrder)
            # Remove the view that currently has the requested order number.
            for node in rect.xpath(
                    "ancestor::svg:g[@inkscape:groupmode='layer']"
                    "/descendant::*[@jessyink:view]"):
                prop_dict = inkex.Style(node.get("jessyink:view"))

                if prop_dict["order"] == view_order:
                    node.set("jessyink:view", None)

            # Set the new view.
            rect.set(
                "jessyink:view",
                inkex.Style(
                    name="view",
                    order=view_order,
                    length=int(self.options.viewDuration * 1000),
                ))

            # Remove possible effect arguments.
            self.attr_remove('effectIn')
            self.attr_remove('effectOut')
        else:
            self.attr_remove('view')
示例#8
0
    def describe_node(self, node, prefix, dat):
        """Standard print out formatter"""

        self.msg(_(f"{prefix}Layer name: {node.label}"))
        self.describe_transition(node, prefix, "In")
        self.describe_transition(node, prefix, "Out")
        self.describe_autotext(node, prefix, dat)
        self.describe_effects(node, prefix)
示例#9
0
    def effect(self):
        self.is_installed()
        if not self.svg.selected:
            raise inkex.AbortExtension(
                _("No object selected. Please select the object you want to "
                  "assign an effect to and then press apply.\n"))

        for elem in self.svg.selected.values():
            self._process(elem, 'effectIn')
            self._process(elem, 'effectOut')
示例#10
0
    def effect(self):
        self.is_installed()
        # Remove old master slide property
        for node in self.svg.xpath("//*[@jessyink:masterSlide='masterSlide']"):
            node.set("jessyink:masterSlide", None)

        # Set new master slide.
        if self.options.layerName != "":
            nodes = self.svg.xpath(
                f"//*[@inkscape:groupmode='layer' "
                f"and @inkscape:label='{self.options.layerName}']")
            if not nodes:
                inkex.errormsg(
                    _("Layer not found. Removed current master slide selection.\n"
                      ))
            elif len(nodes) > 1:
                inkex.errormsg(
                    _("More than one layer with this name found. "
                      "Removed current master slide selection.\n"))
            else:
                nodes[0].set("jessyink:masterSlide", "masterSlide")
示例#11
0
    def effect(self):
        self.is_installed()

        if not self.svg.selected:
            inkex.errormsg(
                _("To assign an effect, please select an object.\n\n"))

        for node in self.svg.selected.get(inkex.Tspan):
            if self.options.autoText == "slideTitle":
                node.set("jessyink:autoText", "slideTitle")
            elif self.options.autoText == "slideNumber":
                node.set("jessyink:autoText", "slideNumber")
            elif self.options.autoText == "numberOfSlides":
                node.set("jessyink:autoText", "numberOfSlides")
            elif node.get("jessyink:autoText"):
                node.set("jessyink:autoText", None)