Logo Search packages:      
Sourcecode: inkscape version File versions

SPEventContext* sp_event_context_new ( GType  type,
SPDesktop desktop,
gchar const *  pref_path,
unsigned int  key 
)

Creates new SPEventContext object and calls its virtual setup() function.

Todo:
This is bogus. pref_path should be a private property of the inheriting objects.

Definition at line 772 of file event-context.cpp.

References SPEventContext::_message_context, Inkscape::Preferences::addObserver(), SPEventContext::desktop, Inkscape::Preferences::get(), SPEventContext::key, Inkscape::UI::View::View::messageStack(), and SPEventContext::pref_observer.

Referenced by SPDesktop::push_event_context(), and SPDesktop::set_event_context().

{
    g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
    g_return_val_if_fail(desktop != NULL, NULL);

    SPEventContext *const ec = (SPEventContext*)g_object_new(type, NULL);

    ec->desktop = desktop;
    ec->_message_context = new Inkscape::MessageContext(desktop->messageStack());
    ec->key = key;
    ec->pref_observer = NULL;

    if (pref_path) {
        ec->pref_observer = new ToolPrefObserver(pref_path, ec);

        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
        prefs->addObserver(*(ec->pref_observer));
    }

    if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup)
        ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup(ec);

    return ec;
}


Generated by  Doxygen 1.6.0   Back to index