1 #define __SP_VERBS_C__
2 /**
3 * \file verbs.cpp
4 *
5 * \brief Actions for inkscape
6 *
7 * This file implements routines necessary to deal with verbs. A verb
8 * is a numeric identifier used to retrieve standard SPActions for particular
9 * views.
10 */
12 /*
13 * Authors:
14 * Lauris Kaplinski <lauris@kaplinski.com>
15 * Ted Gould <ted@gould.cx>
16 * MenTaLguY <mental@rydia.net>
17 * David Turner <novalis@gnu.org>
18 * bulia byak <buliabyak@users.sf.net>
19 *
20 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
21 * Copyright (C) (date unspecified) Authors
22 * This code is in public domain.
23 */
28 #include <gtk/gtkstock.h>
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
34 #include "helper/action.h"
36 #include <gtkmm/messagedialog.h>
37 #include <gtkmm/filechooserdialog.h>
38 #include <gtkmm/stock.h>
40 #include "dialogs/text-edit.h"
41 #include "dialogs/xml-tree.h"
42 #include "dialogs/object-properties.h"
43 #include "dialogs/item-properties.h"
44 #include "dialogs/find.h"
45 #include "dialogs/layer-properties.h"
46 #include "dialogs/clonetiler.h"
47 #include "dialogs/iconpreview.h"
48 #include "dialogs/extensions.h"
49 #include "dialogs/swatches.h"
50 #include "dialogs/layers-panel.h"
51 #include "dialogs/input.h"
53 #ifdef WITH_INKBOARD
54 #include "jabber_whiteboard/session-manager.h"
55 #endif
57 #include "extension/effect.h"
59 #include "tools-switch.h"
60 #include "inkscape-private.h"
61 #include "file.h"
62 #include "help.h"
63 #include "document.h"
64 #include "desktop.h"
65 #include "message-stack.h"
66 #include "desktop-handles.h"
67 #include "selection-chemistry.h"
68 #include "path-chemistry.h"
69 #include "text-chemistry.h"
70 #include "ui/dialog/dialog-manager.h"
71 #include "ui/dialog/inkscape-preferences.h"
72 #include "interface.h"
73 #include "prefs-utils.h"
74 #include "splivarot.h"
75 #include "sp-namedview.h"
76 #include "sp-flowtext.h"
77 #include "layer-fns.h"
78 #include "node-context.h"
79 #include "select-context.h"
80 #include "seltrans.h"
81 #include "gradient-context.h"
82 #include "shape-editor.h"
85 /**
86 * \brief Return the name without underscores and ellipsis, for use in dialog
87 * titles, etc. Allocated memory must be freed by caller.
88 */
89 gchar *
90 sp_action_get_title(SPAction const *action)
91 {
92 char const *src = action->name;
93 gchar *ret = g_new(gchar, strlen(src) + 1);
94 unsigned ri = 0;
96 for (unsigned si = 0 ; ; si++) {
97 int const c = src[si];
98 if ( c != '_' && c != '.' ) {
99 ret[ri] = c;
100 ri++;
101 if (c == '\0') {
102 return ret;
103 }
104 }
105 }
107 } // end of sp_action_get_title()
110 namespace Inkscape {
112 /// \todo !!!FIXME:: kill this, use DialogManager instead!!!
114 class PanelDialog : public Inkscape::UI::Dialog::Dialog
115 {
116 public:
117 PanelDialog(char const *prefs_path, int const verb_num) : Dialog(prefs_path, verb_num) {}
118 /*
119 virtual Glib::ustring getName() const {return "foo";}
120 virtual Glib::ustring getDesc() const {return "bar";}
121 */
122 };
124 /** \brief Utility function to get a panel displayed. */
125 static void show_panel( Inkscape::UI::Widget::Panel &panel, char const *prefs_path, int const verb_num )
126 {
127 Gtk::Container *container = panel.get_toplevel();
128 if ( &panel == container ) { // safe check?
129 //g_message("Creating new dialog to hold it");
130 PanelDialog *dia = new PanelDialog(prefs_path, verb_num);
131 Gtk::VBox *mainVBox = dia->get_vbox();
132 mainVBox->pack_start(panel);
133 dia->show_all_children();
134 dia->read_geometry();
135 dia->present();
136 } else {
137 PanelDialog *dia = dynamic_cast<PanelDialog*>(container);
138 if ( dia ) {
139 //g_message("Found an existing dialog");
140 dia->read_geometry();
141 dia->present();
142 } else {
143 g_message("Failed to find an existing dialog");
144 }
145 }
146 }
148 /** \brief A class to encompass all of the verbs which deal with
149 file operations. */
150 class FileVerb : public Verb {
151 private:
152 static void perform(SPAction *action, void *mydata, void *otherdata);
153 static SPActionEventVector vector;
154 protected:
155 virtual SPAction *make_action(Inkscape::UI::View::View *view);
156 public:
157 /** \brief Use the Verb initializer with the same parameters. */
158 FileVerb(unsigned int const code,
159 gchar const *id,
160 gchar const *name,
161 gchar const *tip,
162 gchar const *image) :
163 Verb(code, id, name, tip, image)
164 { }
165 }; /* FileVerb class */
167 /** \brief A class to encompass all of the verbs which deal with
168 edit operations. */
169 class EditVerb : public Verb {
170 private:
171 static void perform(SPAction *action, void *mydata, void *otherdata);
172 static SPActionEventVector vector;
173 protected:
174 virtual SPAction *make_action(Inkscape::UI::View::View *view);
175 public:
176 /** \brief Use the Verb initializer with the same parameters. */
177 EditVerb(unsigned int const code,
178 gchar const *id,
179 gchar const *name,
180 gchar const *tip,
181 gchar const *image) :
182 Verb(code, id, name, tip, image)
183 { }
184 }; /* EditVerb class */
186 /** \brief A class to encompass all of the verbs which deal with
187 selection operations. */
188 class SelectionVerb : public Verb {
189 private:
190 static void perform(SPAction *action, void *mydata, void *otherdata);
191 static SPActionEventVector vector;
192 protected:
193 virtual SPAction *make_action(Inkscape::UI::View::View *view);
194 public:
195 /** \brief Use the Verb initializer with the same parameters. */
196 SelectionVerb(unsigned int const code,
197 gchar const *id,
198 gchar const *name,
199 gchar const *tip,
200 gchar const *image) :
201 Verb(code, id, name, tip, image)
202 { }
203 }; /* SelectionVerb class */
205 /** \brief A class to encompass all of the verbs which deal with
206 layer operations. */
207 class LayerVerb : public Verb {
208 private:
209 static void perform(SPAction *action, void *mydata, void *otherdata);
210 static SPActionEventVector vector;
211 protected:
212 virtual SPAction *make_action(Inkscape::UI::View::View *view);
213 public:
214 /** \brief Use the Verb initializer with the same parameters. */
215 LayerVerb(unsigned int const code,
216 gchar const *id,
217 gchar const *name,
218 gchar const *tip,
219 gchar const *image) :
220 Verb(code, id, name, tip, image)
221 { }
222 }; /* LayerVerb class */
224 /** \brief A class to encompass all of the verbs which deal with
225 operations related to objects. */
226 class ObjectVerb : public Verb {
227 private:
228 static void perform(SPAction *action, void *mydata, void *otherdata);
229 static SPActionEventVector vector;
230 protected:
231 virtual SPAction *make_action(Inkscape::UI::View::View *view);
232 public:
233 /** \brief Use the Verb initializer with the same parameters. */
234 ObjectVerb(unsigned int const code,
235 gchar const *id,
236 gchar const *name,
237 gchar const *tip,
238 gchar const *image) :
239 Verb(code, id, name, tip, image)
240 { }
241 }; /* ObjectVerb class */
243 /** \brief A class to encompass all of the verbs which deal with
244 operations relative to context. */
245 class ContextVerb : public Verb {
246 private:
247 static void perform(SPAction *action, void *mydata, void *otherdata);
248 static SPActionEventVector vector;
249 protected:
250 virtual SPAction *make_action(Inkscape::UI::View::View *view);
251 public:
252 /** \brief Use the Verb initializer with the same parameters. */
253 ContextVerb(unsigned int const code,
254 gchar const *id,
255 gchar const *name,
256 gchar const *tip,
257 gchar const *image) :
258 Verb(code, id, name, tip, image)
259 { }
260 }; /* ContextVerb class */
262 /** \brief A class to encompass all of the verbs which deal with
263 zoom operations. */
264 class ZoomVerb : public Verb {
265 private:
266 static void perform(SPAction *action, void *mydata, void *otherdata);
267 static SPActionEventVector vector;
268 protected:
269 virtual SPAction *make_action(Inkscape::UI::View::View *view);
270 public:
271 /** \brief Use the Verb initializer with the same parameters. */
272 ZoomVerb(unsigned int const code,
273 gchar const *id,
274 gchar const *name,
275 gchar const *tip,
276 gchar const *image) :
277 Verb(code, id, name, tip, image)
278 { }
279 }; /* ZoomVerb class */
282 /** \brief A class to encompass all of the verbs which deal with
283 dialog operations. */
284 class DialogVerb : public Verb {
285 private:
286 static void perform(SPAction *action, void *mydata, void *otherdata);
287 static SPActionEventVector vector;
288 protected:
289 virtual SPAction *make_action(Inkscape::UI::View::View *view);
290 public:
291 /** \brief Use the Verb initializer with the same parameters. */
292 DialogVerb(unsigned int const code,
293 gchar const *id,
294 gchar const *name,
295 gchar const *tip,
296 gchar const *image) :
297 Verb(code, id, name, tip, image)
298 { }
299 }; /* DialogVerb class */
301 /** \brief A class to encompass all of the verbs which deal with
302 help operations. */
303 class HelpVerb : public Verb {
304 private:
305 static void perform(SPAction *action, void *mydata, void *otherdata);
306 static SPActionEventVector vector;
307 protected:
308 virtual SPAction *make_action(Inkscape::UI::View::View *view);
309 public:
310 /** \brief Use the Verb initializer with the same parameters. */
311 HelpVerb(unsigned int const code,
312 gchar const *id,
313 gchar const *name,
314 gchar const *tip,
315 gchar const *image) :
316 Verb(code, id, name, tip, image)
317 { }
318 }; /* HelpVerb class */
320 /** \brief A class to encompass all of the verbs which deal with
321 tutorial operations. */
322 class TutorialVerb : public Verb {
323 private:
324 static void perform(SPAction *action, void *mydata, void *otherdata);
325 static SPActionEventVector vector;
326 protected:
327 virtual SPAction *make_action(Inkscape::UI::View::View *view);
328 public:
329 /** \brief Use the Verb initializer with the same parameters. */
330 TutorialVerb(unsigned int const code,
331 gchar const *id,
332 gchar const *name,
333 gchar const *tip,
334 gchar const *image) :
335 Verb(code, id, name, tip, image)
336 { }
337 }; /* TutorialVerb class */
339 /** \brief A class to encompass all of the verbs which deal with
340 text operations. */
341 class TextVerb : public Verb {
342 private:
343 static void perform(SPAction *action, void *mydata, void *otherdata);
344 static SPActionEventVector vector;
345 protected:
346 virtual SPAction *make_action(Inkscape::UI::View::View *view);
347 public:
348 /** \brief Use the Verb initializer with the same parameters. */
349 TextVerb(unsigned int const code,
350 gchar const *id,
351 gchar const *name,
352 gchar const *tip,
353 gchar const *image) :
354 Verb(code, id, name, tip, image)
355 { }
356 }; //TextVerb : public Verb
358 Verb::VerbTable Verb::_verbs;
359 Verb::VerbIDTable Verb::_verb_ids;
361 /** \brief Create a verb without a code.
363 This function calls the other constructor for all of the parameters,
364 but generates the code. It is important to READ THE OTHER DOCUMENTATION
365 it has important details in it. To generate the code a static is
366 used which starts at the last static value: \c SP_VERB_LAST. For
367 each call it is incremented. The list of allocated verbs is kept
368 in the \c _verbs hashtable which is indexed by the \c code.
369 */
370 Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) :
371 _actions(NULL), _id(id), _name(name), _tip(tip), _image(image)
372 {
373 static int count = SP_VERB_LAST;
375 count++;
376 _code = count;
377 _verbs.insert(VerbTable::value_type(count, this));
378 _verb_ids.insert(VerbIDTable::value_type(_id, this));
380 return;
381 }
383 /** \brief Destroy a verb.
385 The only allocated variable is the _actions variable. If it has
386 been allocated it is deleted.
387 */
388 Verb::~Verb(void)
389 {
390 /// \todo all the actions need to be cleaned up first.
391 if (_actions != NULL) {
392 delete _actions;
393 }
395 return;
396 }
398 /** \brief Verbs are no good without actions. This is a place holder
399 for a function that every subclass should write. Most
400 can be written using \c make_action_helper.
401 \param view Which view the action should be created for.
402 \return NULL to represent error (this function shouldn't ever be called)
403 */
404 SPAction *
405 Verb::make_action(Inkscape::UI::View::View *view)
406 {
407 //std::cout << "make_action" << std::endl;
408 return NULL;
409 }
411 /** \brief Create an action for a \c FileVerb
412 \param view Which view the action should be created for
413 \return The built action.
415 Calls \c make_action_helper with the \c vector.
416 */
417 SPAction *
418 FileVerb::make_action(Inkscape::UI::View::View *view)
419 {
420 //std::cout << "fileverb: make_action: " << &vector << std::endl;
421 return make_action_helper(view, &vector);
422 }
424 /** \brief Create an action for a \c EditVerb
425 \param view Which view the action should be created for
426 \return The built action.
428 Calls \c make_action_helper with the \c vector.
429 */
430 SPAction *
431 EditVerb::make_action(Inkscape::UI::View::View *view)
432 {
433 //std::cout << "editverb: make_action: " << &vector << std::endl;
434 return make_action_helper(view, &vector);
435 }
437 /** \brief Create an action for a \c SelectionVerb
438 \param view Which view the action should be created for
439 \return The built action.
441 Calls \c make_action_helper with the \c vector.
442 */
443 SPAction *
444 SelectionVerb::make_action(Inkscape::UI::View::View *view)
445 {
446 return make_action_helper(view, &vector);
447 }
449 /** \brief Create an action for a \c LayerVerb
450 \param view Which view the action should be created for
451 \return The built action.
453 Calls \c make_action_helper with the \c vector.
454 */
455 SPAction *
456 LayerVerb::make_action(Inkscape::UI::View::View *view)
457 {
458 return make_action_helper(view, &vector);
459 }
461 /** \brief Create an action for a \c ObjectVerb
462 \param view Which view the action should be created for
463 \return The built action.
465 Calls \c make_action_helper with the \c vector.
466 */
467 SPAction *
468 ObjectVerb::make_action(Inkscape::UI::View::View *view)
469 {
470 return make_action_helper(view, &vector);
471 }
473 /** \brief Create an action for a \c ContextVerb
474 \param view Which view the action should be created for
475 \return The built action.
477 Calls \c make_action_helper with the \c vector.
478 */
479 SPAction *
480 ContextVerb::make_action(Inkscape::UI::View::View *view)
481 {
482 return make_action_helper(view, &vector);
483 }
485 /** \brief Create an action for a \c ZoomVerb
486 \param view Which view the action should be created for
487 \return The built action.
489 Calls \c make_action_helper with the \c vector.
490 */
491 SPAction *
492 ZoomVerb::make_action(Inkscape::UI::View::View *view)
493 {
494 return make_action_helper(view, &vector);
495 }
497 /** \brief Create an action for a \c DialogVerb
498 \param view Which view the action should be created for
499 \return The built action.
501 Calls \c make_action_helper with the \c vector.
502 */
503 SPAction *
504 DialogVerb::make_action(Inkscape::UI::View::View *view)
505 {
506 return make_action_helper(view, &vector);
507 }
509 /** \brief Create an action for a \c HelpVerb
510 \param view Which view the action should be created for
511 \return The built action.
513 Calls \c make_action_helper with the \c vector.
514 */
515 SPAction *
516 HelpVerb::make_action(Inkscape::UI::View::View *view)
517 {
518 return make_action_helper(view, &vector);
519 }
521 /** \brief Create an action for a \c TutorialVerb
522 \param view Which view the action should be created for
523 \return The built action.
525 Calls \c make_action_helper with the \c vector.
526 */
527 SPAction *
528 TutorialVerb::make_action(Inkscape::UI::View::View *view)
529 {
530 return make_action_helper(view, &vector);
531 }
533 /** \brief Create an action for a \c TextVerb
534 \param view Which view the action should be created for
535 \return The built action.
537 Calls \c make_action_helper with the \c vector.
538 */
539 SPAction *
540 TextVerb::make_action(Inkscape::UI::View::View *view)
541 {
542 return make_action_helper(view, &vector);
543 }
545 /** \brief A quick little convience function to make building actions
546 a little bit easier.
547 \param view Which view the action should be created for.
548 \param vector The function vector for the verb.
549 \return The created action.
551 This function does a couple of things. The most obvious is that
552 it allocates and creates the action. When it does this it
553 translates the \c _name and \c _tip variables. This allows them
554 to be staticly allocated easily, and get translated in the end. Then,
555 if the action gets crated, a listener is added to the action with
556 the vector that is passed in.
557 */
558 SPAction *
559 Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *vector, void *in_pntr)
560 {
561 SPAction *action;
563 //std::cout << "Adding action: " << _code << std::endl;
564 action = sp_action_new(view, _id, _(_name),
565 _(_tip), _image, this);
567 if (action != NULL) {
568 if (in_pntr == NULL) {
569 nr_active_object_add_listener(
570 (NRActiveObject *) action,
571 (NRObjectEventVector *) vector,
572 sizeof(SPActionEventVector),
573 reinterpret_cast<void *>(_code)
574 );
575 } else {
576 nr_active_object_add_listener(
577 (NRActiveObject *) action,
578 (NRObjectEventVector *) vector,
579 sizeof(SPActionEventVector),
580 in_pntr
581 );
582 }
583 }
585 return action;
586 }
588 /** \brief A function to get an action if it exists, or otherwise to
589 build it.
590 \param view The view which this action would relate to
591 \return The action, or NULL if there is an error.
593 This function will get the action for a given view for this verb. It
594 will create the verb if it can't be found in the ActionTable. Also,
595 if the \c ActionTable has not been created, it gets created by this
596 function.
598 If the action is created, it's sensitivity must be determined. The
599 default for a new action is that it is sensitive. If the value in
600 \c _default_sensitive is \c false, then the sensitivity must be
601 removed. Also, if the view being created is based on the same
602 document as a view already created, the sensitivity should be the
603 same as views on that document. A view with the same document is
604 looked for, and the sensitivity is matched. Unfortunately, this is
605 currently a linear search.
606 */
607 SPAction *
608 Verb::get_action(Inkscape::UI::View::View *view)
609 {
610 SPAction *action = NULL;
612 if ( _actions == NULL ) {
613 _actions = new ActionTable;
614 }
615 ActionTable::iterator action_found = _actions->find(view);
617 if (action_found != _actions->end()) {
618 action = action_found->second;
619 } else {
620 action = this->make_action(view);
622 // if (action == NULL) printf("Hmm, NULL in %s\n", _name);
623 if (action == NULL) printf("Hmm, NULL in %s\n", _name);
624 if (!_default_sensitive) {
625 sp_action_set_sensitive(action, 0);
626 } else {
627 for (ActionTable::iterator cur_action = _actions->begin();
628 cur_action != _actions->end() && view != NULL;
629 cur_action++) {
630 if (cur_action->first != NULL && cur_action->first->doc() == view->doc()) {
631 sp_action_set_sensitive(action, cur_action->second->sensitive);
632 break;
633 }
634 }
635 }
637 _actions->insert(ActionTable::value_type(view, action));
638 }
640 return action;
641 }
643 void
644 Verb::sensitive(SPDocument *in_doc, bool in_sensitive)
645 {
646 // printf("Setting sensitivity of \"%s\" to %d\n", _name, in_sensitive);
647 if (_actions != NULL) {
648 for (ActionTable::iterator cur_action = _actions->begin();
649 cur_action != _actions->end();
650 cur_action++) {
651 if (in_doc == NULL || (cur_action->first != NULL && cur_action->first->doc() == in_doc)) {
652 sp_action_set_sensitive(cur_action->second, in_sensitive ? 1 : 0);
653 }
654 }
655 }
657 if (in_doc == NULL) {
658 _default_sensitive = in_sensitive;
659 }
661 return;
662 }
665 void
666 Verb::name(SPDocument *in_doc, Glib::ustring in_name)
667 {
668 if (_actions != NULL) {
669 for (ActionTable::iterator cur_action = _actions->begin();
670 cur_action != _actions->end();
671 cur_action++) {
672 if (in_doc == NULL || (cur_action->first != NULL && cur_action->first->doc() == in_doc)) {
673 sp_action_set_name(cur_action->second, in_name);
674 }
675 }
676 }
677 }
679 /** \brief A function to remove the action associated with a view.
680 \param view Which view's actions should be removed.
681 \return None
683 This function looks for the action in \c _actions. If it is
684 found then it is unreferenced and the entry in the action
685 table is erased.
686 */
687 void
688 Verb::delete_view(Inkscape::UI::View::View *view)
689 {
690 if (_actions == NULL) return;
691 if (_actions->empty()) return;
693 #if 0
694 static int count = 0;
695 std::cout << count++ << std::endl;
696 #endif
698 ActionTable::iterator action_found = _actions->find(view);
700 if (action_found != _actions->end()) {
701 SPAction *action = action_found->second;
702 nr_object_unref(NR_OBJECT(action));
703 _actions->erase(action_found);
704 }
706 return;
707 }
709 /** \brief A function to delete a view from all verbs
710 \param view Which view's actions should be removed.
711 \return None
713 This function first looks through _base_verbs and deteles
714 the view from all of those views. If \c _verbs is not empty
715 then all of the entries in that table have all of the views
716 deleted also.
717 */
718 void
719 Verb::delete_all_view(Inkscape::UI::View::View *view)
720 {
721 for (int i = 0; i <= SP_VERB_LAST; i++) {
722 if (_base_verbs[i])
723 _base_verbs[i]->delete_view(view);
724 }
726 if (!_verbs.empty()) {
727 for (VerbTable::iterator thisverb = _verbs.begin();
728 thisverb != _verbs.end(); thisverb++) {
729 Inkscape::Verb *verbpntr = thisverb->second;
730 // std::cout << "Delete In Verb: " << verbpntr->_name << std::endl;
731 verbpntr->delete_view(view);
732 }
733 }
735 return;
736 }
738 /** \brief A function to turn a \c code into a Verb for dynamically
739 created Verbs.
740 \param code What code is being looked for
741 \return The found Verb of NULL if none is found.
743 This function basically just looks through the \c _verbs hash
744 table. STL does all the work.
745 */
746 Verb *
747 Verb::get_search(unsigned int code)
748 {
749 Verb *verb = NULL;
750 VerbTable::iterator verb_found = _verbs.find(code);
752 if (verb_found != _verbs.end()) {
753 verb = verb_found->second;
754 }
756 return verb;
757 }
759 /** \brief Find a Verb using it's ID
760 \param id Which id to search for
762 This function uses the \c _verb_ids has table to find the
763 verb by it's id. Should be much faster than previous
764 implementations.
765 */
766 Verb *
767 Verb::getbyid(gchar const *id)
768 {
769 Verb *verb = NULL;
770 VerbIDTable::iterator verb_found = _verb_ids.find(id);
772 if (verb_found != _verb_ids.end()) {
773 verb = verb_found->second;
774 }
776 if (verb == NULL)
777 printf("Unable to find: %s\n", id);
779 return verb;
780 }
782 /** \brief Decode the verb code and take appropriate action */
783 void
784 FileVerb::perform(SPAction *action, void *data, void *pdata)
785 {
786 #if 0
787 /* These aren't used, but are here to remind people not to use
788 the CURRENT_DOCUMENT macros unless they really have to. */
789 Inkscape::UI::View::View *current_view = sp_action_get_view(action);
790 SPDocument *current_document = current_view->doc();
791 #endif
792 switch ((long) data) {
793 case SP_VERB_FILE_NEW:
794 sp_file_new_default();
795 break;
796 case SP_VERB_FILE_OPEN:
797 sp_file_open_dialog(NULL, NULL);
798 break;
799 case SP_VERB_FILE_REVERT:
800 sp_file_revert_dialog();
801 break;
802 case SP_VERB_FILE_SAVE:
803 sp_file_save(NULL, NULL);
804 break;
805 case SP_VERB_FILE_SAVE_AS:
806 sp_file_save_as(NULL, NULL);
807 break;
808 case SP_VERB_FILE_SAVE_A_COPY:
809 sp_file_save_a_copy(NULL, NULL);
810 break;
811 case SP_VERB_FILE_PRINT:
812 sp_file_print();
813 break;
814 case SP_VERB_FILE_VACUUM:
815 sp_file_vacuum();
816 break;
817 case SP_VERB_FILE_PRINT_DIRECT:
818 sp_file_print_direct();
819 break;
820 case SP_VERB_FILE_PRINT_PREVIEW:
821 sp_file_print_preview(NULL, NULL);
822 break;
823 case SP_VERB_FILE_IMPORT:
824 sp_file_import(NULL);
825 break;
826 case SP_VERB_FILE_EXPORT:
827 sp_file_export_dialog(NULL);
828 break;
829 case SP_VERB_FILE_NEXT_DESKTOP:
830 inkscape_switch_desktops_next();
831 break;
832 case SP_VERB_FILE_PREV_DESKTOP:
833 inkscape_switch_desktops_prev();
834 break;
835 case SP_VERB_FILE_CLOSE_VIEW:
836 sp_ui_close_view(NULL);
837 break;
838 case SP_VERB_FILE_QUIT:
839 sp_file_exit();
840 break;
841 default:
842 break;
843 }
845 } // end of sp_verb_action_file_perform()
847 /** \brief Decode the verb code and take appropriate action */
848 void
849 EditVerb::perform(SPAction *action, void *data, void *pdata)
850 {
851 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
852 if (!dt)
853 return;
854 SPEventContext *ec = dt->event_context;
856 switch (reinterpret_cast<std::size_t>(data)) {
857 case SP_VERB_EDIT_UNDO:
858 sp_undo(dt, sp_desktop_document(dt));
859 break;
860 case SP_VERB_EDIT_REDO:
861 sp_redo(dt, sp_desktop_document(dt));
862 break;
863 case SP_VERB_EDIT_CUT:
864 sp_selection_cut();
865 break;
866 case SP_VERB_EDIT_COPY:
867 sp_selection_copy();
868 break;
869 case SP_VERB_EDIT_PASTE:
870 sp_selection_paste(false);
871 break;
872 case SP_VERB_EDIT_PASTE_STYLE:
873 sp_selection_paste_style();
874 break;
875 case SP_VERB_EDIT_PASTE_SIZE:
876 sp_selection_paste_size(true, true);
877 break;
878 case SP_VERB_EDIT_PASTE_SIZE_X:
879 sp_selection_paste_size(true, false);
880 break;
881 case SP_VERB_EDIT_PASTE_SIZE_Y:
882 sp_selection_paste_size(false, true);
883 break;
884 case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY:
885 sp_selection_paste_size_separately(true, true);
886 break;
887 case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X:
888 sp_selection_paste_size_separately(true, false);
889 break;
890 case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y:
891 sp_selection_paste_size_separately(false, true);
892 break;
893 case SP_VERB_EDIT_PASTE_IN_PLACE:
894 sp_selection_paste(true);
895 break;
896 case SP_VERB_EDIT_DELETE:
897 sp_selection_delete();
898 break;
899 case SP_VERB_EDIT_DUPLICATE:
900 sp_selection_duplicate();
901 break;
902 case SP_VERB_EDIT_CLONE:
903 sp_selection_clone();
904 break;
905 case SP_VERB_EDIT_UNLINK_CLONE:
906 sp_selection_unlink();
907 break;
908 case SP_VERB_EDIT_CLONE_ORIGINAL:
909 sp_select_clone_original();
910 break;
911 case SP_VERB_EDIT_TILE:
912 sp_selection_tile();
913 break;
914 case SP_VERB_EDIT_UNTILE:
915 sp_selection_untile();
916 break;
917 case SP_VERB_EDIT_CLEAR_ALL:
918 sp_edit_clear_all();
919 break;
920 case SP_VERB_EDIT_SELECT_ALL:
921 if (tools_isactive(dt, TOOLS_NODES)) {
922 SP_NODE_CONTEXT(ec)->shape_editor->select_all_from_subpath(false);
923 } else {
924 sp_edit_select_all();
925 }
926 break;
927 case SP_VERB_EDIT_INVERT:
928 if (tools_isactive(dt, TOOLS_NODES)) {
929 SP_NODE_CONTEXT(ec)->shape_editor->select_all_from_subpath(true);
930 } else {
931 sp_edit_invert();
932 }
933 break;
934 case SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS:
935 if (tools_isactive(dt, TOOLS_NODES)) {
936 SP_NODE_CONTEXT(ec)->shape_editor->select_all(false);
937 } else {
938 sp_edit_select_all_in_all_layers();
939 }
940 break;
941 case SP_VERB_EDIT_INVERT_IN_ALL_LAYERS:
942 if (tools_isactive(dt, TOOLS_NODES)) {
943 SP_NODE_CONTEXT(ec)->shape_editor->select_all(true);
944 } else {
945 sp_edit_invert_in_all_layers();
946 }
947 break;
949 case SP_VERB_EDIT_SELECT_NEXT:
950 if (tools_isactive(dt, TOOLS_NODES)) {
951 SP_NODE_CONTEXT(ec)->shape_editor->select_next();
952 } else if (tools_isactive(dt, TOOLS_GRADIENT)) {
953 sp_gradient_context_select_next (ec);
954 } else {
955 sp_selection_item_next();
956 }
957 break;
958 case SP_VERB_EDIT_SELECT_PREV:
959 if (tools_isactive(dt, TOOLS_NODES)) {
960 SP_NODE_CONTEXT(ec)->shape_editor->select_prev();
961 } else if (tools_isactive(dt, TOOLS_GRADIENT)) {
962 sp_gradient_context_select_prev (ec);
963 } else {
964 sp_selection_item_prev();
965 }
966 break;
968 case SP_VERB_EDIT_DESELECT:
969 if (tools_isactive(dt, TOOLS_NODES)) {
970 SP_NODE_CONTEXT(ec)->shape_editor->deselect();
971 } else {
972 sp_desktop_selection(dt)->clear();
973 }
974 break;
975 default:
976 break;
977 }
979 } // end of sp_verb_action_edit_perform()
981 /** \brief Decode the verb code and take appropriate action */
982 void
983 SelectionVerb::perform(SPAction *action, void *data, void *pdata)
984 {
985 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
987 if (!dt)
988 return;
990 switch (reinterpret_cast<std::size_t>(data)) {
991 case SP_VERB_SELECTION_TO_FRONT:
992 sp_selection_raise_to_top();
993 break;
994 case SP_VERB_SELECTION_TO_BACK:
995 sp_selection_lower_to_bottom();
996 break;
997 case SP_VERB_SELECTION_RAISE:
998 sp_selection_raise();
999 break;
1000 case SP_VERB_SELECTION_LOWER:
1001 sp_selection_lower();
1002 break;
1003 case SP_VERB_SELECTION_GROUP:
1004 sp_selection_group();
1005 break;
1006 case SP_VERB_SELECTION_UNGROUP:
1007 sp_selection_ungroup();
1008 break;
1010 case SP_VERB_SELECTION_TEXTTOPATH:
1011 text_put_on_path();
1012 break;
1013 case SP_VERB_SELECTION_TEXTFROMPATH:
1014 text_remove_from_path();
1015 break;
1016 case SP_VERB_SELECTION_REMOVE_KERNS:
1017 text_remove_all_kerns();
1018 break;
1020 case SP_VERB_SELECTION_UNION:
1021 sp_selected_path_union();
1022 break;
1023 case SP_VERB_SELECTION_INTERSECT:
1024 sp_selected_path_intersect();
1025 break;
1026 case SP_VERB_SELECTION_DIFF:
1027 sp_selected_path_diff();
1028 break;
1029 case SP_VERB_SELECTION_SYMDIFF:
1030 sp_selected_path_symdiff();
1031 break;
1033 case SP_VERB_SELECTION_CUT:
1034 sp_selected_path_cut();
1035 break;
1036 case SP_VERB_SELECTION_SLICE:
1037 sp_selected_path_slice();
1038 break;
1040 case SP_VERB_SELECTION_OFFSET:
1041 sp_selected_path_offset();
1042 break;
1043 case SP_VERB_SELECTION_OFFSET_SCREEN:
1044 sp_selected_path_offset_screen(1);
1045 break;
1046 case SP_VERB_SELECTION_OFFSET_SCREEN_10:
1047 sp_selected_path_offset_screen(10);
1048 break;
1049 case SP_VERB_SELECTION_INSET:
1050 sp_selected_path_inset();
1051 break;
1052 case SP_VERB_SELECTION_INSET_SCREEN:
1053 sp_selected_path_inset_screen(1);
1054 break;
1055 case SP_VERB_SELECTION_INSET_SCREEN_10:
1056 sp_selected_path_inset_screen(10);
1057 break;
1058 case SP_VERB_SELECTION_DYNAMIC_OFFSET:
1059 sp_selected_path_create_offset_object_zero();
1060 tools_switch_current(TOOLS_NODES);
1061 break;
1062 case SP_VERB_SELECTION_LINKED_OFFSET:
1063 sp_selected_path_create_updating_offset_object_zero();
1064 tools_switch_current(TOOLS_NODES);
1065 break;
1067 case SP_VERB_SELECTION_OUTLINE:
1068 sp_selected_path_outline();
1069 break;
1070 case SP_VERB_SELECTION_SIMPLIFY:
1071 sp_selected_path_simplify();
1072 break;
1073 case SP_VERB_SELECTION_REVERSE:
1074 sp_selected_path_reverse();
1075 break;
1076 case SP_VERB_SELECTION_TRACE:
1077 dt->_dlg_mgr->showDialog("Trace");
1078 break;
1079 case SP_VERB_SELECTION_CREATE_BITMAP:
1080 sp_selection_create_bitmap_copy();
1081 break;
1083 case SP_VERB_SELECTION_COMBINE:
1084 sp_selected_path_combine();
1085 break;
1086 case SP_VERB_SELECTION_BREAK_APART:
1087 sp_selected_path_break_apart();
1088 break;
1089 case SP_VERB_SELECTION_GRIDTILE:
1090 dt->_dlg_mgr->showDialog("TileDialog");
1091 break;
1092 default:
1093 break;
1094 }
1096 } // end of sp_verb_action_selection_perform()
1098 /** \brief Decode the verb code and take appropriate action */
1099 void
1100 LayerVerb::perform(SPAction *action, void *data, void *pdata)
1101 {
1102 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1103 unsigned int verb = reinterpret_cast<std::size_t>(data);
1105 if ( !dt || !dt->currentLayer() ) {
1106 return;
1107 }
1109 switch (verb) {
1110 case SP_VERB_LAYER_NEW: {
1111 Inkscape::UI::Dialogs::LayerPropertiesDialog::showCreate(dt, dt->currentLayer());
1112 break;
1113 }
1114 case SP_VERB_LAYER_RENAME: {
1115 Inkscape::UI::Dialogs::LayerPropertiesDialog::showRename(dt, dt->currentLayer());
1116 break;
1117 }
1118 case SP_VERB_LAYER_NEXT: {
1119 SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
1120 if (next) {
1121 dt->setCurrentLayer(next);
1122 sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT,
1123 _("Move to next layer"));
1124 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Moved to next layer."));
1125 } else {
1126 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot move past last layer."));
1127 }
1128 break;
1129 }
1130 case SP_VERB_LAYER_PREV: {
1131 SPObject *prev=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
1132 if (prev) {
1133 dt->setCurrentLayer(prev);
1134 sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_PREV,
1135 _("Move to previous layer"));
1136 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Moved to previous layer."));
1137 } else {
1138 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot move past first layer."));
1139 }
1140 break;
1141 }
1142 case SP_VERB_LAYER_MOVE_TO_NEXT: {
1143 sp_selection_to_next_layer();
1144 break;
1145 }
1146 case SP_VERB_LAYER_MOVE_TO_PREV: {
1147 sp_selection_to_prev_layer();
1148 break;
1149 }
1150 case SP_VERB_LAYER_TO_TOP:
1151 case SP_VERB_LAYER_TO_BOTTOM:
1152 case SP_VERB_LAYER_RAISE:
1153 case SP_VERB_LAYER_LOWER: {
1154 if ( dt->currentLayer() == dt->currentRoot() ) {
1155 dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer."));
1156 return;
1157 }
1159 SPItem *layer=SP_ITEM(dt->currentLayer());
1160 g_return_if_fail(layer != NULL);
1162 SPObject *old_pos=SP_OBJECT_NEXT(layer);
1164 switch (verb) {
1165 case SP_VERB_LAYER_TO_TOP:
1166 layer->raiseToTop();
1167 break;
1168 case SP_VERB_LAYER_TO_BOTTOM:
1169 layer->lowerToBottom();
1170 break;
1171 case SP_VERB_LAYER_RAISE:
1172 layer->raiseOne();
1173 break;
1174 case SP_VERB_LAYER_LOWER:
1175 layer->lowerOne();
1176 break;
1177 }
1179 if ( SP_OBJECT_NEXT(layer) != old_pos ) {
1180 char const *message = NULL;
1181 Glib::ustring description = "";
1182 switch (verb) {
1183 case SP_VERB_LAYER_TO_TOP:
1184 message = g_strdup_printf(_("Raised layer <b>%s</b>."), layer->defaultLabel());
1185 description = _("Layer to top");
1186 break;
1187 case SP_VERB_LAYER_RAISE:
1188 message = g_strdup_printf(_("Raised layer <b>%s</b>."), layer->defaultLabel());
1189 description = _("Raise layer");
1190 break;
1191 case SP_VERB_LAYER_TO_BOTTOM:
1192 message = g_strdup_printf(_("Lowered layer <b>%s</b>."), layer->defaultLabel());
1193 description = _("Layer to bottom");
1194 break;
1195 case SP_VERB_LAYER_LOWER:
1196 message = g_strdup_printf(_("Lowered layer <b>%s</b>."), layer->defaultLabel());
1197 description = _("Lower layer");
1198 break;
1199 };
1200 sp_document_done(sp_desktop_document(dt), verb, description);
1201 if (message) {
1202 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
1203 g_free((void *) message);
1204 }
1205 } else {
1206 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot move layer any further."));
1207 }
1209 break;
1210 }
1211 case SP_VERB_LAYER_DELETE: {
1212 if ( dt->currentLayer() != dt->currentRoot() ) {
1213 sp_desktop_selection(dt)->clear();
1214 SPObject *old_layer=dt->currentLayer();
1216 sp_object_ref(old_layer, NULL);
1217 SPObject *survivor=Inkscape::next_layer(dt->currentRoot(), old_layer);
1218 if (!survivor) {
1219 survivor = Inkscape::previous_layer(dt->currentRoot(), old_layer);
1220 }
1222 /* Deleting the old layer before switching layers is a hack to trigger the
1223 * listeners of the deletion event (as happens when old_layer is deleted using the
1224 * xml editor). See
1225 * http://sourceforge.net/tracker/index.php?func=detail&aid=1339397&group_id=93438&atid=604306
1226 */
1227 old_layer->deleteObject();
1228 sp_object_unref(old_layer, NULL);
1229 if (survivor) {
1230 dt->setCurrentLayer(survivor);
1231 }
1233 sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE,
1234 _("Delete layer"));
1236 // TRANSLATORS: this means "The layer has been deleted."
1237 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Deleted layer."));
1238 } else {
1239 dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer."));
1240 }
1241 break;
1242 }
1243 }
1245 return;
1246 } // end of sp_verb_action_layer_perform()
1248 /** \brief Decode the verb code and take appropriate action */
1249 void
1250 ObjectVerb::perform( SPAction *action, void *data, void *pdata )
1251 {
1252 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1253 if (!dt)
1254 return;
1256 SPEventContext *ec = dt->event_context;
1258 Inkscape::Selection *sel = sp_desktop_selection(dt);
1260 if (sel->isEmpty())
1261 return;
1263 NR::Maybe<NR::Rect> bbox = sel->bounds();
1264 if (!bbox) {
1265 return;
1266 }
1267 // If the rotation center of the selection is visible, choose it as reference point
1268 // for horizontal and vertical flips. Otherwise, take the center of the bounding box.
1269 NR::Point center;
1270 if (tools_isactive(dt, TOOLS_SELECT) && sel->center() && SP_SELECT_CONTEXT(ec)->_seltrans->centerIsVisible())
1271 center = *sel->center();
1272 else
1273 center = bbox->midpoint();
1275 switch (reinterpret_cast<std::size_t>(data)) {
1276 case SP_VERB_OBJECT_ROTATE_90_CW:
1277 sp_selection_rotate_90_cw();
1278 break;
1279 case SP_VERB_OBJECT_ROTATE_90_CCW:
1280 sp_selection_rotate_90_ccw();
1281 break;
1282 case SP_VERB_OBJECT_FLATTEN:
1283 sp_selection_remove_transform();
1284 break;
1285 case SP_VERB_OBJECT_TO_CURVE:
1286 sp_selected_path_to_curves();
1287 break;
1288 case SP_VERB_OBJECT_FLOW_TEXT:
1289 text_flow_into_shape();
1290 break;
1291 case SP_VERB_OBJECT_UNFLOW_TEXT:
1292 text_unflow();
1293 break;
1294 case SP_VERB_OBJECT_FLOWTEXT_TO_TEXT:
1295 flowtext_to_text();
1296 break;
1297 case SP_VERB_OBJECT_FLIP_HORIZONTAL:
1298 // When working with the node tool ...
1299 if (tools_isactive(dt, TOOLS_NODES)) {
1300 Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
1302 // ... and one of the nodes is currently mouseovered ...
1303 if (active_node) {
1305 // ... flip the selected nodes about that node
1306 SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::X, active_node->pos);
1307 } else {
1309 // ... or else about the center of their bounding box.
1310 SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::X);
1311 }
1313 // When working with the selector tool, flip the selection about its rotation center
1314 // (if it is visible) or about the center of the bounding box.
1315 } else {
1316 sp_selection_scale_relative(sel, center, NR::scale(-1.0, 1.0));
1317 }
1318 sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL,
1319 _("Flip horizontally"));
1320 break;
1321 case SP_VERB_OBJECT_FLIP_VERTICAL:
1322 // The behaviour is analogous to flipping horizontally
1323 if (tools_isactive(dt, TOOLS_NODES)) {
1324 Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
1325 if (active_node) {
1326 SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::Y, active_node->pos);
1327 } else {
1328 SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::Y);
1329 }
1330 } else {
1331 sp_selection_scale_relative(sel, center, NR::scale(1.0, -1.0));
1332 }
1333 sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL,
1334 _("Flip vertically"));
1335 break;
1336 case SP_VERB_OBJECT_SET_MASK:
1337 sp_selection_set_mask(false, false);
1338 break;
1339 case SP_VERB_OBJECT_UNSET_MASK:
1340 sp_selection_unset_mask(false);
1341 break;
1342 case SP_VERB_OBJECT_SET_CLIPPATH:
1343 sp_selection_set_mask(true, false);
1344 break;
1345 case SP_VERB_OBJECT_UNSET_CLIPPATH:
1346 sp_selection_unset_mask(true);
1347 break;
1348 default:
1349 break;
1350 }
1352 } // end of sp_verb_action_object_perform()
1354 /** \brief Decode the verb code and take appropriate action */
1355 void
1356 ContextVerb::perform(SPAction *action, void *data, void *pdata)
1357 {
1358 SPDesktop *dt;
1359 sp_verb_t verb;
1360 int vidx;
1362 dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1364 if (!dt)
1365 return;
1367 verb = (sp_verb_t)GPOINTER_TO_INT((gpointer)data);
1369 /** \todo !!! hopefully this can go away soon and actions can look after
1370 * themselves
1371 */
1372 for (vidx = SP_VERB_CONTEXT_SELECT; vidx <= SP_VERB_CONTEXT_PAINTBUCKET_PREFS; vidx++)
1373 {
1374 SPAction *tool_action= get((sp_verb_t)vidx)->get_action(dt);
1375 if (tool_action) {
1376 sp_action_set_active(tool_action, vidx == (int)verb);
1377 }
1378 }
1380 switch (verb) {
1381 case SP_VERB_CONTEXT_SELECT:
1382 tools_switch_current(TOOLS_SELECT);
1383 break;
1384 case SP_VERB_CONTEXT_NODE:
1385 tools_switch_current(TOOLS_NODES);
1386 break;
1387 case SP_VERB_CONTEXT_RECT:
1388 tools_switch_current(TOOLS_SHAPES_RECT);
1389 break;
1390 case SP_VERB_CONTEXT_ARC:
1391 tools_switch_current(TOOLS_SHAPES_ARC);
1392 break;
1393 case SP_VERB_CONTEXT_STAR:
1394 tools_switch_current(TOOLS_SHAPES_STAR);
1395 break;
1396 case SP_VERB_CONTEXT_SPIRAL:
1397 tools_switch_current(TOOLS_SHAPES_SPIRAL);
1398 break;
1399 case SP_VERB_CONTEXT_PENCIL:
1400 tools_switch_current(TOOLS_FREEHAND_PENCIL);
1401 break;
1402 case SP_VERB_CONTEXT_PEN:
1403 tools_switch_current(TOOLS_FREEHAND_PEN);
1404 break;
1405 case SP_VERB_CONTEXT_CALLIGRAPHIC:
1406 tools_switch_current(TOOLS_CALLIGRAPHIC);
1407 break;
1408 case SP_VERB_CONTEXT_TEXT:
1409 tools_switch_current(TOOLS_TEXT);
1410 break;
1411 case SP_VERB_CONTEXT_GRADIENT:
1412 tools_switch_current(TOOLS_GRADIENT);
1413 break;
1414 case SP_VERB_CONTEXT_ZOOM:
1415 tools_switch_current(TOOLS_ZOOM);
1416 break;
1417 case SP_VERB_CONTEXT_DROPPER:
1418 tools_switch_current(TOOLS_DROPPER);
1419 break;
1420 case SP_VERB_CONTEXT_CONNECTOR:
1421 tools_switch_current (TOOLS_CONNECTOR);
1422 break;
1423 case SP_VERB_CONTEXT_PAINTBUCKET:
1424 tools_switch_current(TOOLS_PAINTBUCKET);
1425 break;
1427 case SP_VERB_CONTEXT_SELECT_PREFS:
1428 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SELECTOR);
1429 dt->_dlg_mgr->showDialog("InkscapePreferences");
1430 break;
1431 case SP_VERB_CONTEXT_NODE_PREFS:
1432 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_NODE);
1433 dt->_dlg_mgr->showDialog("InkscapePreferences");
1434 break;
1435 case SP_VERB_CONTEXT_RECT_PREFS:
1436 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_RECT);
1437 dt->_dlg_mgr->showDialog("InkscapePreferences");
1438 break;
1439 case SP_VERB_CONTEXT_ARC_PREFS:
1440 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
1441 dt->_dlg_mgr->showDialog("InkscapePreferences");
1442 break;
1443 case SP_VERB_CONTEXT_STAR_PREFS:
1444 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_STAR);
1445 dt->_dlg_mgr->showDialog("InkscapePreferences");
1446 break;
1447 case SP_VERB_CONTEXT_SPIRAL_PREFS:
1448 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
1449 dt->_dlg_mgr->showDialog("InkscapePreferences");
1450 break;
1451 case SP_VERB_CONTEXT_PENCIL_PREFS:
1452 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PENCIL);
1453 dt->_dlg_mgr->showDialog("InkscapePreferences");
1454 break;
1455 case SP_VERB_CONTEXT_PEN_PREFS:
1456 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PEN);
1457 dt->_dlg_mgr->showDialog("InkscapePreferences");
1458 break;
1459 case SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS:
1460 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_CALLIGRAPHY);
1461 dt->_dlg_mgr->showDialog("InkscapePreferences");
1462 break;
1463 case SP_VERB_CONTEXT_TEXT_PREFS:
1464 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_TEXT);
1465 dt->_dlg_mgr->showDialog("InkscapePreferences");
1466 break;
1467 case SP_VERB_CONTEXT_GRADIENT_PREFS:
1468 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_GRADIENT);
1469 dt->_dlg_mgr->showDialog("InkscapePreferences");
1470 break;
1471 case SP_VERB_CONTEXT_ZOOM_PREFS:
1472 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_ZOOM);
1473 dt->_dlg_mgr->showDialog("InkscapePreferences");
1474 break;
1475 case SP_VERB_CONTEXT_DROPPER_PREFS:
1476 prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_DROPPER);
1477 dt->_dlg_mgr->showDialog("InkscapePreferences");
1478 break;
1479 case SP_VERB_CONTEXT_CONNECTOR_PREFS:
1480 prefs_set_int_attribute ("dialogs.preferences", "page", PREFS_PAGE_TOOLS_CONNECTOR);
1481 dt->_dlg_mgr->showDialog("InkscapePreferences");
1482 break;
1483 case SP_VERB_CONTEXT_PAINTBUCKET_PREFS:
1484 prefs_set_int_attribute ("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PAINTBUCKET);
1485 dt->_dlg_mgr->showDialog("InkscapePreferences");
1486 break;
1488 default:
1489 break;
1490 }
1492 } // end of sp_verb_action_ctx_perform()
1494 /** \brief Decode the verb code and take appropriate action */
1495 void
1496 TextVerb::perform(SPAction *action, void *data, void *pdata)
1497 {
1498 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1499 if (!dt)
1500 return;
1502 SPDocument *doc = sp_desktop_document(dt);
1503 (void)doc;
1504 Inkscape::XML::Node *repr = SP_OBJECT_REPR(dt->namedview);
1505 (void)repr;
1506 }
1508 /** \brief Decode the verb code and take appropriate action */
1509 void
1510 ZoomVerb::perform(SPAction *action, void *data, void *pdata)
1511 {
1512 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1513 if (!dt)
1514 return;
1516 SPDocument *doc = sp_desktop_document(dt);
1518 Inkscape::XML::Node *repr = SP_OBJECT_REPR(dt->namedview);
1520 gdouble zoom_inc =
1521 prefs_get_double_attribute_limited( "options.zoomincrement",
1522 "value", 1.414213562, 1.01, 10 );
1524 switch (GPOINTER_TO_INT(data)) {
1525 case SP_VERB_ZOOM_IN:
1526 {
1527 NR::Rect const d = dt->get_display_area();
1528 dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], zoom_inc);
1529 break;
1530 }
1531 case SP_VERB_ZOOM_OUT:
1532 {
1533 NR::Rect const d = dt->get_display_area();
1534 dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1 / zoom_inc );
1535 break;
1536 }
1537 case SP_VERB_ZOOM_1_1:
1538 {
1539 NR::Rect const d = dt->get_display_area();
1540 dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1.0 );
1541 break;
1542 }
1543 case SP_VERB_ZOOM_1_2:
1544 {
1545 NR::Rect const d = dt->get_display_area();
1546 dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 0.5);
1547 break;
1548 }
1549 case SP_VERB_ZOOM_2_1:
1550 {
1551 NR::Rect const d = dt->get_display_area();
1552 dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 2.0 );
1553 break;
1554 }
1555 case SP_VERB_ZOOM_PAGE:
1556 dt->zoom_page();
1557 break;
1558 case SP_VERB_ZOOM_PAGE_WIDTH:
1559 dt->zoom_page_width();
1560 break;
1561 case SP_VERB_ZOOM_DRAWING:
1562 dt->zoom_drawing();
1563 break;
1564 case SP_VERB_ZOOM_SELECTION:
1565 dt->zoom_selection();
1566 break;
1567 case SP_VERB_ZOOM_NEXT:
1568 dt->next_zoom();
1569 break;
1570 case SP_VERB_ZOOM_PREV:
1571 dt->prev_zoom();
1572 break;
1573 case SP_VERB_TOGGLE_RULERS:
1574 dt->toggleRulers();
1575 break;
1576 case SP_VERB_TOGGLE_SCROLLBARS:
1577 dt->toggleScrollbars();
1578 break;
1579 case SP_VERB_TOGGLE_GUIDES:
1580 sp_namedview_toggle_guides(doc, repr);
1581 break;
1582 case SP_VERB_TOGGLE_GRID:
1583 dt->toggleGrid();
1584 break;
1585 #ifdef HAVE_GTK_WINDOW_FULLSCREEN
1586 case SP_VERB_FULLSCREEN:
1587 dt->fullscreen();
1588 break;
1589 #endif /* HAVE_GTK_WINDOW_FULLSCREEN */
1590 case SP_VERB_VIEW_NEW:
1591 sp_ui_new_view();
1592 break;
1593 case SP_VERB_VIEW_NEW_PREVIEW:
1594 sp_ui_new_view_preview();
1595 break;
1596 case SP_VERB_VIEW_MODE_NORMAL:
1597 dt->setDisplayModeNormal();
1598 break;
1599 case SP_VERB_VIEW_MODE_OUTLINE:
1600 dt->setDisplayModeOutline();
1601 break;
1602 case SP_VERB_VIEW_MODE_TOGGLE:
1603 dt->displayModeToggle();
1604 break;
1605 case SP_VERB_VIEW_ICON_PREVIEW:
1606 show_panel( Inkscape::UI::Dialogs::IconPreviewPanel::getInstance(), "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW );
1607 break;
1608 default:
1609 break;
1610 }
1612 dt->updateNow();
1614 } // end of sp_verb_action_zoom_perform()
1616 /** \brief Decode the verb code and take appropriate action */
1617 void
1618 DialogVerb::perform(SPAction *action, void *data, void *pdata)
1619 {
1620 if (reinterpret_cast<std::size_t>(data) != SP_VERB_DIALOG_TOGGLE) {
1621 // unhide all when opening a new dialog
1622 inkscape_dialogs_unhide();
1623 }
1625 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1626 g_assert(dt->_dlg_mgr != NULL);
1628 switch (reinterpret_cast<std::size_t>(data)) {
1629 case SP_VERB_DIALOG_DISPLAY:
1630 //sp_display_dialog();
1631 dt->_dlg_mgr->showDialog("InkscapePreferences");
1632 break;
1633 case SP_VERB_DIALOG_METADATA:
1634 // sp_desktop_dialog();
1635 dt->_dlg_mgr->showDialog("DocumentMetadata");
1636 break;
1637 case SP_VERB_DIALOG_NAMEDVIEW:
1638 // sp_desktop_dialog();
1639 dt->_dlg_mgr->showDialog("DocumentProperties");
1640 break;
1641 case SP_VERB_DIALOG_FILL_STROKE:
1642 sp_object_properties_dialog();
1643 break;
1644 case SP_VERB_DIALOG_SWATCHES:
1645 show_panel( Inkscape::UI::Dialogs::SwatchesPanel::getInstance(), "dialogs.swatches", SP_VERB_DIALOG_SWATCHES);
1646 break;
1647 case SP_VERB_DIALOG_TRANSFORM:
1648 dt->_dlg_mgr->showDialog("Transformation");
1649 break;
1650 case SP_VERB_DIALOG_ALIGN_DISTRIBUTE:
1651 dt->_dlg_mgr->showDialog("AlignAndDistribute");
1652 break;
1653 case SP_VERB_DIALOG_TEXT:
1654 sp_text_edit_dialog();
1655 break;
1656 case SP_VERB_DIALOG_XML_EDITOR:
1657 sp_xml_tree_dialog();
1658 break;
1659 case SP_VERB_DIALOG_FIND:
1660 sp_find_dialog();
1661 // Please test the new find dialog if you have time:
1662 // dt->_dlg_mgr->showDialog("Find");
1663 break;
1664 case SP_VERB_DIALOG_DEBUG:
1665 dt->_dlg_mgr->showDialog("Messages");
1666 break;
1667 case SP_VERB_DIALOG_SCRIPT:
1668 dt->_dlg_mgr->showDialog("Script");
1669 break;
1670 case SP_VERB_DIALOG_UNDO_HISTORY:
1671 dt->_dlg_mgr->showDialog("UndoHistory");
1672 break;
1673 case SP_VERB_DIALOG_TOGGLE:
1674 inkscape_dialogs_toggle();
1675 break;
1676 case SP_VERB_DIALOG_CLONETILER:
1677 clonetiler_dialog();
1678 break;
1679 case SP_VERB_DIALOG_ITEM:
1680 sp_item_dialog();
1681 break;
1682 #ifdef WITH_INKBOARD
1683 case SP_VERB_XMPP_CLIENT:
1684 {
1685 Inkscape::Whiteboard::SessionManager::showClient();
1686 break;
1687 }
1688 #endif
1689 case SP_VERB_DIALOG_INPUT:
1690 sp_input_dialog();
1691 break;
1692 case SP_VERB_DIALOG_EXTENSIONEDITOR:
1693 dt->_dlg_mgr->showDialog("ExtensionEditor");
1694 break;
1695 case SP_VERB_DIALOG_LAYERS:
1696 show_panel( Inkscape::UI::Dialogs::LayersPanel::getInstance(), "dialogs.layers", SP_VERB_DIALOG_LAYERS );
1697 break;
1698 default:
1699 break;
1700 }
1701 } // end of sp_verb_action_dialog_perform()
1703 /** \brief Decode the verb code and take appropriate action */
1704 void
1705 HelpVerb::perform(SPAction *action, void *data, void *pdata)
1706 {
1707 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1708 g_assert(dt->_dlg_mgr != NULL);
1710 switch (reinterpret_cast<std::size_t>(data)) {
1711 case SP_VERB_HELP_KEYS:
1712 /* TRANSLATORS: If you have translated the keys.svg file to your language, then
1713 translate this string as "keys.LANG.svg" (where LANG is your language code);
1714 otherwise leave as "keys.svg". */
1715 sp_help_open_screen(_("keys.svg"));
1716 break;
1717 case SP_VERB_HELP_ABOUT:
1718 sp_help_about();
1719 break;
1720 case SP_VERB_HELP_ABOUT_EXTENSIONS: {
1721 Inkscape::UI::Dialogs::ExtensionsPanel *panel = new Inkscape::UI::Dialogs::ExtensionsPanel();
1722 panel->set_full(true);
1723 show_panel( *panel, "dialogs.aboutextensions", SP_VERB_HELP_ABOUT_EXTENSIONS );
1724 break;
1725 }
1727 /*
1728 case SP_VERB_SHOW_LICENSE:
1729 // TRANSLATORS: See "tutorial-basic.svg" comment.
1730 sp_help_open_tutorial(NULL, (gpointer) _("gpl-2.svg"));
1731 break;
1732 */
1734 case SP_VERB_HELP_MEMORY:
1735 dt->_dlg_mgr->showDialog("Memory");
1736 break;
1737 default:
1738 break;
1739 }
1740 } // end of sp_verb_action_help_perform()
1742 /** \brief Decode the verb code and take appropriate action */
1743 void
1744 TutorialVerb::perform(SPAction *action, void *data, void *pdata)
1745 {
1746 switch (reinterpret_cast<std::size_t>(data)) {
1747 case SP_VERB_TUTORIAL_BASIC:
1748 /* TRANSLATORS: If you have translated the tutorial-basic.svg file to your language,
1749 then translate this string as "tutorial-basic.LANG.svg" (where LANG is your language
1750 code); otherwise leave as "tutorial-basic.svg". */
1751 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-basic.svg"));
1752 break;
1753 case SP_VERB_TUTORIAL_SHAPES:
1754 // TRANSLATORS: See "tutorial-basic.svg" comment.
1755 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-shapes.svg"));
1756 break;
1757 case SP_VERB_TUTORIAL_ADVANCED:
1758 // TRANSLATORS: See "tutorial-basic.svg" comment.
1759 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-advanced.svg"));
1760 break;
1761 case SP_VERB_TUTORIAL_TRACING:
1762 // TRANSLATORS: See "tutorial-basic.svg" comment.
1763 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-tracing.svg"));
1764 break;
1765 case SP_VERB_TUTORIAL_CALLIGRAPHY:
1766 // TRANSLATORS: See "tutorial-basic.svg" comment.
1767 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-calligraphy.svg"));
1768 break;
1769 case SP_VERB_TUTORIAL_DESIGN:
1770 // TRANSLATORS: See "tutorial-basic.svg" comment.
1771 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-elements.svg"));
1772 break;
1773 case SP_VERB_TUTORIAL_TIPS:
1774 // TRANSLATORS: See "tutorial-basic.svg" comment.
1775 sp_help_open_tutorial(NULL, (gpointer)_("tutorial-tips.svg"));
1776 break;
1777 default:
1778 break;
1779 }
1780 } // end of sp_verb_action_tutorial_perform()
1783 /**
1784 * Action vector to define functions called if a staticly defined file verb
1785 * is called.
1786 */
1787 SPActionEventVector FileVerb::vector =
1788 {{NULL},FileVerb::perform, NULL, NULL, NULL, NULL};
1789 /**
1790 * Action vector to define functions called if a staticly defined edit verb is
1791 * called.
1792 */
1793 SPActionEventVector EditVerb::vector =
1794 {{NULL},EditVerb::perform, NULL, NULL, NULL, NULL};
1796 /**
1797 * Action vector to define functions called if a staticly defined selection
1798 * verb is called
1799 */
1800 SPActionEventVector SelectionVerb::vector =
1801 {{NULL},SelectionVerb::perform, NULL, NULL, NULL, NULL};
1803 /**
1804 * Action vector to define functions called if a staticly defined layer
1805 * verb is called
1806 */
1807 SPActionEventVector LayerVerb::vector =
1808 {{NULL}, LayerVerb::perform, NULL, NULL, NULL, NULL};
1810 /**
1811 * Action vector to define functions called if a staticly defined object
1812 * editing verb is called
1813 */
1814 SPActionEventVector ObjectVerb::vector =
1815 {{NULL},ObjectVerb::perform, NULL, NULL, NULL, NULL};
1817 /**
1818 * Action vector to define functions called if a staticly defined context
1819 * verb is called
1820 */
1821 SPActionEventVector ContextVerb::vector =
1822 {{NULL},ContextVerb::perform, NULL, NULL, NULL, NULL};
1824 /**
1825 * Action vector to define functions called if a staticly defined zoom verb
1826 * is called
1827 */
1828 SPActionEventVector ZoomVerb::vector =
1829 {{NULL},ZoomVerb::perform, NULL, NULL, NULL, NULL};
1832 /**
1833 * Action vector to define functions called if a staticly defined dialog verb
1834 * is called
1835 */
1836 SPActionEventVector DialogVerb::vector =
1837 {{NULL},DialogVerb::perform, NULL, NULL, NULL, NULL};
1839 /**
1840 * Action vector to define functions called if a staticly defined help verb
1841 * is called
1842 */
1843 SPActionEventVector HelpVerb::vector =
1844 {{NULL},HelpVerb::perform, NULL, NULL, NULL, NULL};
1846 /**
1847 * Action vector to define functions called if a staticly defined tutorial verb
1848 * is called
1849 */
1850 SPActionEventVector TutorialVerb::vector =
1851 {{NULL},TutorialVerb::perform, NULL, NULL, NULL, NULL};
1853 /**
1854 * Action vector to define functions called if a staticly defined tutorial verb
1855 * is called
1856 */
1857 SPActionEventVector TextVerb::vector =
1858 {{NULL},TextVerb::perform, NULL, NULL, NULL, NULL};
1861 /* *********** Effect Last ********** */
1863 /** \brief A class to represent the last effect issued */
1864 class EffectLastVerb : public Verb {
1865 private:
1866 static void perform(SPAction *action, void *mydata, void *otherdata);
1867 static SPActionEventVector vector;
1868 protected:
1869 virtual SPAction *make_action(Inkscape::UI::View::View *view);
1870 public:
1871 /** \brief Use the Verb initializer with the same parameters. */
1872 EffectLastVerb(unsigned int const code,
1873 gchar const *id,
1874 gchar const *name,
1875 gchar const *tip,
1876 gchar const *image) :
1877 Verb(code, id, name, tip, image)
1878 {
1879 set_default_sensitive(false);
1880 }
1881 }; /* EffectLastVerb class */
1883 /**
1884 * The vector to attach in the last effect verb.
1885 */
1886 SPActionEventVector EffectLastVerb::vector =
1887 {{NULL},EffectLastVerb::perform, NULL, NULL, NULL, NULL};
1889 /** \brief Create an action for a \c EffectLastVerb
1890 \param view Which view the action should be created for
1891 \return The built action.
1893 Calls \c make_action_helper with the \c vector.
1894 */
1895 SPAction *
1896 EffectLastVerb::make_action(Inkscape::UI::View::View *view)
1897 {
1898 return make_action_helper(view, &vector);
1899 }
1901 /** \brief Decode the verb code and take appropriate action */
1902 void
1903 EffectLastVerb::perform(SPAction *action, void *data, void *pdata)
1904 {
1905 /* These aren't used, but are here to remind people not to use
1906 the CURRENT_DOCUMENT macros unless they really have to. */
1907 Inkscape::UI::View::View *current_view = sp_action_get_view(action);
1908 // SPDocument *current_document = SP_VIEW_DOCUMENT(current_view);
1909 Inkscape::Extension::Effect *effect = Inkscape::Extension::Effect::get_last_effect();
1911 if (effect == NULL) return;
1912 if (current_view == NULL) return;
1914 switch ((long) data) {
1915 case SP_VERB_EFFECT_LAST_PREF:
1916 if (!effect->prefs(current_view))
1917 return;
1918 /* Note: fall through */
1919 case SP_VERB_EFFECT_LAST:
1920 effect->effect(current_view);
1921 break;
1922 default:
1923 return;
1924 }
1926 return;
1927 }
1928 /* *********** End Effect Last ********** */
1930 /* *********** Fit Canvas ********** */
1932 /** \brief A class to represent the canvas fitting verbs */
1933 class FitCanvasVerb : public Verb {
1934 private:
1935 static void perform(SPAction *action, void *mydata, void *otherdata);
1936 static SPActionEventVector vector;
1937 protected:
1938 virtual SPAction *make_action(Inkscape::UI::View::View *view);
1939 public:
1940 /** \brief Use the Verb initializer with the same parameters. */
1941 FitCanvasVerb(unsigned int const code,
1942 gchar const *id,
1943 gchar const *name,
1944 gchar const *tip,
1945 gchar const *image) :
1946 Verb(code, id, name, tip, image)
1947 {
1948 set_default_sensitive(false);
1949 }
1950 }; /* FitCanvasVerb class */
1952 /**
1953 * The vector to attach in the fit canvas verb.
1954 */
1955 SPActionEventVector FitCanvasVerb::vector =
1956 {{NULL},FitCanvasVerb::perform, NULL, NULL, NULL, NULL};
1958 /** \brief Create an action for a \c FitCanvasVerb
1959 \param view Which view the action should be created for
1960 \return The built action.
1962 Calls \c make_action_helper with the \c vector.
1963 */
1964 SPAction *
1965 FitCanvasVerb::make_action(Inkscape::UI::View::View *view)
1966 {
1967 SPAction *action = make_action_helper(view, &vector);
1968 return action;
1969 }
1971 /** \brief Decode the verb code and take appropriate action */
1972 void
1973 FitCanvasVerb::perform(SPAction *action, void *data, void *pdata)
1974 {
1975 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
1976 if (!dt) return;
1977 SPDocument *doc = sp_desktop_document(dt);
1978 if (!doc) return;
1980 switch ((long) data) {
1981 case SP_VERB_FIT_CANVAS_TO_SELECTION:
1982 fit_canvas_to_selection(dt);
1983 break;
1984 case SP_VERB_FIT_CANVAS_TO_DRAWING:
1985 fit_canvas_to_drawing(doc);
1986 break;
1987 case SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING:
1988 fit_canvas_to_selection_or_drawing(dt);
1989 break;
1990 default:
1991 return;
1992 }
1994 return;
1995 }
1996 /* *********** End Fit Canvas ********** */
1999 /* *********** Lock'N'Hide ********** */
2001 /** \brief A class to represent the object unlocking and unhiding verbs */
2002 class LockAndHideVerb : public Verb {
2003 private:
2004 static void perform(SPAction *action, void *mydata, void *otherdata);
2005 static SPActionEventVector vector;
2006 protected:
2007 virtual SPAction *make_action(Inkscape::UI::View::View *view);
2008 public:
2009 /** \brief Use the Verb initializer with the same parameters. */
2010 LockAndHideVerb(unsigned int const code,
2011 gchar const *id,
2012 gchar const *name,
2013 gchar const *tip,
2014 gchar const *image) :
2015 Verb(code, id, name, tip, image)
2016 {
2017 set_default_sensitive(true);
2018 }
2019 }; /* LockAndHideVerb class */
2021 /**
2022 * The vector to attach in the lock'n'hide verb.
2023 */
2024 SPActionEventVector LockAndHideVerb::vector =
2025 {{NULL},LockAndHideVerb::perform, NULL, NULL, NULL, NULL};
2027 /** \brief Create an action for a \c LockAndHideVerb
2028 \param view Which view the action should be created for
2029 \return The built action.
2031 Calls \c make_action_helper with the \c vector.
2032 */
2033 SPAction *
2034 LockAndHideVerb::make_action(Inkscape::UI::View::View *view)
2035 {
2036 SPAction *action = make_action_helper(view, &vector);
2037 return action;
2038 }
2040 /** \brief Decode the verb code and take appropriate action */
2041 void
2042 LockAndHideVerb::perform(SPAction *action, void *data, void *pdata)
2043 {
2044 SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
2045 if (!dt) return;
2046 SPDocument *doc = sp_desktop_document(dt);
2047 if (!doc) return;
2049 switch ((long) data) {
2050 case SP_VERB_UNLOCK_ALL:
2051 unlock_all(dt);
2052 sp_document_done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer"));
2053 break;
2054 case SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS:
2055 unlock_all_in_all_layers(dt);
2056 sp_document_done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers"));
2057 break;
2058 case SP_VERB_UNHIDE_ALL:
2059 unhide_all(dt);
2060 sp_document_done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer"));
2061 break;
2062 case SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS:
2063 unhide_all_in_all_layers(dt);
2064 sp_document_done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers"));
2065 break;
2066 default:
2067 return;
2068 }
2070 return;
2071 }
2072 /* *********** End Lock'N'Hide ********** */
2075 /* these must be in the same order as the SP_VERB_* enum in "verbs.h" */
2076 Verb *Verb::_base_verbs[] = {
2077 /* Header */
2078 new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL),
2079 new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL),
2081 /* File */
2082 new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"),
2083 GTK_STOCK_NEW ),
2084 new FileVerb(SP_VERB_FILE_OPEN, "FileOpen", N_("_Open..."),
2085 N_("Open an existing document"), GTK_STOCK_OPEN ),
2086 new FileVerb(SP_VERB_FILE_REVERT, "FileRevert", N_("Re_vert"),
2087 N_("Revert to the last saved version of document (changes will be lost)"), GTK_STOCK_REVERT_TO_SAVED ),
2088 new FileVerb(SP_VERB_FILE_SAVE, "FileSave", N_("_Save"), N_("Save document"),
2089 GTK_STOCK_SAVE ),
2090 new FileVerb(SP_VERB_FILE_SAVE_AS, "FileSaveAs", N_("Save _As..."),
2091 N_("Save document under a new name"), GTK_STOCK_SAVE_AS ),
2092 new FileVerb(SP_VERB_FILE_SAVE_A_COPY, "FileSaveACopy", N_("Save a Cop_y..."),
2093 N_("Save a copy of the document under a new name"), NULL ),
2094 new FileVerb(SP_VERB_FILE_PRINT, "FilePrint", N_("_Print..."), N_("Print document"),
2095 GTK_STOCK_PRINT ),
2096 // TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions)
2097 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"),
2098 "file_vacuum" ),
2099 new FileVerb(SP_VERB_FILE_PRINT_DIRECT, "FilePrintDirect", N_("Print _Direct"),
2100 N_("Print directly without prompting to a file or pipe"), NULL ),
2101 new FileVerb(SP_VERB_FILE_PRINT_PREVIEW, "FilePrintPreview", N_("Print Previe_w"),
2102 N_("Preview document printout"), GTK_STOCK_PRINT_PREVIEW ),
2103 new FileVerb(SP_VERB_FILE_IMPORT, "FileImport", N_("_Import..."),
2104 N_("Import a bitmap or SVG image into this document"), "file_import"),
2105 new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."),
2106 N_("Export this document or a selection as a bitmap image"), "file_export"),
2107 new FileVerb(SP_VERB_FILE_NEXT_DESKTOP, "NextWindow", N_("N_ext Window"),
2108 N_("Switch to the next document window"), "window_next"),
2109 new FileVerb(SP_VERB_FILE_PREV_DESKTOP, "PrevWindow", N_("P_revious Window"),
2110 N_("Switch to the previous document window"), "window_previous"),
2111 new FileVerb(SP_VERB_FILE_CLOSE_VIEW, "FileClose", N_("_Close"),
2112 N_("Close this document window"), GTK_STOCK_CLOSE),
2113 new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), GTK_STOCK_QUIT),
2115 /* Edit */
2116 new EditVerb(SP_VERB_EDIT_UNDO, "EditUndo", N_("_Undo"), N_("Undo last action"),
2117 GTK_STOCK_UNDO),
2118 new EditVerb(SP_VERB_EDIT_REDO, "EditRedo", N_("_Redo"),
2119 N_("Do again the last undone action"), GTK_STOCK_REDO),
2120 new EditVerb(SP_VERB_EDIT_CUT, "EditCut", N_("Cu_t"),
2121 N_("Cut selection to clipboard"), GTK_STOCK_CUT),
2122 new EditVerb(SP_VERB_EDIT_COPY, "EditCopy", N_("_Copy"),
2123 N_("Copy selection to clipboard"), GTK_STOCK_COPY),
2124 new EditVerb(SP_VERB_EDIT_PASTE, "EditPaste", N_("_Paste"),
2125 N_("Paste objects from clipboard to mouse point, or paste text"), GTK_STOCK_PASTE),
2126 new EditVerb(SP_VERB_EDIT_PASTE_STYLE, "EditPasteStyle", N_("Paste _Style"),
2127 N_("Apply the style of the copied object to selection"), "selection_paste_style"),
2128 new EditVerb(SP_VERB_EDIT_PASTE_SIZE, "EditPasteSize", N_("Paste Si_ze"),
2129 N_("Scale selection to match the size of the copied object"), NULL),
2130 new EditVerb(SP_VERB_EDIT_PASTE_SIZE_X, "EditPasteWidth", N_("Paste _Width"),
2131 N_("Scale selection horizontally to match the width of the copied object"), NULL),
2132 new EditVerb(SP_VERB_EDIT_PASTE_SIZE_Y, "EditPasteHeight", N_("Paste _Height"),
2133 N_("Scale selection vertically to match the height of the copied object"), NULL),
2134 new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, "EditPasteSizeSeparately", N_("Paste Size Separately"),
2135 N_("Scale each selected object to match the size of the copied object"), NULL),
2136 new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X, "EditPasteWidthSeparately", N_("Paste Width Separately"),
2137 N_("Scale each selected object horizontally to match the width of the copied object"), NULL),
2138 new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y, "EditPasteHeightSeparately", N_("Paste Height Separately"),
2139 N_("Scale each selected object vertically to match the height of the copied object"), NULL),
2140 new EditVerb(SP_VERB_EDIT_PASTE_IN_PLACE, "EditPasteInPlace", N_("Paste _In Place"),
2141 N_("Paste objects from clipboard to the original location"), "selection_paste_in_place"),
2142 new EditVerb(SP_VERB_EDIT_DELETE, "EditDelete", N_("_Delete"),
2143 N_("Delete selection"), GTK_STOCK_DELETE),
2144 new EditVerb(SP_VERB_EDIT_DUPLICATE, "EditDuplicate", N_("Duplic_ate"),
2145 N_("Duplicate selected objects"), "edit_duplicate"),
2146 new EditVerb(SP_VERB_EDIT_CLONE, "EditClone", N_("Create Clo_ne"),
2147 N_("Create a clone (a copy linked to the original) of selected object"), "edit_clone"),
2148 new EditVerb(SP_VERB_EDIT_UNLINK_CLONE, "EditUnlinkClone", N_("Unlin_k Clone"),
2149 N_("Cut the selected clone's link to its original, turning it into a standalone object"), "edit_unlink_clone"),
2150 new EditVerb(SP_VERB_EDIT_CLONE_ORIGINAL, "EditCloneOriginal", N_("Select _Original"),
2151 N_("Select the object to which the selected clone is linked"), "edit_select_original"),
2152 // TRANSLATORS: Convert selection to a rectangle with tiled pattern fill
2153 new EditVerb(SP_VERB_EDIT_TILE, "ObjectsToPattern", N_("Objects to Patter_n"),
2154 N_("Convert selection to a rectangle with tiled pattern fill"), NULL),
2155 // TRANSLATORS: Extract objects from a tiled pattern fill
2156 new EditVerb(SP_VERB_EDIT_UNTILE, "ObjectsFromPattern", N_("Pattern to _Objects"),
2157 N_("Extract objects from a tiled pattern fill"), NULL),
2158 new EditVerb(SP_VERB_EDIT_CLEAR_ALL, "EditClearAll", N_("Clea_r All"),
2159 N_("Delete all objects from document"), NULL),
2160 new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"),
2161 N_("Select all objects or all nodes"), "selection_select_all"),
2162 new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"),
2163 N_("Select all objects in all visible and unlocked layers"), "selection_select_all_in_all_layers"),
2164 new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"),
2165 N_("Invert selection (unselect what is selected and select everything else)"), "selection_invert"),
2166 new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"),
2167 N_("Invert selection in all visible and unlocked layers"), NULL),
2168 new EditVerb(SP_VERB_EDIT_SELECT_NEXT, "EditSelectNext", N_("Select Next"),
2169 N_("Select next object or node"), NULL),
2170 new EditVerb(SP_VERB_EDIT_SELECT_PREV, "EditSelectPrev", N_("Select Previous"),
2171 N_("Select previous object or node"), NULL),
2172 new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"),
2173 N_("Deselect any selected objects or nodes"), "selection_deselect"),
2175 /* Selection */
2176 new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"),
2177 N_("Raise selection to top"), "selection_top"),
2178 new SelectionVerb(SP_VERB_SELECTION_TO_BACK, "SelectionToBack", N_("Lower to _Bottom"),
2179 N_("Lower selection to bottom"), "selection_bot"),
2180 new SelectionVerb(SP_VERB_SELECTION_RAISE, "SelectionRaise", N_("_Raise"),
2181 N_("Raise selection one step"), "selection_up"),
2182 new SelectionVerb(SP_VERB_SELECTION_LOWER, "SelectionLower", N_("_Lower"),
2183 N_("Lower selection one step"), "selection_down"),
2184 new SelectionVerb(SP_VERB_SELECTION_GROUP, "SelectionGroup", N_("_Group"),
2185 N_("Group selected objects"), "selection_group"),
2186 new SelectionVerb(SP_VERB_SELECTION_UNGROUP, "SelectionUnGroup", N_("_Ungroup"),
2187 N_("Ungroup selected groups"), "selection_ungroup"),
2189 new SelectionVerb(SP_VERB_SELECTION_TEXTTOPATH, "SelectionTextToPath", N_("_Put on Path"),
2190 N_("Put text on path"), "put_on_path"),
2191 new SelectionVerb(SP_VERB_SELECTION_TEXTFROMPATH, "SelectionTextFromPath", N_("_Remove from Path"),
2192 N_("Remove text from path"), "remove_from_path"),
2193 new SelectionVerb(SP_VERB_SELECTION_REMOVE_KERNS, "SelectionTextRemoveKerns", N_("Remove Manual _Kerns"),
2194 // TRANSLATORS: "glyph": An image used in the visual representation of characters;
2195 // roughly speaking, how a character looks. A font is a set of glyphs.
2196 N_("Remove all manual kerns and glyph rotations from a text object"), "remove_manual_kerns"),
2198 new SelectionVerb(SP_VERB_SELECTION_UNION, "SelectionUnion", N_("_Union"),
2199 N_("Create union of selected paths"), "union"),
2200 new SelectionVerb(SP_VERB_SELECTION_INTERSECT, "SelectionIntersect", N_("_Intersection"),
2201 N_("Create intersection of selected paths"), "intersection"),
2202 new SelectionVerb(SP_VERB_SELECTION_DIFF, "SelectionDiff", N_("_Difference"),
2203 N_("Create difference of selected paths (bottom minus top)"), "difference"),
2204 new SelectionVerb(SP_VERB_SELECTION_SYMDIFF, "SelectionSymDiff", N_("E_xclusion"),
2205 N_("Create exclusive OR of selected paths (those parts that belong to only one path)"), "exclusion"),
2206 new SelectionVerb(SP_VERB_SELECTION_CUT, "SelectionDivide", N_("Di_vision"),
2207 N_("Cut the bottom path into pieces"), "division"),
2208 // TRANSLATORS: "to cut a path" is not the same as "to break a path apart" - see the
2209 // Advanced tutorial for more info
2210 new SelectionVerb(SP_VERB_SELECTION_SLICE, "SelectionCutPath", N_("Cut _Path"),
2211 N_("Cut the bottom path's stroke into pieces, removing fill"), "cut_path"),
2212 // TRANSLATORS: "outset": expand a shape by offsetting the object's path,
2213 // i.e. by displacing it perpendicular to the path in each point.
2214 // See also the Advanced Tutorial for explanation.
2215 new SelectionVerb(SP_VERB_SELECTION_OFFSET, "SelectionOffset", N_("Outs_et"),
2216 N_("Outset selected paths"), "outset_path"),
2217 new SelectionVerb(SP_VERB_SELECTION_OFFSET_SCREEN, "SelectionOffsetScreen",
2218 N_("O_utset Path by 1 px"),
2219 N_("Outset selected paths by 1 px"), NULL),
2220 new SelectionVerb(SP_VERB_SELECTION_OFFSET_SCREEN_10, "SelectionOffsetScreen10",
2221 N_("O_utset Path by 10 px"),
2222 N_("Outset selected paths by 10 px"), NULL),
2223 // TRANSLATORS: "inset": contract a shape by offsetting the object's path,
2224 // i.e. by displacing it perpendicular to the path in each point.
2225 // See also the Advanced Tutorial for explanation.
2226 new SelectionVerb(SP_VERB_SELECTION_INSET, "SelectionInset", N_("I_nset"),
2227 N_("Inset selected paths"), "inset_path"),
2228 new SelectionVerb(SP_VERB_SELECTION_INSET_SCREEN, "SelectionInsetScreen",
2229 N_("I_nset Path by 1 px"),
2230 N_("Inset selected paths by 1 px"), NULL),
2231 new SelectionVerb(SP_VERB_SELECTION_INSET_SCREEN_10, "SelectionInsetScreen10",
2232 N_("I_nset Path by 10 px"),
2233 N_("Inset selected paths by 10 px"), NULL),
2234 new SelectionVerb(SP_VERB_SELECTION_DYNAMIC_OFFSET, "SelectionDynOffset",
2235 N_("D_ynamic Offset"), N_("Create a dynamic offset object"), "dynamic_offset"),
2236 new SelectionVerb(SP_VERB_SELECTION_LINKED_OFFSET, "SelectionLinkedOffset",
2237 N_("_Linked Offset"),
2238 N_("Create a dynamic offset object linked to the original path"),
2239 "linked_offset"),
2240 new SelectionVerb(SP_VERB_SELECTION_OUTLINE, "StrokeToPath", N_("_Stroke to Path"),
2241 N_("Convert selected object's stroke to paths"), "stroke_tocurve"),
2242 new SelectionVerb(SP_VERB_SELECTION_SIMPLIFY, "SelectionSimplify", N_("Si_mplify"),
2243 N_("Simplify selected paths (remove extra nodes)"), "simplify"),
2244 new SelectionVerb(SP_VERB_SELECTION_REVERSE, "SelectionReverse", N_("_Reverse"),
2245 N_("Reverse the direction of selected paths (useful for flipping markers)"), "selection_reverse"),
2246 // TRANSLATORS: "to trace" means "to convert a bitmap to vector graphics" (to vectorize)
2247 new SelectionVerb(SP_VERB_SELECTION_TRACE, "SelectionTrace", N_("_Trace Bitmap..."),
2248 N_("Create one or more paths from a bitmap by tracing it"), "selection_trace"),
2249 new SelectionVerb(SP_VERB_SELECTION_CREATE_BITMAP, "SelectionCreateBitmap", N_("_Make a Bitmap Copy"),
2250 N_("Export selection to a bitmap and insert it into document"), "selection_bitmap" ),
2251 new SelectionVerb(SP_VERB_SELECTION_COMBINE, "SelectionCombine", N_("_Combine"),
2252 N_("Combine several paths into one"), "selection_combine"),
2253 // TRANSLATORS: "to cut a path" is not the same as "to break a path apart" - see the
2254 // Advanced tutorial for more info
2255 new SelectionVerb(SP_VERB_SELECTION_BREAK_APART, "SelectionBreakApart", N_("Break _Apart"),
2256 N_("Break selected paths into subpaths"), "selection_break"),
2257 new SelectionVerb(SP_VERB_SELECTION_GRIDTILE, "DialogGridArrange", N_("Gri_d Arrange..."),
2258 N_("Arrange selected objects in a grid pattern"), "grid_arrange"),
2259 /* Layer */
2260 new LayerVerb(SP_VERB_LAYER_NEW, "LayerNew", N_("_Add Layer..."),
2261 N_("Create a new layer"), "new_layer"),
2262 new LayerVerb(SP_VERB_LAYER_RENAME, "LayerRename", N_("Re_name Layer..."),
2263 N_("Rename the current layer"), "rename_layer"),
2264 new LayerVerb(SP_VERB_LAYER_NEXT, "LayerNext", N_("Switch to Layer Abov_e"),
2265 N_("Switch to the layer above the current"), "switch_to_layer_above"),
2266 new LayerVerb(SP_VERB_LAYER_PREV, "LayerPrev", N_("Switch to Layer Belo_w"),
2267 N_("Switch to the layer below the current"), "switch_to_layer_below"),
2268 new LayerVerb(SP_VERB_LAYER_MOVE_TO_NEXT, "LayerMoveToNext", N_("Move Selection to Layer Abo_ve"),
2269 N_("Move selection to the layer above the current"), "move_selection_above"),
2270 new LayerVerb(SP_VERB_LAYER_MOVE_TO_PREV, "LayerMoveToPrev", N_("Move Selection to Layer Bel_ow"),
2271 N_("Move selection to the layer below the current"), "move_selection_below"),
2272 new LayerVerb(SP_VERB_LAYER_TO_TOP, "LayerToTop", N_("Layer to _Top"),
2273 N_("Raise the current layer to the top"), "layer_to_top"),
2274 new LayerVerb(SP_VERB_LAYER_TO_BOTTOM, "LayerToBottom", N_("Layer to _Bottom"),
2275 N_("Lower the current layer to the bottom"), "layer_to_bottom"),
2276 new LayerVerb(SP_VERB_LAYER_RAISE, "LayerRaise", N_("_Raise Layer"),
2277 N_("Raise the current layer"), "raise_layer"),
2278 new LayerVerb(SP_VERB_LAYER_LOWER, "LayerLower", N_("_Lower Layer"),
2279 N_("Lower the current layer"), "lower_layer"),
2280 new LayerVerb(SP_VERB_LAYER_DELETE, "LayerDelete", N_("_Delete Current Layer"),
2281 N_("Delete the current layer"), "delete_layer"),
2283 /* Object */
2284 new ObjectVerb(SP_VERB_OBJECT_ROTATE_90_CW, "ObjectRotate90", N_("Rotate _90° CW"),
2285 // This is shared between tooltips and statusbar, so they
2286 // must use UTF-8, not HTML entities for special characters.
2287 N_("Rotate selection 90\xc2\xb0 clockwise"), "object_rotate_90_CW"),
2288 new ObjectVerb(SP_VERB_OBJECT_ROTATE_90_CCW, "ObjectRotate90CCW", N_("Rotate 9_0° CCW"),
2289 // This is shared between tooltips and statusbar, so they
2290 // must use UTF-8, not HTML entities for special characters.
2291 N_("Rotate selection 90\xc2\xb0 counter-clockwise"), "object_rotate_90_CCW"),
2292 new ObjectVerb(SP_VERB_OBJECT_FLATTEN, "ObjectRemoveTransform", N_("Remove _Transformations"),
2293 N_("Remove transformations from object"), "object_reset"),
2294 new ObjectVerb(SP_VERB_OBJECT_TO_CURVE, "ObjectToPath", N_("_Object to Path"),
2295 N_("Convert selected object to path"), "object_tocurve"),
2296 new ObjectVerb(SP_VERB_OBJECT_FLOW_TEXT, "ObjectFlowText", N_("_Flow into Frame"),
2297 N_("Put text into a frame (path or shape), creating a flowed text linked to the frame object"), "flow_into_frame"),
2298 new ObjectVerb(SP_VERB_OBJECT_UNFLOW_TEXT, "ObjectUnFlowText", N_("_Unflow"),
2299 N_("Remove text from frame (creates a single-line text object)"), "unflow"),
2300 new ObjectVerb(SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, "ObjectFlowtextToText", N_("_Convert to Text"),
2301 N_("Convert flowed text to regular text object (preserves appearance)"), "convert_to_text"),
2302 new ObjectVerb(SP_VERB_OBJECT_FLIP_HORIZONTAL, "ObjectFlipHorizontally",
2303 N_("Flip _Horizontal"), N_("Flip selected objects horizontally"),
2304 "object_flip_hor"),
2305 new ObjectVerb(SP_VERB_OBJECT_FLIP_VERTICAL, "ObjectFlipVertically",
2306 N_("Flip _Vertical"), N_("Flip selected objects vertically"),
2307 "object_flip_ver"),
2308 new ObjectVerb(SP_VERB_OBJECT_SET_MASK, "ObjectSetMask", N_("_Set"),
2309 N_("Apply mask to selection (using the topmost object as mask)"), NULL),
2310 new ObjectVerb(SP_VERB_OBJECT_UNSET_MASK, "ObjectUnSetMask", N_("_Release"),
2311 N_("Remove mask from selection"), NULL),
2312 new ObjectVerb(SP_VERB_OBJECT_SET_CLIPPATH, "ObjectSetClipPath", N_("_Set"),
2313 N_("Apply clipping path to selection (using the topmost object as clipping path)"), NULL),
2314 new ObjectVerb(SP_VERB_OBJECT_UNSET_CLIPPATH, "ObjectUnSetClipPath", N_("_Release"),
2315 N_("Remove clipping path from selection"), NULL),
2317 /* Tools */
2318 new ContextVerb(SP_VERB_CONTEXT_SELECT, "ToolSelector", N_("Select"),
2319 N_("Select and transform objects"), "draw_select"),
2320 new ContextVerb(SP_VERB_CONTEXT_NODE, "ToolNode", N_("Node Edit"),
2321 N_("Edit path nodes or control handles"), "draw_node"),
2322 new ContextVerb(SP_VERB_CONTEXT_RECT, "ToolRect", N_("Rectangle"),
2323 N_("Create rectangles and squares"), "draw_rect"),
2324 new ContextVerb(SP_VERB_CONTEXT_ARC, "ToolArc", N_("Ellipse"),
2325 N_("Create circles, ellipses, and arcs"), "draw_arc"),
2326 new ContextVerb(SP_VERB_CONTEXT_STAR, "ToolStar", N_("Star"),
2327 N_("Create stars and polygons"), "draw_star"),
2328 new ContextVerb(SP_VERB_CONTEXT_SPIRAL, "ToolSpiral", N_("Spiral"),
2329 N_("Create spirals"), "draw_spiral"),
2330 new ContextVerb(SP_VERB_CONTEXT_PENCIL, "ToolPencil", N_("Pencil"),
2331 N_("Draw freehand lines"), "draw_freehand"),
2332 new ContextVerb(SP_VERB_CONTEXT_PEN, "ToolPen", N_("Pen"),
2333 N_("Draw Bezier curves and straight lines"), "draw_pen"),
2334 new ContextVerb(SP_VERB_CONTEXT_CALLIGRAPHIC, "ToolCalligrphic", N_("Calligraphy"),
2335 N_("Draw calligraphic lines"), "draw_calligraphic"),
2336 new ContextVerb(SP_VERB_CONTEXT_TEXT, "ToolText", N_("Text"),
2337 N_("Create and edit text objects"), "draw_text"),
2338 new ContextVerb(SP_VERB_CONTEXT_GRADIENT, "ToolGradient", N_("Gradient"),
2339 N_("Create and edit gradients"), "draw_gradient"),
2340 new ContextVerb(SP_VERB_CONTEXT_ZOOM, "ToolZoom", N_("Zoom"),
2341 N_("Zoom in or out"), "draw_zoom"),
2342 new ContextVerb(SP_VERB_CONTEXT_DROPPER, "ToolDropper", N_("Dropper"),
2343 N_("Pick colors from image"), "draw_dropper"),
2344 new ContextVerb(SP_VERB_CONTEXT_CONNECTOR, "ToolConnector", N_("Connector"),
2345 N_("Create connectors"), "draw_connector"),
2346 new ContextVerb(SP_VERB_CONTEXT_PAINTBUCKET, "ToolPaintBucket", N_("Paint Bucket"),
2347 N_("Fill bounded areas"), "draw_paintbucket"),
2349 /* Tool prefs */
2350 new ContextVerb(SP_VERB_CONTEXT_SELECT_PREFS, "SelectPrefs", N_("Selector Preferences"),
2351 N_("Open Preferences for the Selector tool"), NULL),
2352 new ContextVerb(SP_VERB_CONTEXT_NODE_PREFS, "NodePrefs", N_("Node Tool Preferences"),
2353 N_("Open Preferences for the Node tool"), NULL),
2354 new ContextVerb(SP_VERB_CONTEXT_RECT_PREFS, "RectPrefs", N_("Rectangle Preferences"),
2355 N_("Open Preferences for the Rectangle tool"), NULL),
2356 new ContextVerb(SP_VERB_CONTEXT_ARC_PREFS, "ArcPrefs", N_("Ellipse Preferences"),
2357 N_("Open Preferences for the Ellipse tool"), NULL),
2358 new ContextVerb(SP_VERB_CONTEXT_STAR_PREFS, "StarPrefs", N_("Star Preferences"),
2359 N_("Open Preferences for the Star tool"), NULL),
2360 new ContextVerb(SP_VERB_CONTEXT_SPIRAL_PREFS, "SpiralPrefs", N_("Spiral Preferences"),
2361 N_("Open Preferences for the Spiral tool"), NULL),
2362 new ContextVerb(SP_VERB_CONTEXT_PENCIL_PREFS, "PencilPrefs", N_("Pencil Preferences"),
2363 N_("Open Preferences for the Pencil tool"), NULL),
2364 new ContextVerb(SP_VERB_CONTEXT_PEN_PREFS, "PenPrefs", N_("Pen Preferences"),
2365 N_("Open Preferences for the Pen tool"), NULL),
2366 new ContextVerb(SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "CalligraphicPrefs", N_("Calligraphic Preferences"),
2367 N_("Open Preferences for the Calligraphy tool"), NULL),
2368 new ContextVerb(SP_VERB_CONTEXT_TEXT_PREFS, "TextPrefs", N_("Text Preferences"),
2369 N_("Open Preferences for the Text tool"), NULL),
2370 new ContextVerb(SP_VERB_CONTEXT_GRADIENT_PREFS, "GradientPrefs", N_("Gradient Preferences"),
2371 N_("Open Preferences for the Gradient tool"), NULL),
2372 new ContextVerb(SP_VERB_CONTEXT_ZOOM_PREFS, "ZoomPrefs", N_("Zoom Preferences"),
2373 N_("Open Preferences for the Zoom tool"), NULL),
2374 new ContextVerb(SP_VERB_CONTEXT_DROPPER_PREFS, "DropperPrefs", N_("Dropper Preferences"),
2375 N_("Open Preferences for the Dropper tool"), NULL),
2376 new ContextVerb(SP_VERB_CONTEXT_CONNECTOR_PREFS, "ConnectorPrefs", N_("Connector Preferences"),
2377 N_("Open Preferences for the Connector tool"), NULL),
2378 new ContextVerb(SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "PaintBucketPrefs", N_("Paint Bucket Preferences"),
2379 N_("Open Preferences for the Paint Bucket tool"), NULL),
2381 /* Zoom/View */
2382 new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), "zoom_in"),
2383 new ZoomVerb(SP_VERB_ZOOM_OUT, "ZoomOut", N_("Zoom Out"), N_("Zoom out"), "zoom_out"),
2384 new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), "rulers"),
2385 new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), "scrollbars"),
2386 new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), "grid"),
2387 new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), "guides"),
2388 new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
2389 "zoom_next"),
2390 new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
2391 "zoom_previous"),
2392 new ZoomVerb(SP_VERB_ZOOM_1_1, "Zoom1:0", N_("Zoom 1:_1"), N_("Zoom to 1:1"),
2393 "zoom_1_to_1"),
2394 new ZoomVerb(SP_VERB_ZOOM_1_2, "Zoom1:2", N_("Zoom 1:_2"), N_("Zoom to 1:2"),
2395 "zoom_1_to_2"),
2396 new ZoomVerb(SP_VERB_ZOOM_2_1, "Zoom2:1", N_("_Zoom 2:1"), N_("Zoom to 2:1"),
2397 "zoom_2_to_1"),
2398 #ifdef HAVE_GTK_WINDOW_FULLSCREEN
2399 new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"),
2400 "fullscreen"),
2401 #endif /* HAVE_GTK_WINDOW_FULLSCREEN */
2402 new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"),
2403 "view_new"),
2404 new ZoomVerb(SP_VERB_VIEW_NEW_PREVIEW, "ViewNewPreview", N_("_New View Preview"),
2405 N_("New View Preview"), NULL/*"view_new_preview"*/),
2407 new ZoomVerb(SP_VERB_VIEW_MODE_NORMAL, "ViewModeNormal", N_("_Normal"),
2408 N_("Switch to normal display mode"), NULL),
2409 new ZoomVerb(SP_VERB_VIEW_MODE_OUTLINE, "ViewModeOutline", N_("_Outline"),
2410 N_("Switch to outline (wireframe) display mode"), NULL),
2411 new ZoomVerb(SP_VERB_VIEW_MODE_TOGGLE, "ViewModeToggle", N_("_Toggle"),
2412 N_("Toggle between normal and outline display modes"), NULL),
2414 new ZoomVerb(SP_VERB_VIEW_ICON_PREVIEW, "ViewIconPreview", N_("Ico_n Preview..."),
2415 N_("Open a window to preview objects at different icon resolutions"), "view_icon_preview"),
2416 new ZoomVerb(SP_VERB_ZOOM_PAGE, "ZoomPage", N_("_Page"),
2417 N_("Zoom to fit page in window"), "zoom_page"),
2418 new ZoomVerb(SP_VERB_ZOOM_PAGE_WIDTH, "ZoomPageWidth", N_("Page _Width"),
2419 N_("Zoom to fit page width in window"), "zoom_pagewidth"),
2420 new ZoomVerb(SP_VERB_ZOOM_DRAWING, "ZoomDrawing", N_("_Drawing"),
2421 N_("Zoom to fit drawing in window"), "zoom_draw"),
2422 new ZoomVerb(SP_VERB_ZOOM_SELECTION, "ZoomSelection", N_("_Selection"),
2423 N_("Zoom to fit selection in window"), "zoom_select"),
2425 /* Dialogs */
2426 new DialogVerb(SP_VERB_DIALOG_DISPLAY, "DialogPreferences", N_("In_kscape Preferences..."),
2427 N_("Edit global Inkscape preferences"), GTK_STOCK_PREFERENCES ),
2428 new DialogVerb(SP_VERB_DIALOG_NAMEDVIEW, "DialogDocumentProperties", N_("_Document Properties..."),
2429 N_("Edit properties of this document (to be saved with the document)"), GTK_STOCK_PROPERTIES ),
2430 new DialogVerb(SP_VERB_DIALOG_METADATA, "DialogMetadata", N_("Document _Metadata..."),
2431 N_("Edit document metadata (to be saved with the document)"), "document_metadata" ),
2432 new DialogVerb(SP_VERB_DIALOG_FILL_STROKE, "DialogFillStroke", N_("_Fill and Stroke..."),
2433 N_("Edit objects' colors, gradients, stroke width, arrowheads, dash patterns..."), "fill_and_stroke"),
2434 // TRANSLATORS: "Swatches" means: color samples
2435 new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."),
2436 N_("Select colors from a swatches palette"), GTK_STOCK_SELECT_COLOR),
2437 new DialogVerb(SP_VERB_DIALOG_TRANSFORM, "DialogTransform", N_("Transfor_m..."),
2438 N_("Precisely control objects' transformations"), "object_trans"),
2439 new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."),
2440 N_("Align and distribute objects"), "object_align"),
2441 new DialogVerb(SP_VERB_DIALOG_UNDO_HISTORY, "DialogUndoHistory", N_("Undo _History..."),
2442 N_("Undo History"), "edit_undo_history"),
2443 new DialogVerb(SP_VERB_DIALOG_TEXT, "DialogText", N_("_Text and Font..."),
2444 N_("View and select font family, font size and other text properties"), "object_font"),
2445 new DialogVerb(SP_VERB_DIALOG_XML_EDITOR, "DialogXMLEditor", N_("_XML Editor..."),
2446 N_("View and edit the XML tree of the document"), "xml_editor"),
2447 new DialogVerb(SP_VERB_DIALOG_FIND, "DialogFind", N_("_Find..."),
2448 N_("Find objects in document"), GTK_STOCK_FIND ),
2449 new DialogVerb(SP_VERB_DIALOG_DEBUG, "DialogDebug", N_("_Messages..."),
2450 N_("View debug messages"), "messages"),
2451 new DialogVerb(SP_VERB_DIALOG_SCRIPT, "DialogScript", N_("S_cripts..."),
2452 N_("Run scripts"), "scripts"),
2453 new DialogVerb(SP_VERB_DIALOG_TOGGLE, "DialogsToggle", N_("Show/Hide D_ialogs"),
2454 N_("Show or hide all open dialogs"), "dialog_toggle"),
2455 new DialogVerb(SP_VERB_DIALOG_CLONETILER, "DialogClonetiler", N_("Create Tiled Clones..."),
2456 N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), "edit_create_tiled_clones"),
2457 new DialogVerb(SP_VERB_DIALOG_ITEM, "DialogObjectProperties", N_("_Object Properties..."),
2458 N_("Edit the ID, locked and visible status, and other object properties"), "dialog_item_properties"),
2459 #ifdef WITH_INKBOARD
2460 new DialogVerb(SP_VERB_XMPP_CLIENT, "DialogXmppClient",
2461 N_("_Instant Messaging..."), N_("Jabber Instant Messaging Client"), NULL),
2462 #endif
2463 new DialogVerb(SP_VERB_DIALOG_INPUT, "DialogInput", N_("_Input Devices..."),
2464 N_("Configure extended input devices, such as a graphics tablet"), "input_devices"),
2465 new DialogVerb(SP_VERB_DIALOG_EXTENSIONEDITOR, "org.inkscape.dialogs.extensioneditor", N_("_Extensions..."),
2466 N_("Query information about extensions"), NULL),
2467 new DialogVerb(SP_VERB_DIALOG_LAYERS, "DialogLayers", N_("Layer_s..."),
2468 N_("View Layers"), "layers"),
2470 /* Help */
2471 new HelpVerb(SP_VERB_HELP_KEYS, "HelpKeys", N_("_Keys and Mouse"),
2472 N_("Keys and mouse shortcuts reference"), "help_keys"),
2473 new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"),
2474 N_("Information on Inkscape extensions"), NULL),
2475 new HelpVerb(SP_VERB_HELP_MEMORY, "HelpAboutMemory", N_("About _Memory"),
2476 N_("Memory usage information"), "about_memory"),
2477 new HelpVerb(SP_VERB_HELP_ABOUT, "HelpAbout", N_("_About Inkscape"),
2478 N_("Inkscape version, authors, license"), /*"help_about"*/"inkscape_options"),
2479 //new HelpVerb(SP_VERB_SHOW_LICENSE, "ShowLicense", N_("_License"),
2480 // N_("Distribution terms"), /*"show_license"*/"inkscape_options"),
2482 /* Tutorials */
2483 new TutorialVerb(SP_VERB_TUTORIAL_BASIC, "TutorialsBasic", N_("Inkscape: _Basic"),
2484 N_("Getting started with Inkscape"), NULL/*"tutorial_basic"*/),
2485 new TutorialVerb(SP_VERB_TUTORIAL_SHAPES, "TutorialsShapes", N_("Inkscape: _Shapes"),
2486 N_("Using shape tools to create and edit shapes"), NULL),
2487 new TutorialVerb(SP_VERB_TUTORIAL_ADVANCED, "TutorialsAdvanced", N_("Inkscape: _Advanced"),
2488 N_("Advanced Inkscape topics"), NULL/*"tutorial_advanced"*/),
2489 // TRANSLATORS: "to trace" means "to convert a bitmap to vector graphics" (to vectorize)
2490 new TutorialVerb(SP_VERB_TUTORIAL_TRACING, "TutorialsTracing", N_("Inkscape: T_racing"),
2491 N_("Using bitmap tracing"), NULL/*"tutorial_tracing"*/),
2492 new TutorialVerb(SP_VERB_TUTORIAL_CALLIGRAPHY, "TutorialsCalligraphy", N_("Inkscape: _Calligraphy"),
2493 N_("Using the Calligraphy pen tool"), NULL),
2494 new TutorialVerb(SP_VERB_TUTORIAL_DESIGN, "TutorialsDesign", N_("_Elements of Design"),
2495 N_("Principles of design in the tutorial form"), NULL/*"tutorial_design"*/),
2496 new TutorialVerb(SP_VERB_TUTORIAL_TIPS, "TutorialsTips", N_("_Tips and Tricks"),
2497 N_("Miscellaneous tips and tricks"), NULL/*"tutorial_tips"*/),
2499 /* Effect */
2500 new EffectLastVerb(SP_VERB_EFFECT_LAST, "EffectLast", N_("Previous Effect"),
2501 N_("Repeat the last effect with the same settings"), NULL),
2502 new EffectLastVerb(SP_VERB_EFFECT_LAST_PREF, "EffectLastPref", N_("Previous Effect Settings..."),
2503 N_("Repeat the last effect with new settings"), NULL),
2505 /* Fit Page */
2506 new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION, "FitCanvasToSelection", N_("Fit Page to Selection"),
2507 N_("Fit the page to the current selection"), NULL),
2508 new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_DRAWING, "FitCanvasToDrawing", N_("Fit Page to Drawing"),
2509 N_("Fit the page to the drawing"), NULL),
2510 new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"),
2511 N_("Fit the page to the current selection or the drawing if there is no selection"), NULL),
2512 /* LockAndHide */
2513 new LockAndHideVerb(SP_VERB_UNLOCK_ALL, "UnlockAll", N_("Unlock All"),
2514 N_("Unlock all objects in the current layer"), NULL),
2515 new LockAndHideVerb(SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, "UnlockAllInAllLayers", N_("Unlock All in All Layers"),
2516 N_("Unlock all objects in all layers"), NULL),
2517 new LockAndHideVerb(SP_VERB_UNHIDE_ALL, "UnhideAll", N_("Unhide All"),
2518 N_("Unhide all objects in the current layer"), NULL),
2519 new LockAndHideVerb(SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, "UnhideAllInAllLayers", N_("Unhide All in All Layers"),
2520 N_("Unhide all objects in all layers"), NULL),
2521 /* Footer */
2522 new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL)
2523 };
2526 void
2527 Verb::list (void) {
2528 // Go through the dynamic verb table
2529 for (VerbTable::iterator iter = _verbs.begin(); iter != _verbs.end(); iter++) {
2530 Verb * verb = iter->second;
2531 if (verb->get_code() == SP_VERB_INVALID ||
2532 verb->get_code() == SP_VERB_NONE ||
2533 verb->get_code() == SP_VERB_LAST) {
2534 continue;
2535 }
2537 printf("%s: %s\n", verb->get_id(), verb->get_tip()? verb->get_tip() : verb->get_name());
2538 }
2540 return;
2541 };
2543 } /* namespace Inkscape */
2545 /*
2546 Local Variables:
2547 mode:c++
2548 c-file-style:"stroustrup"
2549 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2550 indent-tabs-mode:nil
2551 fill-column:99
2552 End:
2553 */
2554 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :