Version 2, last updated by Thinker Li at December 12, 2010 12:06 UTC
Python binding of the verbs and actions
Verb
Each verb contains the following fields
- an unique integer code
- an ASCII ID
- an human readable name
- an tip
- an image
- an vector
The vector implement the function of the verb. In most cases, we only implement the perform function of it. Please notice that a verb will define multiple functions. Each function has a seperate code. Here is an example
new EditVerb(SP_VERB_EDIT_UNDO, "EditUndo", N_("_Undo"), N_("Undo last action"),
GTK_STOCK_UNDO),
The code SP_VERB_EDIT_UNDO is defined.
Action
An action is composed of a view/id/name and a verb. When an action is executed, it will call all registered callbacks. When these callback functions are executed, the view associate to this action will be passed into it as well.
Therefore, when we create a new view, we need to create all necessary actions for it to execute all functions. Each action is associated to at least one verb. Each verb can implement multiple function iside it.
Python binding
From the python, we can use name to access the actions defined for a view. We can refer to the sp_ui_build_dyn_menus() for the details. In short, can can use
verb = Inkscape::Verb::getbyid(name)
to get the verb and then use verb->get_action(view) to get the action and call sp_action_perform to execute it.
The view must be the view of the current active desktop.