From 8f6879f2ede34a0783f72b2276d4318f5b112900 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 6 Jul 2010 01:28:56 -0700 Subject: Removed "Add" and enabled "Delete" for swatch context menu. Updated swatch marker string. (bzr r9582) --- src/sp-gradient.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 9c1ea0da7..2a3142b04 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -288,15 +288,19 @@ SPGradientSpread SPGradient::getSpread() const return spread; } -void SPGradient::setSwatch() +void SPGradient::setSwatch( bool swatch ) { - if ( !isSwatch() ) { - if ( hasStops() && (getStopCount() == 0) ) { - repr->setAttribute("osb:paint", "solid"); + if ( swatch != isSwatch() ) { + if ( swatch ) { + if ( hasStops() && (getStopCount() == 0) ) { + repr->setAttribute( "osb:paint", "solid" ); + } else { + repr->setAttribute( "osb:paint", "gradient" ); + } } else { - repr->setAttribute("osb:paint", "gradient"); + repr->setAttribute( "osb:paint", 0 ); } - requestModified(SP_OBJECT_MODIFIED_FLAG); + requestModified( SP_OBJECT_MODIFIED_FLAG ); } } @@ -594,12 +598,19 @@ void SPGradientImpl::childAdded(SPObject *object, Inkscape::XML::Node *child, In gr->invalidateVector(); - if (((SPObjectClass *) gradient_parent_class)->child_added) + if (((SPObjectClass *) gradient_parent_class)->child_added) { (* ((SPObjectClass *) gradient_parent_class)->child_added)(object, child, ref); + } SPObject *ochild = sp_object_get_child_by_repr(object, child); if ( ochild && SP_IS_STOP(ochild) ) { gr->has_stops = TRUE; + if ( gr->getStopCount() > 0 ) { + gchar const * attr = gr->repr->attribute("osb:paint"); + if ( attr && !strcmp(attr, "solid") ) { + gr->repr->setAttribute("osb:paint", "gradient"); + } + } } /// \todo Fixme: should we schedule "modified" here? @@ -628,6 +639,13 @@ void SPGradientImpl::removeChild(SPObject *object, Inkscape::XML::Node *child) } } + if ( gr->getStopCount() == 0 ) { + gchar const * attr = gr->repr->attribute("osb:paint"); + if ( attr && !strcmp(attr, "gradient") ) { + gr->repr->setAttribute("osb:paint", "solid"); + } + } + /* Fixme: should we schedule "modified" here? */ object->requestModified(SP_OBJECT_MODIFIED_FLAG); } -- cgit v1.2.3