1 // SPDX-License-Identifier: GPL-2.0-or-later 2 #ifndef SEEN_SP_VERBS_H 3 #define SEEN_SP_VERBS_H 4 /* 5 * Author: 6 * Lauris Kaplinski <lauris@kaplinski.com> 7 * Ted Gould <ted@gould.cx> 8 * David Yip <yipdw@rose-hulman.edu> 9 * 10 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> 11 * Copyright (C) (date unspecified) Authors 12 13 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 14 */ 15 16 #ifdef HAVE_CONFIG_H 17 # include "config.h" // only include where actually required! 18 #endif 19 20 #include <cstring> 21 #include <string> 22 #include <glibmm/ustring.h> 23 #include <gtkmm.h> // Gtk::AccelKey 24 25 struct SPAction; 26 class SPDocument; 27 28 namespace Inkscape { 29 30 class ActionContext; 31 32 namespace UI { 33 namespace View { 34 class View; 35 } // namespace View 36 } // namespace UI 37 } // namespace Inkscape 38 39 /** 40 * This anonymous enum is used to provide a list of the Verbs 41 * which are defined statically in the verb files. There may be 42 * other verbs which are defined dynamically also. 43 */ 44 enum { 45 /* Header */ 46 SP_VERB_INVALID, /**< A dummy verb to represent doing something wrong. */ 47 SP_VERB_NONE, /**< A dummy verb to represent not having a verb. */ 48 /* File */ 49 SP_VERB_FILE_NEW, /**< A new file in a new window. */ 50 SP_VERB_FILE_OPEN, /**< Open a file. */ 51 SP_VERB_FILE_REVERT, /**< Revert this file to its original state. */ 52 SP_VERB_FILE_SAVE, /**< Save the current file with its saved filename */ 53 SP_VERB_FILE_SAVE_AS, /**< Save the current file with a new filename */ 54 SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */ 55 SP_VERB_FILE_SAVE_TEMPLATE, /**< Save the ciurrent document as template */ 56 SP_VERB_FILE_PRINT, 57 SP_VERB_FILE_VACUUM, 58 SP_VERB_FILE_IMPORT, 59 // SP_VERB_FILE_EXPORT, 60 SP_VERB_FILE_NEXT_DESKTOP, 61 SP_VERB_FILE_PREV_DESKTOP, 62 SP_VERB_FILE_CLOSE_VIEW, 63 SP_VERB_FILE_QUIT, 64 SP_VERB_FILE_TEMPLATES, 65 /* Edit */ 66 SP_VERB_EDIT_UNDO, 67 SP_VERB_EDIT_REDO, 68 SP_VERB_EDIT_CUT, 69 SP_VERB_EDIT_COPY, 70 SP_VERB_EDIT_PASTE, 71 SP_VERB_EDIT_PASTE_STYLE, 72 SP_VERB_EDIT_PASTE_SIZE, 73 SP_VERB_EDIT_PASTE_SIZE_X, 74 SP_VERB_EDIT_PASTE_SIZE_Y, 75 SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, 76 SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X, 77 SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y, 78 SP_VERB_EDIT_PASTE_IN_PLACE, 79 SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, 80 SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, 81 SP_VERB_EDIT_REMOVE_FILTER, 82 SP_VERB_EDIT_DELETE, 83 SP_VERB_EDIT_DUPLICATE, 84 SP_VERB_EDIT_CLONE, 85 SP_VERB_EDIT_UNLINK_CLONE, 86 SP_VERB_EDIT_UNLINK_CLONE_RECURSIVE, 87 SP_VERB_EDIT_RELINK_CLONE, 88 SP_VERB_EDIT_CLONE_SELECT_ORIGINAL, 89 SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, 90 SP_VERB_EDIT_SELECTION_2_MARKER, 91 SP_VERB_EDIT_SELECTION_2_GUIDES, 92 SP_VERB_EDIT_TILE, 93 SP_VERB_EDIT_UNTILE, 94 SP_VERB_EDIT_SYMBOL, 95 SP_VERB_EDIT_UNSYMBOL, 96 SP_VERB_EDIT_CLEAR_ALL, 97 SP_VERB_EDIT_SELECT_ALL, 98 SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, 99 SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, 100 SP_VERB_EDIT_SELECT_SAME_FILL_COLOR, 101 SP_VERB_EDIT_SELECT_SAME_STROKE_COLOR, 102 SP_VERB_EDIT_SELECT_SAME_STROKE_STYLE, 103 SP_VERB_EDIT_SELECT_SAME_OBJECT_TYPE, 104 SP_VERB_EDIT_INVERT, 105 SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, 106 SP_VERB_EDIT_SELECT_NEXT, 107 SP_VERB_EDIT_SELECT_PREV, 108 SP_VERB_EDIT_DESELECT, 109 SP_VERB_EDIT_DELETE_ALL_GUIDES, 110 SP_VERB_EDIT_GUIDES_TOGGLE_LOCK, 111 SP_VERB_EDIT_GUIDES_AROUND_PAGE, 112 SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, 113 SP_VERB_EDIT_SWAP_FILL_STROKE, 114 /* Selection */ 115 SP_VERB_SELECTION_TO_FRONT, 116 SP_VERB_SELECTION_TO_BACK, 117 SP_VERB_SELECTION_RAISE, 118 SP_VERB_SELECTION_LOWER, 119 SP_VERB_SELECTION_STACK_UP, 120 SP_VERB_SELECTION_STACK_DOWN, 121 SP_VERB_SELECTION_GROUP, 122 SP_VERB_SELECTION_UNGROUP, 123 SP_VERB_SELECTION_UNGROUP_POP_SELECTION, 124 SP_VERB_SELECTION_TEXTTOPATH, 125 SP_VERB_SELECTION_TEXTFROMPATH, 126 SP_VERB_SELECTION_REMOVE_KERNS, 127 SP_VERB_SELECTION_UNION, 128 SP_VERB_SELECTION_INTERSECT, 129 SP_VERB_SELECTION_DIFF, 130 SP_VERB_SELECTION_SYMDIFF, 131 SP_VERB_SELECTION_CUT, 132 SP_VERB_SELECTION_SLICE, 133 SP_VERB_SELECTION_GROW, 134 SP_VERB_SELECTION_GROW_SCREEN, 135 SP_VERB_SELECTION_GROW_DOUBLE, 136 SP_VERB_SELECTION_SHRINK, 137 SP_VERB_SELECTION_SHRINK_SCREEN, 138 SP_VERB_SELECTION_SHRINK_HALVE, 139 SP_VERB_SELECTION_OFFSET, 140 SP_VERB_SELECTION_OFFSET_SCREEN, 141 SP_VERB_SELECTION_OFFSET_SCREEN_10, 142 SP_VERB_SELECTION_INSET, 143 SP_VERB_SELECTION_INSET_SCREEN, 144 SP_VERB_SELECTION_INSET_SCREEN_10, 145 SP_VERB_SELECTION_DYNAMIC_OFFSET, 146 SP_VERB_SELECTION_LINKED_OFFSET, 147 SP_VERB_SELECTION_OUTLINE, 148 SP_VERB_SELECTION_OUTLINE_LEGACY, 149 SP_VERB_SELECTION_SIMPLIFY, 150 SP_VERB_SELECTION_REVERSE, 151 SP_VERB_SELECTION_TRACE, 152 SP_VERB_SELECTION_CREATE_BITMAP, 153 SP_VERB_SELECTION_COMBINE, 154 SP_VERB_SELECTION_BREAK_APART, 155 SP_VERB_SELECTION_ARRANGE, // Former SP_VERB_SELECTION_GRIDTILE 156 SP_VERB_SELECTION_FILL_BETWEEN_MANY, 157 /* Layer */ 158 SP_VERB_LAYER_NEW, 159 SP_VERB_LAYER_RENAME, 160 SP_VERB_LAYER_NEXT, 161 SP_VERB_LAYER_PREV, 162 SP_VERB_LAYER_MOVE_TO_NEXT, 163 SP_VERB_LAYER_MOVE_TO_PREV, 164 SP_VERB_LAYER_MOVE_TO, 165 SP_VERB_LAYER_TO_TOP, 166 SP_VERB_LAYER_TO_BOTTOM, 167 SP_VERB_LAYER_RAISE, 168 SP_VERB_LAYER_LOWER, 169 SP_VERB_LAYER_DUPLICATE, 170 SP_VERB_LAYER_DELETE, 171 SP_VERB_LAYER_SOLO, 172 SP_VERB_LAYER_SHOW_ALL, 173 SP_VERB_LAYER_HIDE_ALL, 174 SP_VERB_LAYER_LOCK_ALL, 175 SP_VERB_LAYER_LOCK_OTHERS, 176 SP_VERB_LAYER_UNLOCK_ALL, 177 SP_VERB_LAYER_TOGGLE_LOCK, 178 SP_VERB_LAYER_TOGGLE_HIDE, 179 /* Object */ 180 SP_VERB_OBJECT_ROTATE_90_CW, 181 SP_VERB_OBJECT_ROTATE_90_CCW, 182 SP_VERB_OBJECT_FLATTEN, 183 SP_VERB_OBJECT_TO_CURVE, 184 SP_VERB_OBJECT_FLOW_TEXT, 185 SP_VERB_OBJECT_UNFLOW_TEXT, 186 SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, 187 SP_VERB_OBJECT_FLIP_HORIZONTAL, 188 SP_VERB_OBJECT_FLIP_VERTICAL, 189 SP_VERB_OBJECT_SET_MASK, 190 SP_VERB_OBJECT_SET_INVERSE_MASK, 191 SP_VERB_OBJECT_EDIT_MASK, 192 SP_VERB_OBJECT_UNSET_MASK, 193 SP_VERB_OBJECT_SET_CLIPPATH, 194 SP_VERB_OBJECT_SET_INVERSE_CLIPPATH, 195 SP_VERB_OBJECT_CREATE_CLIP_GROUP, 196 SP_VERB_OBJECT_EDIT_CLIPPATH, 197 SP_VERB_OBJECT_UNSET_CLIPPATH, 198 /* Tools */ 199 SP_VERB_CONTEXT_SELECT, 200 SP_VERB_CONTEXT_NODE, 201 SP_VERB_CONTEXT_TWEAK, 202 SP_VERB_CONTEXT_SPRAY, 203 SP_VERB_CONTEXT_RECT, 204 SP_VERB_CONTEXT_3DBOX, 205 SP_VERB_CONTEXT_ARC, 206 SP_VERB_CONTEXT_STAR, 207 SP_VERB_CONTEXT_SPIRAL, 208 SP_VERB_CONTEXT_PENCIL, 209 SP_VERB_CONTEXT_PEN, 210 SP_VERB_CONTEXT_CALLIGRAPHIC, 211 SP_VERB_CONTEXT_TEXT, 212 SP_VERB_CONTEXT_GRADIENT, 213 SP_VERB_CONTEXT_MESH, 214 SP_VERB_CONTEXT_ZOOM, 215 SP_VERB_CONTEXT_MEASURE, 216 SP_VERB_CONTEXT_DROPPER, 217 SP_VERB_CONTEXT_CONNECTOR, 218 SP_VERB_CONTEXT_PAINTBUCKET, 219 SP_VERB_CONTEXT_LPE, /* not really a tool but used for editing LPE parameters on-canvas for example */ 220 SP_VERB_CONTEXT_ERASER, 221 SP_VERB_CONTEXT_LPETOOL, /* note that this is very different from SP_VERB_CONTEXT_LPE above! */ 222 /* Tool preferences */ 223 SP_VERB_CONTEXT_SELECT_PREFS, 224 SP_VERB_CONTEXT_NODE_PREFS, 225 SP_VERB_CONTEXT_TWEAK_PREFS, 226 SP_VERB_CONTEXT_SPRAY_PREFS, 227 SP_VERB_CONTEXT_RECT_PREFS, 228 SP_VERB_CONTEXT_3DBOX_PREFS, 229 SP_VERB_CONTEXT_ARC_PREFS, 230 SP_VERB_CONTEXT_STAR_PREFS, 231 SP_VERB_CONTEXT_SPIRAL_PREFS, 232 SP_VERB_CONTEXT_PENCIL_PREFS, 233 SP_VERB_CONTEXT_PEN_PREFS, 234 SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, 235 SP_VERB_CONTEXT_TEXT_PREFS, 236 SP_VERB_CONTEXT_GRADIENT_PREFS, 237 SP_VERB_CONTEXT_MESH_PREFS, 238 SP_VERB_CONTEXT_ZOOM_PREFS, 239 SP_VERB_CONTEXT_MEASURE_PREFS, 240 SP_VERB_CONTEXT_DROPPER_PREFS, 241 SP_VERB_CONTEXT_CONNECTOR_PREFS, 242 SP_VERB_CONTEXT_PAINTBUCKET_PREFS, 243 SP_VERB_CONTEXT_ERASER_PREFS, 244 SP_VERB_CONTEXT_LPETOOL_PREFS, 245 246 /* Zooming */ 247 // SP_VERB_ZOOM_IN, 248 // SP_VERB_ZOOM_OUT, 249 // SP_VERB_ZOOM_NEXT, 250 // SP_VERB_ZOOM_PREV, 251 // SP_VERB_ZOOM_1_1, 252 // SP_VERB_ZOOM_1_2, 253 // SP_VERB_ZOOM_2_1, 254 // SP_VERB_ZOOM_PAGE, 255 // SP_VERB_ZOOM_PAGE_WIDTH, 256 // SP_VERB_ZOOM_DRAWING, 257 // SP_VERB_ZOOM_SELECTION, 258 // SP_VERB_ZOOM_CENTER_PAGE, 259 260 /* Canvas Rotation */ 261 // SP_VERB_ROTATE_CW, 262 // SP_VERB_ROTATE_CCW, 263 // SP_VERB_ROTATE_ZERO, 264 265 /* Canvas Flip */ 266 // SP_VERB_FLIP_HORIZONTAL, 267 // SP_VERB_FLIP_VERTICAL, 268 // SP_VERB_FLIP_NONE, 269 270 /* Desktop settings */ 271 SP_VERB_TOGGLE_COMMAND_PALETTE, 272 SP_VERB_TOGGLE_RULERS, 273 SP_VERB_TOGGLE_SCROLLBARS, 274 SP_VERB_TOGGLE_GRID, 275 SP_VERB_TOGGLE_GUIDES, 276 SP_VERB_TOGGLE_ROTATION_LOCK, 277 SP_VERB_TOGGLE_COMMANDS_TOOLBAR, 278 SP_VERB_TOGGLE_SNAP_TOOLBAR, 279 SP_VERB_TOGGLE_TOOL_TOOLBAR, 280 SP_VERB_TOGGLE_TOOLBOX, 281 SP_VERB_TOGGLE_PALETTE, 282 SP_VERB_TOGGLE_STATUSBAR, 283 SP_VERB_FULLSCREEN, 284 SP_VERB_FULLSCREENFOCUS, 285 SP_VERB_FOCUSTOGGLE, 286 SP_VERB_VIEW_NEW, 287 288 // SP_VERB_VIEW_MODE_NORMAL, 289 // SP_VERB_VIEW_MODE_NO_FILTERS, 290 // SP_VERB_VIEW_MODE_OUTLINE, 291 // SP_VERB_VIEW_MODE_VISIBLE_HAIRLINES, 292 // SP_VERB_VIEW_MODE_TOGGLE, 293 // SP_VERB_VIEW_COLOR_MODE_NORMAL, 294 // SP_VERB_VIEW_COLOR_MODE_GRAYSCALE, 295 296 // SP_VERB_VIEW_COLOR_MODE_PRINT_COLORS_PREVIEW, 297 // SP_VERB_VIEW_COLOR_MODE_TOGGLE, 298 // SP_VERB_VIEW_TOGGLE_SPLIT, 299 // SP_VERB_VIEW_TOGGLE_XRAY, 300 // SP_VERB_VIEW_CMS_TOGGLE, 301 SP_VERB_VIEW_ICON_PREVIEW, 302 303 /* Dialogs */ 304 #ifdef DEBUG 305 SP_VERB_DIALOG_PROTOTYPE, 306 #endif 307 SP_VERB_DIALOG_PREFERENCES, 308 SP_VERB_DIALOG_DOCPROPERTIES, 309 SP_VERB_DIALOG_FILL_STROKE, 310 SP_VERB_DIALOG_GLYPHS, 311 SP_VERB_DIALOG_SWATCHES, 312 SP_VERB_DIALOG_SYMBOLS, 313 SP_VERB_DIALOG_PAINT, 314 SP_VERB_DIALOG_TRANSFORM, 315 SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 316 SP_VERB_DIALOG_UNDO_HISTORY, 317 SP_VERB_DIALOG_TEXT, 318 SP_VERB_DIALOG_XML_EDITOR, 319 SP_VERB_DIALOG_SELECTORS, 320 SP_VERB_DIALOG_FIND, 321 322 #if WITH_GSPELL 323 SP_VERB_DIALOG_SPELLCHECK, 324 #endif 325 326 SP_VERB_DIALOG_DEBUG, 327 SP_VERB_DIALOG_TOGGLE, 328 SP_VERB_DIALOG_CLONETILER, 329 SP_VERB_DIALOG_ATTR, 330 SP_VERB_DIALOG_ATTR_XML, 331 SP_VERB_DIALOG_ITEM, 332 SP_VERB_DIALOG_INPUT, 333 SP_VERB_DIALOG_LAYERS, 334 SP_VERB_DIALOG_OBJECTS, 335 SP_VERB_DIALOG_STYLE, 336 SP_VERB_DIALOG_LIVE_PATH_EFFECT, 337 SP_VERB_DIALOG_FILTER_EFFECTS, 338 SP_VERB_DIALOG_SVG_FONTS, 339 SP_VERB_DIALOG_EXPORT, 340 /* Help */ 341 SP_VERB_HELP_ABOUT_EXTENSIONS, 342 SP_VERB_HELP_MEMORY, 343 SP_VERB_HELP_ABOUT, 344 // SP_VERB_SHOW_LICENSE, 345 346 /* Help URLs */ 347 SP_VERB_HELP_URL_ASK_QUESTION, 348 SP_VERB_HELP_URL_MAN, 349 SP_VERB_HELP_URL_FAQ, 350 SP_VERB_HELP_URL_KEYS, 351 SP_VERB_HELP_URL_RELEASE_NOTES, 352 SP_VERB_HELP_URL_REPORT_BUG, 353 SP_VERB_HELP_URL_MANUAL, 354 SP_VERB_HELP_URL_SVG11_SPEC, 355 SP_VERB_HELP_URL_SVG2_SPEC, 356 357 /* Tutorials */ 358 SP_VERB_TUTORIAL_BASIC, 359 SP_VERB_TUTORIAL_SHAPES, 360 SP_VERB_TUTORIAL_ADVANCED, 361 SP_VERB_TUTORIAL_TRACING, 362 SP_VERB_TUTORIAL_TRACING_PIXELART, 363 SP_VERB_TUTORIAL_CALLIGRAPHY, 364 SP_VERB_TUTORIAL_INTERPOLATE, 365 SP_VERB_TUTORIAL_DESIGN, 366 SP_VERB_TUTORIAL_TIPS, 367 /* Effects */ 368 SP_VERB_EFFECT_LAST, 369 SP_VERB_EFFECT_LAST_PREF, 370 /* Fit Canvas */ 371 SP_VERB_FIT_CANVAS_TO_SELECTION, 372 SP_VERB_FIT_CANVAS_TO_DRAWING, 373 SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, 374 /* LockAndHide */ 375 SP_VERB_UNLOCK_ALL, 376 SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, 377 SP_VERB_UNHIDE_ALL, 378 SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, 379 /* Color management */ 380 SP_VERB_EDIT_LINK_COLOR_PROFILE, 381 SP_VERB_EDIT_REMOVE_COLOR_PROFILE, 382 /*Scripting*/ 383 SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, 384 SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, 385 SP_VERB_EDIT_EMBEDDED_SCRIPT, 386 SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, 387 SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, 388 /* Alignment */ 389 SP_VERB_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR, 390 SP_VERB_ALIGN_HORIZONTAL_LEFT, 391 SP_VERB_ALIGN_HORIZONTAL_CENTER, 392 SP_VERB_ALIGN_HORIZONTAL_RIGHT, 393 SP_VERB_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR, 394 SP_VERB_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR, 395 SP_VERB_ALIGN_VERTICAL_TOP, 396 SP_VERB_ALIGN_VERTICAL_CENTER, 397 SP_VERB_ALIGN_VERTICAL_BOTTOM, 398 SP_VERB_ALIGN_VERTICAL_TOP_TO_ANCHOR, 399 SP_VERB_ALIGN_BOTH_TOP_LEFT, 400 SP_VERB_ALIGN_BOTH_TOP_RIGHT, 401 SP_VERB_ALIGN_BOTH_BOTTOM_RIGHT, 402 SP_VERB_ALIGN_BOTH_BOTTOM_LEFT, 403 SP_VERB_ALIGN_BOTH_TOP_LEFT_TO_ANCHOR, 404 SP_VERB_ALIGN_BOTH_TOP_RIGHT_TO_ANCHOR, 405 SP_VERB_ALIGN_BOTH_BOTTOM_RIGHT_TO_ANCHOR, 406 SP_VERB_ALIGN_BOTH_BOTTOM_LEFT_TO_ANCHOR, 407 SP_VERB_ALIGN_BOTH_CENTER, 408 409 /* Footer */ 410 SP_VERB_LAST 411 }; 412 413 char *sp_action_get_title (const SPAction *action); 414 415 #include <map> 416 #include <vector> 417 418 namespace Inkscape { 419 420 /** 421 * A class to represent things the user can do. In many ways 422 * these are 'action factories' as they are used to create 423 * individual actions that are based on a given view. 424 */ 425 class Verb { 426 private: 427 /** An easy to use definition of the table of verbs by code. */ 428 typedef std::map<unsigned int, Inkscape::Verb *> VerbTable; 429 430 /** A table of all the dynamically created verbs. */ 431 static VerbTable _verbs; 432 433 /** The table of statically created verbs which are mostly 434 'base verbs'. */ 435 static Verb * _base_verbs[SP_VERB_LAST + 1]; 436 /* Plus one because there is an entry for SP_VERB_LAST */ 437 438 /** A string comparison function to be used in the Verb ID lookup 439 to find the different verbs in the hash map. */ 440 struct ltstr { operatorltstr441 bool operator()(const char* s1, const char* s2) const { 442 if ( (s1 == nullptr) && (s2 != nullptr) ) { 443 return true; 444 } else if (s1 == nullptr || s2 == nullptr) { 445 return false; 446 } else { 447 return strcmp(s1, s2) < 0; 448 } 449 } 450 }; 451 452 /** An easy to use definition of the table of verbs by ID. */ 453 typedef std::map<gchar const *, Verb *, ltstr> VerbIDTable; 454 455 /** Quick lookup of verbs by ID */ 456 static VerbIDTable _verb_ids; 457 458 /** A simple typedef to make using the action table easier. */ 459 typedef std::map<Inkscape::UI::View::View *, SPAction *> ActionTable; 460 /** A list of all the actions that have been created for this 461 verb. It is referenced by the view that they are created for. */ 462 ActionTable * _actions; 463 464 /** A unique textual ID for the verb. */ 465 char const * _id; 466 467 /** The full name of the verb. (shown on menu entries) */ 468 char const * _name; 469 470 /** Tooltip for the verb. */ 471 char const * _tip; 472 473 char * _full_tip; // includes shortcut 474 475 Gtk::AccelKey _shortcut; 476 477 /** Name of the image that represents the verb. */ 478 char const * _image; 479 480 /** 481 * Unique numerical representation of the verb. In most cases 482 * it is a value from the anonymous enum at the top of this 483 * file. 484 */ 485 unsigned int _code; 486 487 /** Name of the group the verb belongs to. */ 488 char const * _group; 489 490 /** 491 * Whether this verb is set to default to sensitive or 492 * insensitive when new actions are created. 493 */ 494 bool _default_sensitive; 495 496 protected: 497 498 /** 499 * Allows for preliminary setting of the \c _default_sensitive 500 * value without effecting existing actions. 501 * This function is mostly used at initialization where there are 502 * not actions to effect. I can't think of another case where it 503 * should be used. 504 * 505 * @param in_val New value. 506 */ set_default_sensitive(bool in_val)507 bool set_default_sensitive (bool in_val) { return _default_sensitive = in_val; } 508 509 public: 510 511 /** Accessor to get the \c _default_sensitive value. */ get_default_sensitive()512 bool get_default_sensitive () { return _default_sensitive; } 513 514 /** Accessor to get the internal variable. */ get_code()515 unsigned int get_code () { return _code; } 516 517 /** Accessor to get the internal variable. */ get_id()518 char const * get_id () { return _id; } 519 520 /** Accessor to get the internal variable. */ get_name()521 char const * get_name () { return _name; } 522 523 /** Accessor to get the internal variable. */ get_short_tip()524 char const * get_short_tip () { return _tip; }; 525 526 /** Accessor to get the internal variable. */ 527 char const * get_tip () ; 528 529 /** Accessor to get the internal variable. */ get_image()530 char const * get_image () { return _image; } 531 532 /** Get the verbs group */ get_group()533 char const * get_group () { return _group; } 534 535 /** Set the name after initialization. */ set_name(char const * name)536 char const * set_name (char const * name) { _name = name; return _name; } 537 538 /** Set the tooltip after initialization. */ set_tip(char const * tip)539 char const * set_tip (char const * tip) { _tip = tip; return _tip; } 540 541 542 protected: 543 SPAction *make_action_helper (Inkscape::ActionContext const & context, void (*perform_fun)(SPAction *, void *), void *in_pntr = nullptr); 544 virtual SPAction *make_action (Inkscape::ActionContext const & context); 545 546 public: 547 548 /** 549 * Inititalizes the Verb with the parameters. 550 * 551 * This function also sets \c _actions to NULL. 552 * 553 * @warning NO DATA IS COPIED BY CALLING THIS FUNCTION. 554 * 555 * In many respects this is very bad object oriented design, but it 556 * is done for a reason. All verbs today are of two types: 1) static 557 * or 2) created for extension. In the static case all of the 558 * strings are constants in the code, and thus don't really need to 559 * be copied. In the extensions case the strings are identical to 560 * the ones already created in the extension object, copying them 561 * would be a waste of memory. 562 * 563 * @param code Goes to \c _code. 564 * @param id Goes to \c _id. 565 * @param name Goes to \c _name. 566 * @param tip Goes to \c _tip. 567 * @param image Goes to \c _image. 568 */ Verb(const unsigned int code,char const * id,char const * name,char const * tip,char const * image,char const * group)569 Verb(const unsigned int code, 570 char const * id, 571 char const * name, 572 char const * tip, 573 char const * image, 574 char const * group) : 575 _actions(nullptr), 576 _id(id), 577 _name(name), 578 _tip(tip), 579 _full_tip(nullptr), 580 _image(image), 581 _code(code), 582 _group(group), 583 _default_sensitive(true) 584 { 585 _verbs.insert(VerbTable::value_type(_code, this)); 586 _verb_ids.insert(VerbIDTable::value_type(_id, this)); 587 } 588 Verb (char const * id, char const * name, char const * tip, char const * image, char const * group); 589 virtual ~Verb (); 590 591 SPAction * get_action(Inkscape::ActionContext const & context); 592 593 private: 594 static Verb * get_search (unsigned int code); 595 public: 596 597 /** 598 * A function to turn a code into a verb. 599 * 600 * This is an inline function to translate the codes which are 601 * static quickly. This should optimize into very quick code 602 * everywhere which hard coded \c codes are used. In the case 603 * where the \c code is not static the \c get_search function 604 * is used. 605 * 606 * @param code The code to be translated 607 * @return A pointer to a verb object or a NULL if not found. 608 */ get(unsigned int code)609 static Verb * get (unsigned int code) { 610 if (code <= SP_VERB_LAST) { 611 return _base_verbs[code]; 612 } else { 613 return get_search(code); 614 } 615 } 616 static Verb * getbyid (gchar const * id, bool verbose = true); 617 618 /** 619 * Print a message to stderr indicating that this verb needs a GUI to run 620 */ 621 static bool ensure_desktop_valid(SPAction *action); 622 623 static void delete_all_view (Inkscape::UI::View::View * view); 624 void delete_view (Inkscape::UI::View::View * view); 625 626 void sensitive (SPDocument * in_doc = nullptr, bool in_sensitive = true); 627 void name (SPDocument * in_doc = nullptr, Glib::ustring in_name = ""); 628 629 // Yes, multiple public, protected and private sections are bad. We'll clean that up later 630 protected: 631 632 /** 633 * Returns the size of the internal base verb array. 634 * 635 * This is an inline function intended for testing. This should normally not be used. 636 * For testing, a subclass that returns this value can be created to verify that the 637 * length matches the enum values, etc. 638 * 639 * @return The size in elements of the internal base array. 640 */ _getBaseListSize()641 static int _getBaseListSize() {return G_N_ELEMENTS(_base_verbs);} 642 643 public: 644 static void list (); 645 static std::vector<Inkscape::Verb *>getList (); 646 647 }; /* Verb class */ 648 649 650 } /* Inkscape namespace */ 651 652 #endif // SEEN_SP_VERBS_H 653 654 /* 655 Local Variables: 656 mode:c++ 657 c-file-style:"stroustrup" 658 c-file-offsets:((innamespace . 0)(inline-open . 0)) 659 indent-tabs-mode:nil 660 fill-column:99 661 End: 662 */ 663 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : 664