Code

fix include paths
[inkscape.git] / src / extension / internal / bluredge.cpp
index 29036df7a86b38f8ecc05f9c03a32257f7de873c..4a732fb495c193e67828fddbe302ac22e8decbaa 100644 (file)
@@ -12,6 +12,7 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
+#include <vector>
 #include "desktop.h"
 #include "selection.h"
 #include "helper/action.h"
@@ -38,7 +39,7 @@ namespace Internal {
     \return Whether the load was sucessful
 */
 bool
-BlurEdge::load (Inkscape::Extension::Extension *module)
+BlurEdge::load (Inkscape::Extension::Extension */*module*/)
 {
     // std::cout << "Hey, I'm Blur Edge, I'm loading!" << std::endl;
     return TRUE;
@@ -50,7 +51,7 @@ BlurEdge::load (Inkscape::Extension::Extension *module)
     \param  document What should be edited.
 */
 void
-BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document)
+BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
 {
     Inkscape::Selection * selection     = ((SPDesktop *)document)->selection;
 
@@ -65,16 +66,14 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
     items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
     selection->clear();
 
-    std::list<SPItem *> new_items;
     for(std::list<SPItem *>::iterator item = items.begin();
             item != items.end(); item++) {
         SPItem * spitem = *item;
 
-        Inkscape::XML::Node * new_items[steps];
-        Inkscape::XML::Node * new_group = sp_repr_new("svg:g");
+        std::vector<Inkscape::XML::Node *> new_items(steps);
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document->doc());
+        Inkscape::XML::Node * new_group = xml_doc->createElement("svg:g");
         (SP_OBJECT_REPR(spitem)->parent())->appendChild(new_group);
-        /** \todo  Need to figure out how to get from XML::Node to SPItem */
-        /* new_items.push_back(); */
 
         double orig_opacity = sp_repr_css_double_property(sp_repr_css_attr(SP_OBJECT_REPR(spitem), "style"), "opacity", 1.0);
         char opacity_string[64];
@@ -84,7 +83,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
         for (int i = 0; i < steps; i++) {
             double offset = (width / (float)(steps - 1) * (float)i) - (width / 2.0);
 
-            new_items[i] = (SP_OBJECT_REPR(spitem))->duplicate();
+            new_items[i] = (SP_OBJECT_REPR(spitem))->duplicate(xml_doc);
 
             SPCSSAttr * css = sp_repr_css_attr(new_items[i], "style");
             sp_repr_css_set_property(css, "opacity", opacity_string);
@@ -99,8 +98,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
                 offset *= -1.0;
                 prefs_set_double_attribute("options.defaultoffsetwidth", "value", offset);
                 sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(document), NULL);
-            } else if (offset == 0.0) {
-            } else {
+            } else if (offset > 0.0) {
                 prefs_set_double_attribute("options.defaultoffsetwidth", "value", offset);
                 sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(document), NULL);
             }
@@ -114,15 +112,14 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
 
     selection->clear();
     selection->add(items.begin(), items.end());
-    selection->add(new_items.begin(), new_items.end());
 
     return;
 }
 
 Gtk::Widget *
-BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view)
+BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * /*view*/, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
 {
-    return module->autogui(NULL, NULL);
+    return module->autogui(NULL, NULL, changeSignal);
 }
 
 #include "clear-n_.h"
@@ -132,10 +129,10 @@ BlurEdge::init (void)
 {
     Inkscape::Extension::build_from_mem(
         "<inkscape-extension>\n"
-            "<name>" N_("Blur Edge") "</name>\n"
+            "<name>" N_("Inset/Outset Halo") "</name>\n"
             "<id>org.inkscape.effect.bluredge</id>\n"
-            "<param name=\"blur-width\" gui-text=\"" N_("Blur Width") "\" gui-description=\"" N_("Width in pixels of the blurred area") "\" scope=\"document\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n"
-            "<param name=\"num-steps\" gui-text=\"" N_("Number of Steps") "\" gui-description=\"" N_("Number of copies of the object to make to simulate the blur") "\" scope=\"document\" type=\"int\" min=\"5\" max=\"100\">11</param>\n"
+            "<param name=\"blur-width\" gui-text=\"" N_("Width") "\" gui-description=\"" N_("Width in px of the halo") "\" scope=\"document\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n"
+            "<param name=\"num-steps\" gui-text=\"" N_("Number of steps") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" scope=\"document\" type=\"int\" min=\"5\" max=\"100\">11</param>\n"
             "<effect>\n"
                 "<object-type>all</object-type>\n"
                 "<effects-menu>\n"