Logo Search packages:      
Sourcecode: inkscape version File versions

SPAction * Inkscape::Verb::get_action ( Inkscape::UI::View::View view  )  [inherited]

A function to get an action if it exists, or otherwise to build it.

view The view which this action would relate to
The action, or NULL if there is an error.
This function will get the action for a given view for this verb. It will create the verb if it can't be found in the ActionTable. Also, if the ActionTable has not been created, it gets created by this function.

If the action is created, it's sensitivity must be determined. The default for a new action is that it is sensitive. If the value in _default_sensitive is false, then the sensitivity must be removed. Also, if the view being created is based on the same document as a view already created, the sensitivity should be the same as views on that document. A view with the same document is looked for, and the sensitivity is matched. Unfortunately, this is currently a linear search.

Definition at line 572 of file verbs.cpp.

References Inkscape::Verb::_actions, Inkscape::Verb::_default_sensitive, Inkscape::Verb::_name, Inkscape::UI::View::View::doc(), Inkscape::Verb::make_action(), SPAction::sensitive, and sp_action_set_sensitive().

Referenced by Inkscape::UI::Widget::PageSizer::fire_fit_canvas_to_selection_or_drawing(), and sp_desktop_widget_init().

    SPAction *action = NULL;

    if ( _actions == NULL ) {
        _actions = new ActionTable;
    ActionTable::iterator action_found = _actions->find(view);

    if (action_found != _actions->end()) {
        action = action_found->second;
    } else {
        action = this->make_action(view);

        // if (action == NULL) printf("Hmm, NULL in %s\n", _name);
        if (action == NULL) printf("Hmm, NULL in %s\n", _name);
        if (!_default_sensitive) {
            sp_action_set_sensitive(action, 0);
        } else {
            for (ActionTable::iterator cur_action = _actions->begin();
                 cur_action != _actions->end() && view != NULL;
                 cur_action++) {
                if (cur_action->first != NULL && cur_action->first->doc() == view->doc()) {
                    sp_action_set_sensitive(action, cur_action->second->sensitive);

        _actions->insert(ActionTable::value_type(view, action));

    return action;

Generated by  Doxygen 1.6.0   Back to index