summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2007-03-01 07:14:41 +0000
committergouldtj <gouldtj@users.sourceforge.net>2007-03-01 07:14:41 +0000
commit99ffaf09bea5e0104cce510cf476ffdeafe73331 (patch)
treef3661358275555cdbb52fbab0e9672b888ca793c /src
parentr14583@tres: ted | 2007-02-28 19:29:48 -0800 (diff)
downloadinkscape-99ffaf09bea5e0104cce510cf476ffdeafe73331.tar.gz
inkscape-99ffaf09bea5e0104cce510cf476ffdeafe73331.zip
r14584@tres: ted | 2007-02-28 20:01:52 -0800
Effects now register two different verbs. One is the same one they've always registered and one is the same ID with ".nopref" added to it. This one executes the effect without the prefrences dialog. Default values will be used. (bzr r2480)
Diffstat (limited to 'src')
-rw-r--r--src/extension/effect.cpp18
-rw-r--r--src/extension/effect.h14
2 files changed, 26 insertions, 6 deletions
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index 0f9434c17..10ac493b5 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -24,7 +24,12 @@ Effect * Effect::_last_effect = NULL;
Inkscape::XML::Node * Effect::_effects_list = NULL;
Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
- : Extension(in_repr, in_imp), _verb(get_id(), get_name(), NULL, NULL, this), _menu_node(NULL)
+ : Extension(in_repr, in_imp),
+ _id_noprefs(Glib::ustring(get_id()) + ".noprefs"),
+ _name_noprefs(Glib::ustring(get_name()) + _(" (No preferences)")),
+ _verb(get_id(), get_name(), NULL, NULL, this, true),
+ _verb_nopref(_id_noprefs.c_str(), _name_noprefs.c_str(), NULL, NULL, this, false),
+ _menu_node(NULL)
{
Inkscape::XML::Node * local_effects_menu = NULL;
@@ -293,7 +298,7 @@ Effect::get_info_widget(void)
SPAction *
Effect::EffectVerb::make_action (Inkscape::UI::View::View * view)
{
- return make_action_helper(view, &vector, static_cast<void *>(_effect));
+ return make_action_helper(view, &vector, static_cast<void *>(this));
}
/** \brief Decode the verb code and take appropriate action */
@@ -302,13 +307,18 @@ Effect::EffectVerb::perform (SPAction *action, void * data, void *pdata)
{
Inkscape::UI::View::View * current_view = sp_action_get_view(action);
// SPDocument * current_document = current_view->doc;
- Effect * effect = reinterpret_cast<Effect *>(data);
+ Effect::EffectVerb * ev = reinterpret_cast<Effect::EffectVerb *>(data);
+ Effect * effect = ev->_effect;
if (effect == NULL) return;
if (current_view == NULL) return;
// std::cout << "Executing: " << effect->get_name() << std::endl;
- if (effect->prefs(current_view))
+ bool execute = true;
+
+ if (ev->_showPrefs)
+ execute = effect->prefs(current_view);
+ if (execute)
effect->effect(current_view);
return;
diff --git a/src/extension/effect.h b/src/extension/effect.h
index c0231eac4..b6fc80aa5 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -56,6 +56,8 @@ class Effect : public Extension {
/** \brief The effect that this verb represents. */
Effect * _effect;
+ /** \brief Whether or not to show preferences on display */
+ bool _showPrefs;
protected:
virtual SPAction * make_action (Inkscape::UI::View::View * view);
public:
@@ -64,15 +66,23 @@ class Effect : public Extension {
gchar const * name,
gchar const * tip,
gchar const * image,
- Effect * effect) :
- Verb(id, _(name), _(tip), image), _effect(effect) {
+ Effect * effect,
+ bool showPrefs) :
+ Verb(id, _(name), _(tip), image), _effect(effect), _showPrefs(showPrefs) {
/* No clue why, but this is required */
this->set_default_sensitive(true);
}
};
+ /** \brief ID used for the verb without preferences */
+ Glib::ustring _id_noprefs;
+ /** \brief Name used for the verb without preferences */
+ Glib::ustring _name_noprefs;
+
/** \brief The verb representing this effect. */
EffectVerb _verb;
+ /** \brief The verb representing this effect. Without preferences. */
+ EffectVerb _verb_nopref;
/** \brief Menu node created for this effect */
Inkscape::XML::Node * _menu_node;
public: