Logo Search packages:      
Sourcecode: inkscape version File versions

void SPDesktop::setDocument ( SPDocument doc  )  [virtual]

Associate document with desktop.

Todo:
fixme: refactor SPDesktop::init to use setDocument

Todo:
fixme: This condition exists to make sure the code inside is called only once on initialization. But there are surely more safe methods to accomplish this.

Reimplemented from Inkscape::UI::View::View.

Definition at line 1106 of file desktop.cpp.

References _layer_deactivated(), _layer_hierarchy_changed(), _namedview_modified(), activate_guides(), SPDocument::addUndoObserver(), Inkscape::ObjectHierarchy::clear(), Inkscape::ObjectHierarchy::connectAdded(), Inkscape::ObjectHierarchy::connectChanged(), SPDocument::connectCommit(), Inkscape::ObjectHierarchy::connectRemoved(), Inkscape::UI::View::View::doc(), and Inkscape::ObjectHierarchy::setTop().

Referenced by change_document(), and init().

{
    if (this->doc() && doc) {
        namedview->hide(this);
        sp_item_invoke_hide (SP_ITEM (sp_document_root (this->doc())), dkey);
    }

    if (_layer_hierarchy) {
        _layer_hierarchy->clear();
        delete _layer_hierarchy;
    }
    _layer_hierarchy = new Inkscape::ObjectHierarchy(NULL);
    _layer_hierarchy->connectAdded(sigc::bind(sigc::ptr_fun(_layer_activated), this));
    _layer_hierarchy->connectRemoved(sigc::bind(sigc::ptr_fun(_layer_deactivated), this));
    _layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this));
    _layer_hierarchy->setTop(SP_DOCUMENT_ROOT(doc));

    /* setup EventLog */
    event_log = new Inkscape::EventLog(doc);
    doc->addUndoObserver(*event_log);

    _commit_connection.disconnect();
    _commit_connection = doc->connectCommit(sigc::mem_fun(*this, &SPDesktop::updateNow));

    /// \todo fixme: This condition exists to make sure the code
    /// inside is called only once on initialization. But there
    /// are surely more safe methods to accomplish this.
    if (drawing) {
        NRArenaItem *ai;

        namedview = sp_document_namedview (doc, NULL);
        _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
        number = namedview->getViewCount();

        ai = sp_item_invoke_show (SP_ITEM (sp_document_root (doc)),
                SP_CANVAS_ARENA (drawing)->arena,
                dkey,
                SP_ITEM_SHOW_DISPLAY);
        if (ai) {
            nr_arena_item_add_child (SP_CANVAS_ARENA (drawing)->root, ai, NULL);
            nr_arena_item_unref (ai);
        }
        namedview->show(this);
        /* Ugly hack */
        activate_guides (true);
        /* Ugly hack */
        _namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
    }

    _document_replaced_signal.emit (this, doc);

    View::setDocument (doc);
}


Generated by  Doxygen 1.6.0   Back to index