verbs.cpp revision ff3ee1f3aa5ce72ccec547b5be153caf2ebabed7
ffbafb085314cc47a5b400e41c229be2aa20f530JazzyNico * \brief Actions for inkscape
ffbafb085314cc47a5b400e41c229be2aa20f530JazzyNico * This file implements routines necessary to deal with verbs. A verb
ffbafb085314cc47a5b400e41c229be2aa20f530JazzyNico * is a numeric identifier used to retrieve standard SPActions for particular
ffbafb085314cc47a5b400e41c229be2aa20f530JazzyNico * Lauris Kaplinski <lauris@kaplinski.com>
8e438535e658b97ba9a47002b79758b5bf83c3f5JazzyNico * Ted Gould <ted@gould.cx>
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "dialogs/text-edit.h"
#include "dialogs/xml-tree.h"
#include "dialogs/object-properties.h"
#include "dialogs/item-properties.h"
#include "dialogs/layer-properties.h"
#include "dialogs/clonetiler.h"
#include "dialogs/iconpreview.h"
#include "dialogs/extensions.h"
#include "dialogs/swatches.h"
#include "dialogs/layers-panel.h"
#ifdef WITH_INKBOARD
#include "jabber_whiteboard/session-manager.h"
#include "tools-switch.h"
#include "inkscape-private.h"
#include "file.h"
#include "help.h"
#include "document.h"
#include "desktop.h"
#include "message-stack.h"
#include "desktop-handles.h"
#include "selection-chemistry.h"
#include "path-chemistry.h"
#include "text-chemistry.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/inkscape-preferences.h"
#include "interface.h"
#include "prefs-utils.h"
#include "splivarot.h"
#include "sp-namedview.h"
#include "sp-flowtext.h"
#include "layer-fns.h"
#include "node-context.h"
#include "select-context.h"
#include "seltrans.h"
#include "gradient-context.h"
#include "shape-editor.h"
#include "draw-context.h"
gchar *
unsigned ri = 0;
ri++;
return ret;
namespace Inkscape {
static void show_panel( Inkscape::UI::Widget::Panel &panel, char const *prefs_path, int const verb_num )
if ( dia ) {
count++;
delete _actions;
SPAction *
return NULL;
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
SPAction *
Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *vector, void *in_pntr)
sizeof(SPActionEventVector),
reinterpret_cast<void *>(_code)
sizeof(SPActionEventVector),
return action;
SPAction *
if (!_default_sensitive) {
cur_action++) {
return action;
cur_action++) {
cur_action++) {
static int count = 0;
for (int i = 0; i <= SP_VERB_LAST; i++) {
if (_base_verbs[i])
Verb *
return verb;
Verb *
return verb;
switch ((long) data) {
case SP_VERB_FILE_NEW:
case SP_VERB_FILE_OPEN:
case SP_VERB_FILE_REVERT:
case SP_VERB_FILE_SAVE:
case SP_VERB_FILE_SAVE_AS:
case SP_VERB_FILE_SAVE_A_COPY:
case SP_VERB_FILE_PRINT:
case SP_VERB_FILE_VACUUM:
case SP_VERB_FILE_IMPORT:
case SP_VERB_FILE_EXPORT:
case SP_VERB_FILE_CLOSE_VIEW:
case SP_VERB_FILE_QUIT:
sp_file_exit();
if (!dt)
case SP_VERB_EDIT_UNDO:
case SP_VERB_EDIT_REDO:
case SP_VERB_EDIT_CUT:
case SP_VERB_EDIT_COPY:
case SP_VERB_EDIT_PASTE:
sp_selection_paste(false);
case SP_VERB_EDIT_PASTE_STYLE:
case SP_VERB_EDIT_PASTE_SIZE:
sp_selection_paste_size(true, true);
sp_selection_paste_size(true, false);
sp_selection_paste_size(false, true);
sp_selection_paste_size_separately(true, true);
sp_selection_paste_size_separately(true, false);
sp_selection_paste_size_separately(false, true);
sp_selection_paste(true);
case SP_VERB_EDIT_DELETE:
case SP_VERB_EDIT_DUPLICATE:
case SP_VERB_EDIT_CLONE:
case SP_VERB_EDIT_TILE:
case SP_VERB_EDIT_UNTILE:
case SP_VERB_EDIT_CLEAR_ALL:
case SP_VERB_EDIT_SELECT_ALL:
case SP_VERB_EDIT_INVERT:
case SP_VERB_EDIT_SELECT_NEXT:
case SP_VERB_EDIT_SELECT_PREV:
case SP_VERB_EDIT_DESELECT:
if (!dt)
case SP_VERB_SELECTION_RAISE:
case SP_VERB_SELECTION_LOWER:
case SP_VERB_SELECTION_GROUP:
case SP_VERB_SELECTION_UNION:
case SP_VERB_SELECTION_DIFF:
case SP_VERB_SELECTION_CUT:
case SP_VERB_SELECTION_SLICE:
case SP_VERB_SELECTION_OFFSET:
case SP_VERB_SELECTION_INSET:
case SP_VERB_SELECTION_TRACE:
switch (verb) {
case SP_VERB_LAYER_NEW: {
case SP_VERB_LAYER_RENAME: {
case SP_VERB_LAYER_NEXT: {
if (next) {
case SP_VERB_LAYER_PREV: {
if (prev) {
case SP_VERB_LAYER_MOVE_TO_NEXT: {
case SP_VERB_LAYER_MOVE_TO_PREV: {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_LOWER: {
switch (verb) {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_LOWER:
switch (verb) {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_LOWER:
if (message) {
case SP_VERB_LAYER_DELETE: {
if (!survivor) {
if (survivor) {
if (!dt)
if (!bbox) {
if (tools_isactive(dt, TOOLS_SELECT) && sel->center() && SP_SELECT_CONTEXT(ec)->_seltrans->centerIsVisible())
case SP_VERB_OBJECT_FLATTEN:
case SP_VERB_OBJECT_TO_CURVE:
case SP_VERB_OBJECT_FLOW_TEXT:
text_unflow();
if (active_node) {
if (active_node) {
case SP_VERB_OBJECT_SET_MASK:
sp_selection_set_mask(false, false);
sp_selection_unset_mask(false);
sp_selection_set_mask(true, false);
sp_selection_unset_mask(true);
int vidx;
if (!dt)
if (tool_action) {
switch (verb) {
case SP_VERB_CONTEXT_SELECT:
case SP_VERB_CONTEXT_NODE:
case SP_VERB_CONTEXT_TWEAK:
case SP_VERB_CONTEXT_RECT:
case SP_VERB_CONTEXT_3DBOX:
case SP_VERB_CONTEXT_ARC:
case SP_VERB_CONTEXT_STAR:
case SP_VERB_CONTEXT_SPIRAL:
case SP_VERB_CONTEXT_PENCIL:
case SP_VERB_CONTEXT_PEN:
case SP_VERB_CONTEXT_TEXT:
case SP_VERB_CONTEXT_GRADIENT:
case SP_VERB_CONTEXT_ZOOM:
case SP_VERB_CONTEXT_DROPPER:
if (!dt)
(void)doc;
(void)repr;
if (!dt)
case SP_VERB_ZOOM_IN:
case SP_VERB_ZOOM_OUT:
case SP_VERB_ZOOM_1_1:
case SP_VERB_ZOOM_1_2:
case SP_VERB_ZOOM_2_1:
case SP_VERB_ZOOM_PAGE:
case SP_VERB_ZOOM_PAGE_WIDTH:
case SP_VERB_ZOOM_DRAWING:
case SP_VERB_ZOOM_SELECTION:
case SP_VERB_ZOOM_NEXT:
case SP_VERB_ZOOM_PREV:
case SP_VERB_TOGGLE_RULERS:
case SP_VERB_TOGGLE_GUIDES:
case SP_VERB_TOGGLE_GRID:
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
case SP_VERB_FULLSCREEN:
case SP_VERB_VIEW_NEW:
case SP_VERB_VIEW_NEW_PREVIEW:
case SP_VERB_VIEW_MODE_NORMAL:
case SP_VERB_VIEW_MODE_TOGGLE:
show_panel( Inkscape::UI::Dialogs::IconPreviewPanel::getInstance(), "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW );
case SP_VERB_DIALOG_DISPLAY:
case SP_VERB_DIALOG_METADATA:
case SP_VERB_DIALOG_NAMEDVIEW:
case SP_VERB_DIALOG_SWATCHES:
show_panel( Inkscape::UI::Dialogs::SwatchesPanel::getInstance(), "dialogs.swatches", SP_VERB_DIALOG_SWATCHES);
case SP_VERB_DIALOG_TRANSFORM:
case SP_VERB_DIALOG_TEXT:
case SP_VERB_DIALOG_FIND:
case SP_VERB_DIALOG_DEBUG:
case SP_VERB_DIALOG_SCRIPT:
case SP_VERB_DIALOG_TOGGLE:
case SP_VERB_DIALOG_ITEM:
#ifdef WITH_INKBOARD
case SP_VERB_XMPP_CLIENT:
case SP_VERB_DIALOG_INPUT:
case SP_VERB_DIALOG_LAYERS:
show_panel( Inkscape::UI::Dialogs::LayersPanel::getInstance(), "dialogs.layers", SP_VERB_DIALOG_LAYERS );
case SP_VERB_HELP_KEYS:
/* TRANSLATORS: If you have translated the keys.svg file to your language, then
translate this string as "keys.LANG.svg" (where LANG is your language code);
otherwise leave as "keys.svg". */
case SP_VERB_HELP_ABOUT:
case SP_VERB_HELP_ABOUT_EXTENSIONS: {
// TRANSLATORS: See "tutorial-basic.svg" comment.
sp_help_open_tutorial(NULL, (gpointer) _("gpl-2.svg"));
case SP_VERB_HELP_MEMORY:
case SP_VERB_TUTORIAL_BASIC:
/* TRANSLATORS: If you have translated the tutorial-basic.svg file to your language,
then translate this string as "tutorial-basic.LANG.svg" (where LANG is your language
code); otherwise leave as "tutorial-basic.svg". */
case SP_VERB_TUTORIAL_SHAPES:
// TRANSLATORS: See "tutorial-basic.svg" comment.
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_TRACING:
// TRANSLATORS: See "tutorial-basic.svg" comment.
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_DESIGN:
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_TIPS:
// TRANSLATORS: See "tutorial-basic.svg" comment.
set_default_sensitive(false);
SPAction *
switch ((long) data) {
case SP_VERB_EFFECT_LAST_PREF:
case SP_VERB_EFFECT_LAST:
set_default_sensitive(false);
SPAction *
return action;
if (!dt) return;
if (!doc) return;
switch ((long) data) {
set_default_sensitive(true);
SPAction *
return action;
if (!dt) return;
if (!doc) return;
switch ((long) data) {
case SP_VERB_UNLOCK_ALL:
case SP_VERB_UNHIDE_ALL:
/* these must be in the same order as the SP_VERB_* enum in "verbs.h" */
new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"),
N_("Revert to the last saved version of document (changes will be lost)"), GTK_STOCK_REVERT_TO_SAVED ),
new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Vac_uum Defs"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"),
new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import From Open Clip Art Library"), N_("Import a document from Open Clip Art Library"), "ocal_import"),
new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"), N_("Export this document to Open Clip Art Library"), "ocal_export"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, "EditPasteSizeSeparately", N_("Paste Size Separately"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X, "EditPasteWidthSeparately", N_("Paste Width Separately"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y, "EditPasteHeightSeparately", N_("Paste Height Separately"),
N_("Cut the selected clone's link to its original, turning it into a standalone object"), "edit_unlink_clone"),
new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"),
new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"),
new SelectionVerb(SP_VERB_SELECTION_REMOVE_KERNS, "SelectionTextRemoveKerns", N_("Remove Manual _Kerns"),
N_("Create exclusive OR of selected paths (those parts that belong to only one path)"), "exclusion"),
new SelectionVerb(SP_VERB_SELECTION_CREATE_BITMAP, "SelectionCreateBitmap", N_("_Make a Bitmap Copy"),
N_("Put text into a frame (path or shape), creating a flowed text linked to the frame object"), "flow_into_frame"),
new ContextVerb(SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "CalligraphicPrefs", N_("Calligraphic Preferences"),
new ContextVerb(SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "PaintBucketPrefs", N_("Paint Bucket Preferences"),
new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), "rulers"),
new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), "scrollbars"),
new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), "guides"),
new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"),
new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"),
N_("Edit objects' colors, gradients, stroke width, arrowheads, dash patterns..."), "fill_and_stroke"),
new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."),
N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), "edit_create_tiled_clones"),
N_("Edit the ID, locked and visible status, and other object properties"), "dialog_item_properties"),
#ifdef WITH_INKBOARD
new DialogVerb(SP_VERB_DIALOG_EXTENSIONEDITOR, "org.inkscape.dialogs.extensioneditor", N_("_Extensions..."),
new TutorialVerb(SP_VERB_TUTORIAL_CALLIGRAPHY, "TutorialsCalligraphy", N_("Inkscape: _Calligraphy"),
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION, "FitCanvasToSelection", N_("Fit Page to Selection"),
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"),
new LockAndHideVerb(SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, "UnlockAllInAllLayers", N_("Unlock All in All Layers"),
new LockAndHideVerb(SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, "UnhideAllInAllLayers", N_("Unhide All in All Layers"),