Code

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