Code

display/inkscape-cairo.h: Supply missing #includes/declarations so that we don't...
[inkscape.git] / src / extension / effect.cpp
index a20f1c6e93dc4ef596e74100448a0137b1a34387..615aeac7ae90d4ec006ea92d49f6992eee4597f7 100644 (file)
@@ -13,7 +13,7 @@
 #include "desktop-handles.h"
 #include "selection.h"
 #include "sp-namedview.h"
-#include "document.h"
+#include "desktop.h"
 #include "implementation/implementation.h"
 #include "effect.h"
 #include "execution-env.h"
@@ -35,7 +35,8 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation *
       _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), _workingDialog(true)
+      _menu_node(NULL), _workingDialog(true),
+      _prefDialog(NULL)
 {
     Inkscape::XML::Node * local_effects_menu = NULL;
 
@@ -46,29 +47,33 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation *
     bool hidden = false;
 
     no_doc = false;
+    no_live_preview = false;
 
     if (repr != NULL) {
 
         for (Inkscape::XML::Node *child = sp_repr_children(repr); child != NULL; child = child->next()) {
-            if (!strcmp(child->name(), "effect")) {
-                if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "no")) {
+            if (!strcmp(child->name(), INKSCAPE_EXTENSION_NS "effect")) {
+                if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "false")) {
                   no_doc = true;
                 }
+                if (child->attribute("needs-live-preview") && !strcmp(child->attribute("needs-live-preview"), "false")) {
+                  no_live_preview = true;
+                }
                 for (Inkscape::XML::Node *effect_child = sp_repr_children(child); effect_child != NULL; effect_child = effect_child->next()) {
-                    if (!strcmp(effect_child->name(), "effects-menu")) {
+                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "effects-menu")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
                         local_effects_menu = sp_repr_children(effect_child);
-                        if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "yes")) {
+                        if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "true")) {
                             hidden = true;
                         }
                     }
-                    if (!strcmp(effect_child->name(), "menu-name") ||
-                            !strcmp(effect_child->name(), "_menu-name")) {
+                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-name") ||
+                            !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-name")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
                         _verb.set_name(sp_repr_children(effect_child)->content());
                     }
-                    if (!strcmp(effect_child->name(), "menu-tip") ||
-                            !strcmp(effect_child->name(), "_menu-tip")) {
+                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-tip") ||
+                            !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-tip")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
                         _verb.set_tip(sp_repr_children(effect_child)->content());
                     }
@@ -206,20 +211,22 @@ Effect::check (void)
 bool
 Effect::prefs (Inkscape::UI::View::View * doc)
 {
+    if (_prefDialog != NULL) {
+        _prefDialog->raise();
+        return true;
+    }
+
+    if (param_visible_count() == 0) {
+        effect(doc);
+        return true;
+    }
+
     if (!loaded())
         set_state(Extension::STATE_LOADED);
     if (!loaded()) return false;
 
-    sigc::signal<void> * changeSignal = new sigc::signal<void>;
-
-    Gtk::Widget * controls;
-    controls = imp->prefs_effect(this, doc, changeSignal);
-
-    ExecutionEnv executionEnv(this, doc, controls, changeSignal);
-
-    timer->lock();
-    executionEnv.run();
-    timer->unlock();
+    _prefDialog = new PrefDialog(this->get_name(), this->get_help(), NULL, this);
+    _prefDialog->show();
 
     return true;
 }
@@ -237,14 +244,21 @@ Effect::prefs (Inkscape::UI::View::View * doc)
 void
 Effect::effect (Inkscape::UI::View::View * doc)
 {
-    printf("Execute effect\n");
+    //printf("Execute effect\n");
     if (!loaded())
         set_state(Extension::STATE_LOADED);
     if (!loaded()) return;
 
 
-    ExecutionEnv executionEnv(this, doc, NULL);
+    ExecutionEnv executionEnv(this, doc);
+    timer->lock();
     executionEnv.run();
+    if (executionEnv.wait()) {
+        executionEnv.commit();
+    } else {
+        executionEnv.cancel();
+    }
+    timer->unlock();
 
     return;
 }
@@ -300,6 +314,13 @@ Effect::get_info_widget(void)
     return Extension::get_info_widget();
 }
 
+void
+Effect::set_pref_dialog (PrefDialog * prefdialog)
+{
+    _prefDialog = prefdialog;
+    return;
+}
+
 /** \brief  Create an action for a \c EffectVerb
     \param  view  Which view the action should be created for
     \return The built action.
@@ -314,7 +335,7 @@ Effect::EffectVerb::make_action (Inkscape::UI::View::View * view)
 
 /** \brief  Decode the verb code and take appropriate action */
 void
-Effect::EffectVerb::perform (SPAction *action, void * data, void *pdata)
+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;