Code

more unreffing temporary styles properly
[inkscape.git] / src / gradient-drag.cpp
index d671b4823822e7e673fb290b73262e01b5661ede..5801489fe0db2114dd225072547bf570da634644 100644 (file)
@@ -802,7 +802,9 @@ GrDragger::fireDraggables (bool write_repr, bool scale_radial, bool merging_focu
         // to the center, unless it's the first update upon merge when we must snap it to the point
         if (merging_focus ||
             !(draggable->point_type == POINT_RG_FOCUS && this->isA(draggable->item, POINT_RG_CENTER, draggable->point_i, draggable->fill_or_stroke)))
+        {
             sp_item_gradient_set_coords (draggable->item, draggable->point_type, draggable->point_i, this->point, draggable->fill_or_stroke, write_repr, scale_radial);
+        }
     }
 }
 
@@ -1743,11 +1745,31 @@ GrDrag::deleteSelected (bool just_one)
         else
         { // delete the gradient from the object. set fill to unset  FIXME: set to fill of unselected node?
             SPCSSAttr *css = sp_repr_css_attr_new ();
-            if (stopinfo->draggable->fill_or_stroke) {
-                sp_repr_css_unset_property (css, "fill");
+
+            // stopinfo->spstop is the selected stop
+            Inkscape::XML::Node *unselectedrepr = SP_OBJECT_REPR(stopinfo->vector)->firstChild();
+            if (unselectedrepr == SP_OBJECT_REPR(stopinfo->spstop) ) {
+                unselectedrepr = unselectedrepr->next();
+            }
+
+            if (unselectedrepr == NULL) {
+                if (stopinfo->draggable->fill_or_stroke) {
+                    sp_repr_css_unset_property (css, "fill");
+                } else {
+                    sp_repr_css_unset_property (css, "stroke");
+                }
             } else {
-                sp_repr_css_unset_property (css, "stroke");
+                SPCSSAttr *stopcss = sp_repr_css_attr(unselectedrepr, "style");
+                if (stopinfo->draggable->fill_or_stroke) {
+                    sp_repr_css_set_property(css, "fill", sp_repr_css_property(stopcss, "stop-color", "inkscape:unset"));
+                    sp_repr_css_set_property(css, "fill-opacity", sp_repr_css_property(stopcss, "stop-opacity", "1"));
+                } else {
+                    sp_repr_css_set_property(css, "stroke", sp_repr_css_property(stopcss, "stop-color", "inkscape:unset"));
+                    sp_repr_css_set_property(css, "stroke-opacity", sp_repr_css_property(stopcss, "stop-opacity", "1"));
+                }
+                sp_repr_css_attr_unref (stopcss);
             }
+            
             sp_repr_css_change (SP_OBJECT_REPR (stopinfo->draggable->item), css, "style");
             sp_repr_css_attr_unref (css);
         }