Code

Add a zoom correction option to preferences (used when zooming to 1:1 etc. to display...
[inkscape.git] / src / ui / dialog / livepatheffect-editor.cpp
index ee010eeca4a12597eefc8f09e6f6cbf0d6114180..567ee24dadf47ada4130dd7d0b7e0c0a7166dbb6 100644 (file)
-/**\r
- * \brief LivePathEffect dialog\r
- *\r
- * Authors:\r
- *   Johan Engelen <j.b.c.engelen@utwente.nl>\r
- *\r
- * Copyright (C) 2007 Author\r
- *\r
- * Released under GNU GPL.  Read the file 'COPYING' for more information.\r
- */\r
-\r
-#ifdef HAVE_CONFIG_H\r
-# include <config.h>\r
-#endif\r
-\r
-#include <glibmm/i18n.h>\r
-#include "livepatheffect-editor.h"\r
-#include "verbs.h"\r
-#include "selection.h"\r
-#include "sp-shape.h"\r
-#include "sp-path.h"\r
-#include "live_effects/effect.h"\r
-#include "live_effects/lpeobject.h"\r
-#include "gtkmm/widget.h"\r
-#include <vector>\r
-#include "inkscape.h"\r
-#include "desktop-handles.h"\r
-#include "desktop.h"\r
-#include "document-private.h"\r
-#include "xml/node.h"\r
-#include "xml/document.h"\r
-\r
-namespace Inkscape {\r
-class Application;\r
-\r
-namespace UI {\r
-namespace Dialog {\r
-\r
-\r
-/*####################\r
- * Callback functions\r
- */\r
-static void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)\r
-{\r
-    LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);\r
-    lpeeditor->onSelectionChanged(selection);\r
-}\r
-\r
-static void lpeeditor_selection_modified (Inkscape::Selection *selection, guint flags, gpointer data)\r
-{\r
-    lpeeditor_selection_changed (selection, data);\r
-}\r
-\r
-\r
-static void lpeeditor_desktop_change(Inkscape::Application*, SPDesktop* desktop, void *data)\r
-{\r
-    if (!desktop) {\r
-        return;\r
-    }\r
-    LivePathEffectEditor* editor = reinterpret_cast<LivePathEffectEditor*>(data);\r
-    editor->setDesktop(desktop);\r
-}\r
-\r
-\r
-\r
-/*#######################\r
- * LivePathEffectEditor\r
- */\r
-LivePathEffectEditor::LivePathEffectEditor(Behavior::BehaviorFactory behavior_factory) \r
-    : Dialog (behavior_factory, "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),\r
-      combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),\r
-      button_apply(_("_Apply"), _("Apply chosen effect to selection")),\r
-      button_remove(_("_Remove"), _("Remove effect from selection")),\r
-      effectwidget(NULL),\r
-      explain_label("", Gtk::ALIGN_CENTER),\r
-      effectapplication_frame(_("Apply new effect")),\r
-      effectcontrol_frame(_("Current effect")),\r
-      current_desktop(NULL)\r
-{\r
-    // Top level vbox\r
-    Gtk::VBox *vbox = get_vbox();\r
-    vbox->set_spacing(4);\r
-\r
-    effectapplication_vbox.set_spacing(4);\r
-    effectcontrol_vbox.set_spacing(4);\r
-\r
-    effectapplication_vbox.pack_start(combo_effecttype, true, true);\r
-    effectapplication_vbox.pack_start(button_apply, true, true);\r
-    effectapplication_vbox.pack_start(button_remove, true, true);\r
-    effectapplication_frame.add(effectapplication_vbox);\r
-\r
-    effectcontrol_vbox.pack_start(explain_label, true, true);\r
-    effectcontrol_frame.add(effectcontrol_vbox);\r
-\r
-    vbox->pack_start(effectapplication_frame, true, true);\r
-    vbox->pack_start(effectcontrol_frame, true, true);\r
-\r
-    // connect callback functions to buttons\r
-    button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply));\r
-    button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));\r
-\r
-    // connect callback functions to changes in selected desktop.\r
-    g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop",\r
-                       G_CALLBACK(lpeeditor_desktop_change), this);\r
-\r
-    g_signal_connect( G_OBJECT(INKSCAPE), "deactivate_desktop",\r
-                       G_CALLBACK(lpeeditor_desktop_change), this);\r
-\r
-    setDesktop(SP_ACTIVE_DESKTOP);\r
-    show_all_children();\r
-}\r
-\r
-LivePathEffectEditor::~LivePathEffectEditor() \r
-{\r
-    if (effectwidget) {\r
-        effectcontrol_vbox.remove(*effectwidget);\r
-        effectwidget = NULL;\r
-    }\r
-\r
-    if (current_desktop) {\r
-        selection_changed_connection.disconnect();\r
-        selection_modified_connection.disconnect();\r
-    }\r
-}\r
-\r
-void\r
-LivePathEffectEditor::showParams(LivePathEffect::Effect* effect)\r
-{\r
-    if (effectwidget) {\r
-        effectcontrol_vbox.remove(*effectwidget);\r
-        effectwidget = NULL;\r
-    }\r
-\r
-    explain_label.set_markup("<b>" + effect->getName() + "</b>");\r
-    effectwidget = effect->getWidget();\r
-    if (effectwidget) {\r
-        effectcontrol_vbox.pack_start(*effectwidget, true, true);\r
-    }\r
-\r
-    effectcontrol_vbox.show_all_children();\r
-    // fixme: do resizing of dialog \r
-}\r
-\r
-void\r
-LivePathEffectEditor::showText(Glib::ustring const &str)\r
-{\r
-    if (effectwidget) {\r
-        effectcontrol_vbox.remove(*effectwidget);\r
-        effectwidget = NULL;\r
-    }\r
-\r
-    explain_label.set_label(str);\r
-\r
-    // fixme: do resizing of dialog ?\r
-}\r
-\r
-void\r
-LivePathEffectEditor::set_sensitize_all(bool sensitive)\r
-{\r
-    combo_effecttype.set_sensitive(sensitive);\r
-    button_apply.set_sensitive(sensitive);\r
-    button_remove.set_sensitive(sensitive);\r
-}\r
-\r
-void\r
-LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)\r
-{\r
-    if ( sel && !sel->isEmpty() ) {\r
-        SPItem *item = sel->singleItem();\r
-        if ( item ) {\r
-            if ( SP_IS_SHAPE(item) ) {\r
-                SPShape *shape = SP_SHAPE(item);\r
-                LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);\r
-                set_sensitize_all(true);\r
-                if (lpeobj) {\r
-                    if (lpeobj->lpe) {\r
-                        showParams(lpeobj->lpe);\r
-                    } else {\r
-                        showText(_("Unknown effect is applied"));\r
-                    }\r
-                } else {\r
-                    showText(_("No effect applied"));\r
-                    button_remove.set_sensitive(false);\r
-                }\r
-            } else {\r
-                showText(_("Item is not a shape"));\r
-                set_sensitize_all(false);\r
-            }\r
-        } else {\r
-            showText(_("Only one item can be selected"));\r
-            set_sensitize_all(false);\r
-        }\r
-    } else {\r
-        showText(_("Empty selection"));\r
-        set_sensitize_all(false);\r
-    }\r
-}\r
-\r
-void \r
-LivePathEffectEditor::setDesktop(SPDesktop *desktop)\r
-{\r
-\r
-    if ( desktop == current_desktop ) {\r
-        return;\r
-    }\r
-\r
-    if (current_desktop) {\r
-        selection_changed_connection.disconnect();\r
-        selection_modified_connection.disconnect();\r
-    }\r
-\r
-    current_desktop = desktop;\r
-    if (desktop) {\r
-        Inkscape::Selection *selection = sp_desktop_selection(desktop);\r
-        selection_changed_connection = selection->connectChanged(\r
-            sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );\r
-        selection_modified_connection = selection->connectModified(\r
-            sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );\r
-\r
-        onSelectionChanged(selection);\r
-    } else {\r
-        onSelectionChanged(NULL);\r
-    }\r
-}\r
-\r
-\r
-\r
-\r
-/*########################################################################\r
-# BUTTON CLICK HANDLERS    (callbacks)\r
-########################################################################*/\r
-\r
-void\r
-LivePathEffectEditor::onApply()\r
-{\r
-    Inkscape::Selection *sel = _getSelection();\r
-    if ( sel && !sel->isEmpty() ) {\r
-        SPItem *item = sel->singleItem();\r
-        if ( item && SP_IS_SHAPE(item) ) {\r
-            SPDocument *doc = current_desktop->doc();\r
-\r
-            const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data();\r
-            if (!data) return;\r
-\r
-            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);\r
-            Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");\r
-            repr->setAttribute("effect", data->key.c_str() );\r
-\r
-            SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute\r
-            const gchar * repr_id = repr->attribute("id");\r
-            Inkscape::GC::release(repr);\r
-\r
-            gchar *href = g_strdup_printf("#%s", repr_id);\r
-            sp_shape_set_path_effect(SP_SHAPE(item), href);\r
-            g_free(href);\r
-\r
-            // make sure there is an original-d for paths!!!\r
-            if ( SP_IS_PATH(item) ) {\r
-                Inkscape::XML::Node *pathrepr = SP_OBJECT_REPR(item);\r
-                if ( ! pathrepr->attribute("inkscape:original-d") ) {\r
-                    pathrepr->setAttribute("inkscape:original-d", pathrepr->attribute("d"));\r
-                }\r
-            }\r
-\r
-            sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, \r
-                             _("Create and apply live effect"));\r
-        }\r
-    }\r
-}\r
-\r
-void\r
-LivePathEffectEditor::onRemove()\r
-{\r
-    Inkscape::Selection *sel = _getSelection();\r
-    if ( sel && !sel->isEmpty() ) {\r
-        SPItem *item = sel->singleItem();\r
-        if ( item && SP_IS_SHAPE(item) ) {\r
-            sp_shape_remove_path_effect(SP_SHAPE(item));\r
-            sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, \r
-                               _("Remove live path effect") );\r
-        }\r
-    }\r
-}\r
-\r
-\r
-\r
-} // namespace Dialog\r
-} // namespace UI\r
-} // namespace Inkscape\r
-\r
+/**
+ * \brief LivePathEffect dialog
+ *
+ * Authors:
+ *   Johan Engelen <j.b.c.engelen@utwente.nl>
+ *   Steren Giannini <steren.giannini@gmail.com>
+ *   Bastien Bouclet <bgkweb@gmail.com>
+ *
+ * Copyright (C) 2007 Author
+ *
+ * Released under GNU GPL.  Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glibmm/i18n.h>
+#include "livepatheffect-editor.h"
+#include "ui/widget/imagetoggler.h"
+#include "verbs.h"
+#include "selection.h"
+#include "sp-shape.h"
+#include "sp-item-group.h"
+#include "sp-path.h"
+#include "sp-rect.h"
+#include "sp-lpe-item.h"
+#include "path-chemistry.h"
+#include "live_effects/effect.h"
+#include "live_effects/lpeobject.h"
+#include "gtkmm/widget.h"
+#include <vector>
+#include "inkscape.h"
+#include "desktop-handles.h"
+#include "desktop.h"
+#include "document.h"
+#include "xml/node.h"
+#include <gtkmm/stock.h>
+#include <gtkmm/toolbar.h>
+
+#include "live_effects/lpeobject-reference.h"
+
+namespace Inkscape {
+class Application;
+
+namespace UI {
+namespace Dialog {
+
+
+/*####################
+ * Callback functions
+ */
+static void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)
+{
+    LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
+    lpeeditor->onSelectionChanged(selection);
+}
+
+static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
+{
+    LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
+    lpeeditor->onSelectionChanged(selection);
+}
+
+
+/*#######################
+ * LivePathEffectEditor
+ */
+
+LivePathEffectEditor::LivePathEffectEditor()
+    : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
+      lpe_list_locked(false),
+      combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
+      effectwidget(NULL),
+      explain_label("", Gtk::ALIGN_CENTER),
+      effectapplication_frame(_("Apply new effect")),
+      effectcontrol_frame(_("Current effect")),
+      effectlist_frame(_("Effect list")),
+      button_up(Gtk::Stock::GO_UP),
+      button_down(Gtk::Stock::GO_DOWN),
+      button_apply(Gtk::Stock::ADD),
+      button_remove(Gtk::Stock::REMOVE),
+      current_desktop(NULL),
+      current_lpeitem(NULL)
+{
+    Gtk::Box *contents = _getContents();
+    contents->set_spacing(4);
+
+    //Add the TreeView, inside a ScrolledWindow, with the button underneath:
+    scrolled_window.add(effectlist_view);
+    //Only show the scrollbars when they are necessary:
+    scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+
+    effectapplication_hbox.set_spacing(4);
+    effectcontrol_vbox.set_spacing(4);
+    effectlist_vbox.set_spacing(4);
+
+    effectapplication_hbox.pack_start(combo_effecttype, true, true);
+    effectapplication_hbox.pack_start(button_apply, true, true);
+    effectapplication_frame.add(effectapplication_hbox);
+
+    effectlist_vbox.pack_start(scrolled_window, Gtk::PACK_EXPAND_WIDGET);
+    effectlist_vbox.pack_end(toolbar, Gtk::PACK_SHRINK);
+   // effectlist_vbox.pack_end(button_hbox, Gtk::PACK_SHRINK);
+    effectlist_frame.add(effectlist_vbox);
+
+    effectcontrol_vbox.pack_start(explain_label, true, true);
+    effectcontrol_frame.add(effectcontrol_vbox);
+
+ //   button_hbox.pack_start(button_up, true, true);
+ //   button_hbox.pack_start(button_down, true, true);
+ //   button_hbox.pack_end(button_remove, true, true);
+    toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
+ // Add toolbar items to toolbar
+    toolbar.append(button_up);
+    toolbar.append(button_down);
+    toolbar.append(button_remove);
+
+
+    // Add toolbar
+    //add_toolbar(toolbar);
+    toolbar.show_all(); //Show the toolbar and all its child widgets.
+
+
+    //Create the Tree model:
+    effectlist_store = Gtk::ListStore::create(columns);
+    effectlist_view.set_model(effectlist_store);
+
+    effectlist_view.set_headers_visible(false);
+
+    // Handle tree selections
+    effectlist_selection = effectlist_view.get_selection();
+    effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) );
+
+    //Add the visibility icon column:
+    Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler("visible", "hidden") );
+    int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1;
+    eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) );
+    eyeRenderer->property_activatable() = true;
+    Gtk::TreeViewColumn* col = effectlist_view.get_column(visibleColNum);
+    if ( col ) {
+        col->add_attribute( eyeRenderer->property_active(), columns.col_visible );
+    }
+
+    //Add the effect name column:
+    effectlist_view.append_column("Effect", columns.col_name);
+
+    contents->pack_start(effectapplication_frame, false, false);
+    contents->pack_start(effectlist_frame, true, true);
+    contents->pack_start(effectcontrol_frame, false, false);
+
+    // connect callback functions to buttons
+    button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply));
+    button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));
+
+    button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp));
+    button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown));
+
+    show_all_children();
+
+    //button_remove.hide();
+}
+
+LivePathEffectEditor::~LivePathEffectEditor()
+{
+    if (effectwidget) {
+        effectcontrol_vbox.remove(*effectwidget);
+        delete effectwidget;
+        effectwidget = NULL;
+    }
+
+    if (current_desktop) {
+        selection_changed_connection.disconnect();
+        selection_modified_connection.disconnect();
+    }
+}
+
+void
+LivePathEffectEditor::showParams(LivePathEffect::Effect* effect)
+{
+    if (effectwidget) {
+        effectcontrol_vbox.remove(*effectwidget);
+        delete effectwidget;
+        effectwidget = NULL;
+    }
+
+    explain_label.set_markup("<b>" + effect->getName() + "</b>");
+    effectwidget = effect->newWidget(&tooltips);
+    if (effectwidget) {
+        effectcontrol_vbox.pack_start(*effectwidget, true, true);
+    }
+    button_remove.show();
+
+    effectcontrol_vbox.show_all_children();
+    // fixme: add resizing of dialog
+}
+
+void
+LivePathEffectEditor::selectInList(LivePathEffect::Effect* effect)
+{
+    Gtk::TreeNodeChildren chi = effectlist_view.get_model()->children();
+    for (Gtk::TreeIter ci = chi.begin() ; ci != chi.end(); ci++) {
+        if (ci->get_value(columns.lperef)->lpeobject->lpe == effect)
+            effectlist_view.get_selection()->select(ci);
+    }
+}
+
+
+void
+LivePathEffectEditor::showText(Glib::ustring const &str)
+{
+    if (effectwidget) {
+        effectcontrol_vbox.remove(*effectwidget);
+        delete effectwidget;
+        effectwidget = NULL;
+    }
+
+    explain_label.set_label(str);
+    //button_remove.hide();
+
+    // fixme: do resizing of dialog ?
+}
+
+void
+LivePathEffectEditor::set_sensitize_all(bool sensitive)
+{
+    combo_effecttype.set_sensitive(sensitive);
+    button_apply.set_sensitive(sensitive);
+    button_remove.set_sensitive(sensitive);
+    effectlist_view.set_sensitive(sensitive);
+    button_up.set_sensitive(sensitive);
+    button_down.set_sensitive(sensitive);
+}
+
+
+void
+LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
+{
+    if (lpe_list_locked) {
+        // this was triggered by selecting a row in the list, so skip reloading
+        lpe_list_locked = false;
+        return;
+    } 
+
+    effectlist_store->clear();
+    current_lpeitem = NULL;
+
+    if ( sel && !sel->isEmpty() ) {
+        SPItem *item = sel->singleItem();
+        if ( item ) {
+            if ( SP_IS_LPE_ITEM(item) ) {
+                SPLPEItem *lpeitem = SP_LPE_ITEM(item);
+
+                effect_list_reload(lpeitem);
+
+                current_lpeitem = lpeitem;
+
+                set_sensitize_all(true);
+                if ( sp_lpe_item_has_path_effect(lpeitem) ) {
+                    Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem);
+                    if (lpe) {
+                        showParams(lpe);
+                        lpe_list_locked = true; 
+                        selectInList(lpe);
+                    } else {
+                        showText(_("Unknown effect is applied"));
+                    }
+                } else {
+                    showText(_("No effect applied"));
+                    button_remove.set_sensitive(false);
+                }
+            } else {
+                showText(_("Item is not a path or shape"));
+                set_sensitize_all(false);
+            }
+        } else {
+            showText(_("Only one item can be selected"));
+            set_sensitize_all(false);
+        }
+    } else {
+        showText(_("Empty selection"));
+        set_sensitize_all(false);
+    }
+}
+
+/*
+ * First clears the effectlist_store, then appends all effects from the effectlist.
+ */
+void
+LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem)
+{
+    effectlist_store->clear();
+
+    PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem);
+    PathEffectList::iterator it;
+    for( it = effectlist.begin() ; it!=effectlist.end(); it++ )
+    {
+         Gtk::TreeModel::Row row = *(effectlist_store->append());
+         row[columns.col_name] = (*it)->lpeobject->lpe->getName();
+         row[columns.lperef] = *it;
+         row[columns.col_visible] = (*it)->lpeobject->lpe->isVisible();
+    }
+}
+
+
+void
+LivePathEffectEditor::setDesktop(SPDesktop *desktop)
+{
+    Panel::setDesktop(desktop);
+
+    if ( desktop == current_desktop ) {
+        return;
+    }
+
+    if (current_desktop) {
+        selection_changed_connection.disconnect();
+        selection_modified_connection.disconnect();
+    }
+
+    current_desktop = desktop;
+    if (desktop) {
+        Inkscape::Selection *selection = sp_desktop_selection(desktop);
+        selection_changed_connection = selection->connectChanged(
+            sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
+        selection_modified_connection = selection->connectModified(
+            sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );
+
+        onSelectionChanged(selection);
+    } else {
+        onSelectionChanged(NULL);
+    }
+}
+
+
+
+
+/*########################################################################
+# BUTTON CLICK HANDLERS    (callbacks)
+########################################################################*/
+
+// TODO:  factor out the effect applying code which can be called from anywhere. (selection-chemistry.cpp also needs it)
+
+void
+LivePathEffectEditor::onApply()
+{
+    Inkscape::Selection *sel = _getSelection();
+    if ( sel && !sel->isEmpty() ) {
+        SPItem *item = sel->singleItem();
+        if ( item && SP_IS_LPE_ITEM(item) ) {
+            SPDocument *doc = current_desktop->doc();
+
+            const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data();
+            if (!data) return;
+
+            // If item is a SPRect, convert it to path first:
+            if ( SP_IS_RECT(item) ) {
+                sp_selected_path_to_curves(false);
+                item = sel->singleItem(); // get new item
+            }
+
+            LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item);
+
+            sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                     _("Create and apply path effect"));
+
+            onSelectionChanged(sel);
+        }
+    }
+}
+
+void
+LivePathEffectEditor::onRemove()
+{
+    Inkscape::Selection *sel = _getSelection();
+    if ( sel && !sel->isEmpty() ) {
+        SPItem *item = sel->singleItem();
+        if ( item && SP_IS_LPE_ITEM(item) ) {
+            sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false);
+
+            sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                               _("Remove path effect") );
+
+            effect_list_reload(SP_LPE_ITEM(item));
+        }
+    }
+}
+
+void LivePathEffectEditor::onUp()
+{
+    Inkscape::Selection *sel = _getSelection();
+    if ( sel && !sel->isEmpty() ) {
+        SPItem *item = sel->singleItem();
+        if ( item && SP_IS_LPE_ITEM(item) ) {
+            sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item));
+
+            sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                               _("Move path effect up") );
+
+            effect_list_reload(SP_LPE_ITEM(item));
+        }
+    }
+}
+
+void LivePathEffectEditor::onDown()
+{
+    Inkscape::Selection *sel = _getSelection();
+    if ( sel && !sel->isEmpty() ) {
+        SPItem *item = sel->singleItem();
+        if ( item && SP_IS_LPE_ITEM(item) ) {
+            sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item));
+
+            sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                               _("Move path effect down") );
+
+            effect_list_reload(SP_LPE_ITEM(item));
+        }
+    }
+}
+
+void LivePathEffectEditor::on_effect_selection_changed()
+{
+    Glib::RefPtr<Gtk::TreeSelection> sel = effectlist_view.get_selection();
+    if (sel->count_selected_rows () == 0)
+        return;
+
+    Gtk::TreeModel::iterator it = sel->get_selected();
+    LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
+
+    if (lperef && current_lpeitem) {
+        lpe_list_locked = true; // prevent reload of the list which would lose selection
+        sp_lpe_item_set_current_path_effect(current_lpeitem, lperef);
+        showParams(lperef->lpeobject->lpe);
+    }
+}
+
+void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
+{
+    Gtk::TreeModel::Children::iterator iter = effectlist_view.get_model()->get_iter(str);
+    Gtk::TreeModel::Row row = *iter;
+
+    LivePathEffect::LPEObjectReference * lpeobjref = row[columns.lperef];
+
+    if ( lpeobjref ) {
+        bool newValue = !row[columns.col_visible];
+        row[columns.col_visible] = newValue;
+        /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
+         * So one can call:  lpe_item->setActive(lpeobjref->lpeobject); */
+        lpeobjref->lpeobject->lpe->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
+        sp_document_done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                          newValue ? _("Activate path effect") : _("Deactivate path effect"));
+    }
+}
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :