verbs.cpp revision 2197aaeb5cbd6bb675e264602fc92b2d613be298
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * \brief Actions for inkscape
75569f53579b42dc17cf097015b6b055c01e6875slive * This file implements routines necessary to deal with verbs. A verb
75569f53579b42dc17cf097015b6b055c01e6875slive * is a numeric identifier used to retrieve standard SPActions for particular
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * Lauris Kaplinski <lauris@kaplinski.com>
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * Ted Gould <ted@gould.cx>
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * MenTaLguY <mental@rydia.net>
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * David Turner <novalis@gnu.org>
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * bulia byak <buliabyak@users.sf.net>
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen * This code is in public domain.
75569f53579b42dc17cf097015b6b055c01e6875slive * \brief Return the name without underscores and ellipsis, for use in dialog
75569f53579b42dc17cf097015b6b055c01e6875slive * titles, etc. Allocated memory must be freed by caller.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen unsigned ri = 0;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen if (c == '\0') {
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen} // end of sp_action_get_title()
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/// \todo !!!FIXME:: kill this, use DialogManager instead!!!
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenclass PanelDialog : public Inkscape::UI::Dialog::Dialog
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen PanelDialog(char const *prefs_path, int const verb_num) : Dialog(prefs_path, verb_num) {}
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual Glib::ustring getName() const {return "foo";}
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual Glib::ustring getDesc() const {return "bar";}
c3fcea07965f59723831e23da647a77518285b8eslive/** \brief Utility function to get a panel displayed. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenstatic void show_panel( Inkscape::UI::Widget::Panel &panel, char const *prefs_path, int const verb_num )
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //g_message("Creating new dialog to hold it");
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen PanelDialog *dia = new PanelDialog(prefs_path, verb_num);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Gtk::Dialog *dia = dynamic_cast<Gtk::Dialog*>(container);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //g_message("Found an existing dialog");
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen file operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* FileVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen edit operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
dd6c631a85bd0659226ed0406143aeba179846d3yoshiki /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* EditVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen selection operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c3fcea07965f59723831e23da647a77518285b8eslive /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* SelectionVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen layer operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* LayerVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen operations related to objects. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c3fcea07965f59723831e23da647a77518285b8eslive /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* ObjectVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen operations relative to context. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
75569f53579b42dc17cf097015b6b055c01e6875slive}; /* ContextVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen zoom operations. */
c3fcea07965f59723831e23da647a77518285b8eslive static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* ZoomVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen dialog operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* DialogVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen help operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; /* HelpVerb class */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A class to encompass all of the verbs which deal with
75569f53579b42dc17cf097015b6b055c01e6875slive tutorial operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive}; /* TutorialVerb class */
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive/** \brief A class to encompass all of the verbs which deal with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen text operations. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static void perform(SPAction *action, void *mydata, void *otherdata);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen virtual SPAction *make_action(Inkscape::UI::View::View *view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /** \brief Use the Verb initializer with the same parameters. */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen}; //TextVerb : public Verb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create a verb without a code.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen This function calls the other constructor for all of the parameters,
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen but generates the code. It is important to READ THE OTHER DOCUMENTATION
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen it has important details in it. To generate the code a static is
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen used which starts at the last static value: \c SP_VERB_LAST. For
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen each call it is incremented. The list of allocated verbs is kept
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen in the \c _verbs hashtable which is indexed by the \c code.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenVerb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) :
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen _actions(NULL), _id(id), _name(name), _tip(tip), _image(image)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen _verb_ids.insert(VerbIDTable::value_type(_id, this));
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Destroy a verb.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen The only allocated variable is the _actions variable. If it has
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen been allocated it is deleted.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen /// \todo all the actions need to be cleaned up first.
c3fcea07965f59723831e23da647a77518285b8eslive/** \brief Verbs are no good without actions. This is a place holder
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen for a function that every subclass should write. Most
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen can be written using \c make_action_helper.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return NULL to represent error (this function shouldn't ever be called)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //std::cout << "make_action" << std::endl;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c FileVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //std::cout << "fileverb: make_action: " << &vector << std::endl;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c EditVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //std::cout << "editverb: make_action: " << &vector << std::endl;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c SelectionVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenSelectionVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c LayerVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenLayerVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c ObjectVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenObjectVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c ContextVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \return The built action.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive Calls \c make_action_helper with the \c vector.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbsliveContextVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c ZoomVerb
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \param view Which view the action should be created for
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c DialogVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
44c61920e384b819aba8ad43310c67c71fa64a48rbowen Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenDialogVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c HelpVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive/** \brief Create an action for a \c TutorialVerb
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \param view Which view the action should be created for
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \return The built action.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive Calls \c make_action_helper with the \c vector.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenTutorialVerb::make_action(Inkscape::UI::View::View *view)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Create an action for a \c TextVerb
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The built action.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen Calls \c make_action_helper with the \c vector.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive/** \brief A quick little convience function to make building actions
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen a little bit easier.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param view Which view the action should be created for.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param vector The function vector for the verb.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \return The created action.
75569f53579b42dc17cf097015b6b055c01e6875slive This function does a couple of things. The most obvious is that
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen it allocates and creates the action. When it does this it
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen translates the \c _name and \c _tip variables. This allows them
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen to be staticly allocated easily, and get translated in the end. Then,
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen if the action gets crated, a listener is added to the action with
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen the vector that is passed in.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenVerb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *vector, void *in_pntr)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen //std::cout << "Adding action: " << _code << std::endl;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen reinterpret_cast<void *>(_code)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A function to get an action if it exists, or otherwise to
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \param view The view which this action would relate to
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \return The action, or NULL if there is an error.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive This function will get the action for a given view for this verb. It
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive will create the verb if it can't be found in the ActionTable. Also,
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive if the \c ActionTable has not been created, it gets created by this
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen If the action is created, it's sensitivity must be determined. The
75569f53579b42dc17cf097015b6b055c01e6875slive default for a new action is that it is sensitive. If the value in
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \c _default_sensitive is \c false, then the sensitivity must be
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen removed. Also, if the view being created is based on the same
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen document as a view already created, the sensitivity should be the
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen same as views on that document. A view with the same document is
c3fcea07965f59723831e23da647a77518285b8eslive looked for, and the sensitivity is matched. Unfortunately, this is
c3fcea07965f59723831e23da647a77518285b8eslive currently a linear search.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen ActionTable::iterator action_found = _actions->find(view);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen // if (action == NULL) printf("Hmm, NULL in %s\n", _name);
c3fcea07965f59723831e23da647a77518285b8eslive if (action == NULL) printf("Hmm, NULL in %s\n", _name);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen for (ActionTable::iterator cur_action = _actions->begin();
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen if (cur_action->first != NULL && cur_action->first->doc() == view->doc()) {
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen sp_action_set_sensitive(action, cur_action->second->sensitive);
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive _actions->insert(ActionTable::value_type(view, action));
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenVerb::sensitive(SPDocument *in_doc, bool in_sensitive)
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz // printf("Setting sensitivity of \"%s\" to %d\n", _name, in_sensitive);
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz for (ActionTable::iterator cur_action = _actions->begin();
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz if (in_doc == NULL || (cur_action->first != NULL && cur_action->first->doc() == in_doc)) {
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz sp_action_set_sensitive(cur_action->second, in_sensitive ? 1 : 0);
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantzVerb::name(SPDocument *in_doc, Glib::ustring in_name)
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz for (ActionTable::iterator cur_action = _actions->begin();
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz if (in_doc == NULL || (cur_action->first != NULL && cur_action->first->doc() == in_doc)) {
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz sp_action_set_name(cur_action->second, in_name);
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz/** \brief A function to remove the action associated with a view.
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz \param view Which view's actions should be removed.
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz \return None
21b70e758d670601065db7b05e16441226e4e9b4jerenkrantz This function looks for the action in \c _actions. If it is
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen found then it is unreferenced and the entry in the action
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen table is erased.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen static int count = 0;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen ActionTable::iterator action_found = _actions->find(view);
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive/** \brief A function to delete a view from all verbs
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \param view Which view's actions should be removed.
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive \return None
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen This function first looks through _base_verbs and deteles
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen the view from all of those views. If \c _verbs is not empty
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen then all of the entries in that table have all of the views
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen deleted also.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen for (int i = 0; i <= SP_VERB_LAST; i++) {
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen // std::cout << "Delete In Verb: " << verbpntr->_name << std::endl;
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief A function to turn a \c code into a Verb for dynamically
97a9a944b5887e91042b019776c41d5dd74557aferikabele created Verbs.
97a9a944b5887e91042b019776c41d5dd74557aferikabele \param code What code is being looked for
97a9a944b5887e91042b019776c41d5dd74557aferikabele \return The found Verb of NULL if none is found.
97a9a944b5887e91042b019776c41d5dd74557aferikabele This function basically just looks through the \c _verbs hash
97a9a944b5887e91042b019776c41d5dd74557aferikabele table. STL does all the work.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Find a Verb using it's ID
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen \param id Which id to search for
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen This function uses the \c _verb_ids has table to find the
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen verb by it's id. Should be much faster than previous
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen implementations.
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Decode the verb code and take appropriate action */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenFileVerb::perform(SPAction *action, void *data, void *pdata)
97a9a944b5887e91042b019776c41d5dd74557aferikabele /* These aren't used, but are here to remind people not to use
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen the CURRENT_DOCUMENT macros unless they really have to. */
97a9a944b5887e91042b019776c41d5dd74557aferikabele Inkscape::UI::View::View *current_view = sp_action_get_view(action);
97a9a944b5887e91042b019776c41d5dd74557aferikabele SPDocument *current_document = current_view->doc();
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen switch ((long) data) {
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen} // end of sp_verb_action_file_perform()
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen/** \brief Decode the verb code and take appropriate action */
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowenEditVerb::perform(SPAction *action, void *data, void *pdata)
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen sp_nodepath_select_all_from_subpath(SP_NODE_CONTEXT(ec)->nodepath, false);
f794e11d17dcdae9f5f2944a5bfd06a7ded6a579yoshiki sp_nodepath_select_all_from_subpath(SP_NODE_CONTEXT(ec)->nodepath, true);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen sp_nodepath_select_all(SP_NODE_CONTEXT(ec)->nodepath, false);
c053576cdcd7389a1e11dd9c656f1f723ae854bcrbowen sp_nodepath_select_all(SP_NODE_CONTEXT(ec)->nodepath, true);
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive} // end of sp_verb_action_edit_perform()
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive/** \brief Decode the verb code and take appropriate action */
eabaccd4bdeaafc3d0c21886863bd9acefea99bbsliveSelectionVerb::perform(SPAction *action, void *data, void *pdata)
eabaccd4bdeaafc3d0c21886863bd9acefea99bbslive SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
case SP_VERB_SELECTION_UNION:
case SP_VERB_SELECTION_DIFF:
case SP_VERB_SELECTION_CUT:
case SP_VERB_SELECTION_SLICE:
case SP_VERB_SELECTION_OFFSET:
case SP_VERB_SELECTION_INSET:
case SP_VERB_SELECTION_TRACE:
switch (verb) {
case SP_VERB_LAYER_NEW: {
case SP_VERB_LAYER_RENAME: {
case SP_VERB_LAYER_NEXT: {
if (next) {
case SP_VERB_LAYER_PREV: {
if (prev) {
case SP_VERB_LAYER_MOVE_TO_NEXT: {
case SP_VERB_LAYER_MOVE_TO_PREV: {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_LOWER: {
switch (verb) {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_LOWER:
switch (verb) {
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_RAISE:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_LOWER:
if (message) {
case SP_VERB_LAYER_DELETE: {
if (!survivor) {
if (survivor) {
if (!dt)
case SP_VERB_OBJECT_FLATTEN:
case SP_VERB_OBJECT_TO_CURVE:
case SP_VERB_OBJECT_FLOW_TEXT:
text_unflow();
case SP_VERB_OBJECT_SET_MASK:
sp_selection_set_mask(false, false);
sp_selection_unset_mask(false);
sp_selection_set_mask(true, false);
sp_selection_unset_mask(true);
int vidx;
if (!dt)
if (tool_action) {
switch (verb) {
case SP_VERB_CONTEXT_SELECT:
case SP_VERB_CONTEXT_NODE:
case SP_VERB_CONTEXT_RECT:
case SP_VERB_CONTEXT_ARC:
case SP_VERB_CONTEXT_STAR:
case SP_VERB_CONTEXT_SPIRAL:
case SP_VERB_CONTEXT_PENCIL:
case SP_VERB_CONTEXT_PEN:
case SP_VERB_CONTEXT_TEXT:
case SP_VERB_CONTEXT_GRADIENT:
case SP_VERB_CONTEXT_ZOOM:
case SP_VERB_CONTEXT_DROPPER:
if (!dt)
(void)doc;
(void)repr;
if (!dt)
case SP_VERB_ZOOM_IN:
case SP_VERB_ZOOM_OUT:
case SP_VERB_ZOOM_1_1:
case SP_VERB_ZOOM_1_2:
case SP_VERB_ZOOM_2_1:
case SP_VERB_ZOOM_PAGE:
case SP_VERB_ZOOM_PAGE_WIDTH:
case SP_VERB_ZOOM_DRAWING:
case SP_VERB_ZOOM_SELECTION:
case SP_VERB_ZOOM_NEXT:
case SP_VERB_ZOOM_PREV:
case SP_VERB_TOGGLE_RULERS:
case SP_VERB_TOGGLE_GUIDES:
case SP_VERB_TOGGLE_GRID:
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
case SP_VERB_FULLSCREEN:
case SP_VERB_VIEW_NEW:
case SP_VERB_VIEW_NEW_PREVIEW:
case SP_VERB_VIEW_MODE_NORMAL:
show_panel( Inkscape::UI::Dialogs::IconPreviewPanel::getInstance(), "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW );
case SP_VERB_DIALOG_DISPLAY:
case SP_VERB_DIALOG_METADATA:
case SP_VERB_DIALOG_NAMEDVIEW:
case SP_VERB_DIALOG_SWATCHES:
show_panel( Inkscape::UI::Dialogs::SwatchesPanel::getInstance(), "dialogs.swatches", SP_VERB_DIALOG_SWATCHES);
case SP_VERB_DIALOG_TRANSFORM:
case SP_VERB_DIALOG_TEXT:
case SP_VERB_DIALOG_FIND:
case SP_VERB_DIALOG_DEBUG:
case SP_VERB_DIALOG_SCRIPT:
case SP_VERB_DIALOG_TOGGLE:
case SP_VERB_DIALOG_ITEM:
#ifdef WITH_INKBOARD
case SP_VERB_XMPP_CLIENT:
case SP_VERB_DIALOG_INPUT:
case SP_VERB_DIALOG_LAYERS:
show_panel( Inkscape::UI::Dialogs::LayersPanel::getInstance(), "dialogs.layers", SP_VERB_DIALOG_LAYERS );
case SP_VERB_HELP_KEYS:
/* TRANSLATORS: If you have translated the keys.svg file to your language, then
translate this string as "keys.LANG.svg" (where LANG is your language code);
otherwise leave as "keys.svg". */
case SP_VERB_HELP_ABOUT:
case SP_VERB_HELP_ABOUT_EXTENSIONS: {
// TRANSLATORS: See "tutorial-basic.svg" comment.
sp_help_open_tutorial(NULL, (gpointer) _("gpl-2.svg"));
case SP_VERB_HELP_MEMORY:
case SP_VERB_TUTORIAL_BASIC:
/* TRANSLATORS: If you have translated the tutorial-basic.svg file to your language,
then translate this string as "tutorial-basic.LANG.svg" (where LANG is your language
code); otherwise leave as "tutorial-basic.svg". */
case SP_VERB_TUTORIAL_SHAPES:
// TRANSLATORS: See "tutorial-basic.svg" comment.
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_TRACING:
// TRANSLATORS: See "tutorial-basic.svg" comment.
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_DESIGN:
// TRANSLATORS: See "tutorial-basic.svg" comment.
case SP_VERB_TUTORIAL_TIPS:
// TRANSLATORS: See "tutorial-basic.svg" comment.
set_default_sensitive(false);
SPAction *
switch ((long) data) {
case SP_VERB_EFFECT_LAST_PREF:
case SP_VERB_EFFECT_LAST:
set_default_sensitive(false);
SPAction *
return action;
if (!dt) return;
if (!doc) return;
switch ((long) data) {
/* these must be in the same order as the SP_VERB_* enum in "verbs.h" */
new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"),
N_("Revert to the last saved version of document (changes will be lost)"), GTK_STOCK_REVERT_TO_SAVED ),
new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Vac_uum Defs"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, "EditPasteSizeSeparately", N_("Paste Size Separately"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X, "EditPasteWidthSeparately", N_("Paste Width Separately"),
new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y, "EditPasteHeightSeparately", N_("Paste Height Separately"),
N_("Cut the selected clone's link to its original, turning it into a standalone object"), "edit_unlink_clone"),
new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"),
new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"),
new SelectionVerb(SP_VERB_SELECTION_REMOVE_KERNS, "SelectionTextRemoveKerns", N_("Remove Manual _Kerns"),
N_("Create exclusive OR of selected paths (those parts that belong to only one path)"), "exclusion"),
new SelectionVerb(SP_VERB_SELECTION_CREATE_BITMAP, "SelectionCreateBitmap", N_("_Make a Bitmap Copy"),
N_("Put text into a frame (path or shape), creating a flowed text linked to the frame object"), NULL),
new ContextVerb(SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "CalligraphicPrefs", N_("Calligraphic Preferences"),
new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), "rulers"),
new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), "scrollbars"),
new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), "guides"),
new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"),
new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"),
new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."),
N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), NULL),
N_("Edit the ID, locked and visible status, and other object properties"), "dialog_item_properties"),
#ifdef WITH_INKBOARD
new DialogVerb(SP_VERB_DIALOG_EXTENSIONEDITOR, "org.inkscape.dialogs.extensioneditor", N_("_Extensions..."),
new TutorialVerb(SP_VERB_TUTORIAL_CALLIGRAPHY, "TutorialsCalligraphy", N_("Inkscape: _Calligraphy"),
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION, "FitCanvasToSelection", N_("Fit Page to Selection"),
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"),