Adding interface verbs

From Inkscape Wiki
Revision as of 07:50, 8 November 2006 by BryceHarrington (talk | contribs)
Jump to navigation Jump to search

Introduction to Verbs

Commands in Inkscape are called 'Verbs'. They permit invoking internal functionality through menus and keyboard shortcuts.

Verbs are not terribly difficult to add. You don't need to have much coding know-how in order to add a verb, and only a minimal knowledge of Inkscape internals. The aim of this page is to provide novice coders with a "paint by numbers" process that can be followed to add a new verb to Inkscape.

How to Add a Verb

First, add IDs for your new verbs to verbs.h:


The place of the ID in the list determines to which group it belongs (EditVerbs, FileVerbs, etc) - however, this is pretty arbitrary, so don't sweat if you can't find a perfect group for your verb, just use whichever makes most sense.

Then is the meat of the matter. In verbs.cpp, fill in the verb structure with the name, description, action ID, etc; also in the same file, write the actual commands that the verb will do, in a switch case in one of ::perform methods:


As you see, these verbs do different things depending on which tool you are in. Before verbification, this was coded into tool context files, and now we can remove that:

node-context.cpp select-context.cpp draw-context.cpp draw-context.cpp

(the last one required writing two functions that will be called by the verb).

Now assign the keys to the newly created verbs:


and then copy inkscape.xml to default.xml.

Note: even if you are not assigning any key, you MUST list the new verb in inkscape.xml, using a <bind> without a key. Not only this file is a keymap, but it's also a reference for keymap writers, so it must have all verbs, assigned or not.

If you added a shortcut which didn't exist before, update also doc/keys.xml.

If you want the new verb in the menu, edit menus-skeleton.cpp and insert it there in an appropriate place.

Also review the other keymaps to see if you can assign the new verb to some key that would make sense. So in adobe-illustrator.xml, I assigned the new verbs to Alt+Ctrl+[], which seems to be the same thing according to the comments:


Finally update the ReleaseNotes with your new work! :-)