Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

bool Inkscape::Extension::Implementation::Script::load ( Inkscape::Extension::Extension module  )  [virtual]

This function 'loads' an extention, basically it determines the full command for the extention and stores that.

Returns:
none
Parameters:
module The extention to be loaded.
The most difficult part about this function is finding the actual command through all of the Reprs. Basically it is hidden down a couple of layers, and so the code has to move down too. When the command is actually found, it has its relative directory solved.

At that point all of the loops are exited, and there is an if statement to make sure they didn't exit because of not finding the command. If that's the case, the extention doesn't get loaded and should error out at a higher level.

Reimplemented from Inkscape::Extension::Implementation::Implementation.

Definition at line 359 of file script.cpp.

References Inkscape::XML::Node::attribute(), command, Inkscape::XML::Node::content(), Inkscape::Extension::Extension::get_repr(), helper_extension, Inkscape::Extension::Extension::loaded(), Inkscape::XML::Node::name(), solve_reldir(), sp_repr_children(), and sp_repr_next().

{
    if (module->loaded())
        return TRUE;

    helper_extension = "";

    /* This should probably check to find the executable... */
    Inkscape::XML::Node *child_repr = sp_repr_children(module->get_repr());
    while (child_repr != NULL) {
        if (!strcmp(child_repr->name(), "script")) {
            child_repr = sp_repr_children(child_repr);
            while (child_repr != NULL) {
                if (!strcmp(child_repr->name(), "command")) {
                    const gchar *interpretstr = child_repr->attribute("interpreter");
                    if (interpretstr != NULL) {
                        Glib::ustring interpString =
                            resolveInterpreterExecutable(interpretstr);
                        command.insert(command.end(), interpretstr);
                    }

                    command.insert(command.end(), solve_reldir(child_repr));
                }
                if (!strcmp(child_repr->name(), "helper_extension")) {
                    helper_extension = sp_repr_children(child_repr)->content();
                }
                child_repr = sp_repr_next(child_repr);
            }

            break;
        }
        child_repr = sp_repr_next(child_repr);
    }

    //g_return_val_if_fail(command.length() > 0, FALSE);

    return true;
}


Generated by  Doxygen 1.6.0   Back to index