Code

Sync to release 0.48 branch
[inkscape.git] / src / extension / internal / bluredge.cpp
index aa1f3ece3fa29852248e95473bd153a6e75fe63d..e32012070ae6082549d8fc6d9eae1cc530a58105 100644 (file)
@@ -16,7 +16,7 @@
 #include "desktop.h"
 #include "selection.h"
 #include "helper/action.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "path-chemistry.h"
 #include "sp-item.h"
 
@@ -39,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;
@@ -48,17 +48,18 @@ BlurEdge::load (Inkscape::Extension::Extension *module)
 /**
     \brief  This actually blurs the edge.
     \param  module   The effect that was called (unused)
-    \param  document What should be edited.
+    \param  desktop 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 *desktop, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
 {
-    Inkscape::Selection * selection     = ((SPDesktop *)document)->selection;
+    Inkscape::Selection * selection     = static_cast<SPDesktop *>(desktop)->selection;
 
     float width = module->get_param_float("blur-width");
     int   steps = module->get_param_int("num-steps");
 
-    double old_offset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
 
     using Inkscape::Util::GSListConstIterator;
     // TODO need to properly refcount the items, at least
@@ -71,7 +72,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
         SPItem * spitem = *item;
 
         std::vector<Inkscape::XML::Node *> new_items(steps);
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document->doc());
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
         Inkscape::XML::Node * new_group = xml_doc->createElement("svg:g");
         (SP_OBJECT_REPR(spitem)->parent())->appendChild(new_group);
 
@@ -91,24 +92,25 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
 
             new_group->appendChild(new_items[i]);
             selection->add(new_items[i]);
-            sp_selected_path_to_curves();
+            sp_selected_path_to_curves(static_cast<SPDesktop *>(desktop));
 
             if (offset < 0.0) {
                 /* Doing an inset here folks */
                 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);
+                prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+                sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL);
             } 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);
+                prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+                sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL);
             }
 
             selection->clear();
         }
 
+        Inkscape::GC::release(new_group);
     }
 
-    prefs_set_double_attribute("options.defaultoffsetwidth", "value", old_offset);
+    prefs->setDouble("/options/defaultoffsetwidth/value", old_offset);
 
     selection->clear();
     selection->add(items.begin(), items.end());
@@ -117,7 +119,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
 }
 
 Gtk::Widget *
-BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal)
+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, changeSignal);
 }
@@ -128,7 +130,7 @@ void
 BlurEdge::init (void)
 {
     Inkscape::Extension::build_from_mem(
-        "<inkscape-extension>\n"
+        "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
             "<name>" N_("Inset/Outset Halo") "</name>\n"
             "<id>org.inkscape.effect.bluredge</id>\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"