Code

LPE: fix undoing changes to pathparameter on-canvas.
authorjohanengelen <johanengelen@users.sourceforge.net>
Sat, 20 Oct 2007 16:20:50 +0000 (16:20 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Sat, 20 Oct 2007 16:20:50 +0000 (16:20 +0000)
src/shape-editor.cpp
src/shape-editor.h

index abffeefc4b7463089b0592aa05081c108d75da31..00e7c61b1dc223a13db66fb02ecab01cc4fafddf 100644 (file)
@@ -137,19 +137,12 @@ static void shapeeditor_event_attr_changed(Inkscape::XML::Node *repr, gchar cons
                                            gchar const *old_value, gchar const *new_value,
                                            bool is_interactive, gpointer data)
 {
-    SPItem *item = NULL;
     gboolean changed = FALSE;
 
     g_assert(data);
     ShapeEditor *sh = ((ShapeEditor *) data);
 
-    item = sh->get_item();
-
-    if ( ( (sh->has_nodepath())
-           && (  !strcmp(name, "d") // With paths, we only need to act if one of the path-affecting attributes has changed.
-                 || !strcmp(name, "sodipodi:nodetypes")
-                 || !strcmp(name, "inkscape:original-d") ) )
-          || sh->has_knotholder() )
+    if ( sh->has_nodepath() || sh->has_knotholder() )
     {
         changed = !sh->has_local_change(); 
         sh->decrement_local_change();
@@ -161,7 +154,7 @@ static void shapeeditor_event_attr_changed(Inkscape::XML::Node *repr, gchar cons
             saved = sh->save_nodepath_selection();
         }
 
-        sh->set_item (item);
+        sh->reset_item ();
 
         if (sh->has_nodepath() && saved) {
             sh->restore_nodepath_selection(saved);
@@ -237,6 +230,22 @@ void ShapeEditor::set_item_livepatheffect_parameter(SPItem *item, SPObject *lpeo
     }
 }
 
+/** FIXME: think about this. Is this thing only called when the item needs to be updated?
+   Why not make a reload function in NodePath and in KnotHolder? */
+void ShapeEditor::reset_item ()
+{
+    if ( (this->nodepath) && (IS_LIVEPATHEFFECT(this->nodepath->object)) ) {
+        SPItem * item = this->nodepath->item;
+        SPObject *obj = this->nodepath->object;
+        char * key = g_strdup(this->nodepath->repr_key);
+        set_item_livepatheffect_parameter(item, obj, key);
+        g_free(key);
+    } else {
+        SPItem * item = get_item();
+        set_item(item);
+    }
+}
+
 void ShapeEditor::nodepath_destroyed () {
     this->nodepath = NULL;
 }
index 2df1bb0e005ee9190d1a72ea2b5e49c6a4851341..8f4895be636cb95fca45a7ad08845ed1bd202389 100644 (file)
@@ -37,6 +37,7 @@ public:
 
     void set_item (SPItem *item);
     void set_item_livepatheffect_parameter(SPItem *item, SPObject *lpeobject, const char * key);
+    void reset_item ();
     void unset_item ();
 
     SPItem *get_item ();