diff options
Diffstat (limited to 'src')
111 files changed, 1479 insertions, 765 deletions
diff --git a/src/attribute-rel-css.cpp b/src/attribute-rel-css.cpp index b45382b75..89678edb5 100644 --- a/src/attribute-rel-css.cpp +++ b/src/attribute-rel-css.cpp @@ -59,6 +59,7 @@ bool SPAttributeRelCSS::findIfValid(Glib::ustring property, Glib::ustring elemen || property.substr(0,9) == "sodipodi:" || property.substr(0,4) == "rdf:" || property.substr(0,3) == "cc:" + || property.substr(0,4) == "ns1:" // JessyInk || (SPAttributeRelCSS::instance->propertiesOfElements[temp].find(property) != SPAttributeRelCSS::instance->propertiesOfElements[temp].end()) ) { return true; diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp index 80d924f80..49c97ae64 100644 --- a/src/attribute-rel-svg.cpp +++ b/src/attribute-rel-svg.cpp @@ -55,6 +55,7 @@ bool SPAttributeRelSVG::findIfValid(Glib::ustring attribute, Glib::ustring eleme || attribute.substr(0,9) == "sodipodi:" || attribute.substr(0,4) == "rdf:" || attribute.substr(0,3) == "cc:" + || attribute.substr(0,4) == "ns1:" // JessyInk || (SPAttributeRelSVG::instance->attributesOfElements[temp].find(attribute) != SPAttributeRelSVG::instance->attributesOfElements[temp].end()) ) { return true; diff --git a/src/attributes.cpp b/src/attributes.cpp index b93bcfd57..40e11b023 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -440,6 +440,8 @@ static SPStyleProp const props[] = { {SP_PROP_DISPLAY, "display"}, {SP_PROP_OVERFLOW, "overflow"}, {SP_PROP_VISIBILITY, "visibility"}, + {SP_PROP_BLEND_MODE, "mix-blend-mode"}, // CSS Blending and Compositing + {SP_PROP_ISOLATION, "isolation"}, /* SVG */ /* Clip/Mask */ {SP_PROP_CLIP_PATH, "clip-path"}, diff --git a/src/attributes.h b/src/attributes.h index 24244c237..ecf7ce966 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -441,6 +441,8 @@ enum SPAttributeEnum { SP_PROP_DISPLAY, SP_PROP_OVERFLOW, SP_PROP_VISIBILITY, + SP_PROP_BLEND_MODE, + SP_PROP_ISOLATION, /* SVG */ /* Clip/Mask */ SP_PROP_CLIP_PATH, diff --git a/src/color-profile.cpp b/src/color-profile.cpp index b18112ece..2736b9a3b 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -922,7 +922,7 @@ Glib::ustring getNameFromProfile(cmsHPROFILE profile) } nameStr = Glib::ustring(data.begin(), data.end()); } - if (nameStr.empty()) { + if (nameStr.empty() || !g_utf8_validate(nameStr.c_str(), -1, NULL)) { nameStr = _("(invalid UTF-8 string)"); } #endif diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 4f8f7889f..244d5c8ab 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -483,6 +483,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) sp_canvas_item_ungrab(item, event->button.time); ret=TRUE; } + break; case GDK_ENTER_NOTIFY: { sp_guideline_set_color(SP_GUIDELINE(item), guide->hicolor); @@ -574,6 +575,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) // do nothing; break; } + break; default: break; } diff --git a/src/desktop.cpp b/src/desktop.cpp index e24d7eef0..195127ca1 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -695,7 +695,7 @@ Inkscape::UI::Widget::Dock* SPDesktop::getDock() { /** * \see SPDocument::getItemFromListAtPointBottom() */ -SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const +SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const { g_return_val_if_fail (doc() != NULL, NULL); return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); @@ -704,7 +704,7 @@ SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point /** * \see SPDocument::getItemAtPoint() */ -SPItem *SPDesktop::getItemAtPoint(Geom::Point const p, bool into_groups, SPItem *upto) const +SPItem *SPDesktop::getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto) const { g_return_val_if_fail (doc() != NULL, NULL); return doc()->getItemAtPoint( dkey, p, into_groups, upto); @@ -713,7 +713,7 @@ SPItem *SPDesktop::getItemAtPoint(Geom::Point const p, bool into_groups, SPItem /** * \see SPDocument::getGroupAtPoint() */ -SPItem *SPDesktop::getGroupAtPoint(Geom::Point const p) const +SPItem *SPDesktop::getGroupAtPoint(Geom::Point const &p) const { g_return_val_if_fail (doc() != NULL, NULL); return doc()->getGroupAtPoint(dkey, p); @@ -1298,7 +1298,7 @@ bool SPDesktop::showInfoDialog( Glib::ustring const & message ) } bool -SPDesktop::warnDialog (gchar *text) +SPDesktop::warnDialog (Glib::ustring const &text) { return _widget->warnDialog (text); } diff --git a/src/desktop.h b/src/desktop.h index faaa7e3a5..2f47dc2dd 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -311,9 +311,9 @@ public: //void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); - SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const; - SPItem *getItemAtPoint(Geom::Point const p, bool into_groups, SPItem *upto = NULL) const; - SPItem *getGroupAtPoint(Geom::Point const p) const; + SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const; + SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; + SPItem *getGroupAtPoint(Geom::Point const &p) const; Geom::Point point() const; Geom::Rect get_display_area() const; @@ -343,7 +343,7 @@ public: bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0); void scroll_world (double dx, double dy, bool is_scrolling = false); - void scroll_world (Geom::Point const scroll, bool is_scrolling = false) + void scroll_world (Geom::Point const &scroll, bool is_scrolling = false) { scroll_world(scroll[Geom::X], scroll[Geom::Y], is_scrolling); } @@ -356,7 +356,7 @@ public: Gtk::Window* getToplevel(); void presentWindow(); bool showInfoDialog( Glib::ustring const &message ); - bool warnDialog (gchar *text); + bool warnDialog (Glib::ustring const &text); void toggleRulers(); void toggleScrollbars(); void layoutWidget(); diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index d66b97bbc..858312f5b 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -727,19 +727,19 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasAxonomGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasAxonomGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); isr.grid_lines.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasAxonomGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasAxonomGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 4e5af863d..3888a3dc4 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -72,9 +72,9 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, const Geom::Point &point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasAxonomGrid *grid; }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 192cc4cba..3c4ad9b00 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1031,19 +1031,19 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasXYGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasXYGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); isr.grid_lines.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasXYGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasXYGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 078670da7..5a23dee52 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -167,9 +167,9 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, const Geom::Point &point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasXYGrid *grid; }; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index a8257e6e5..a9b07bb6e 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -23,6 +23,66 @@ namespace Inkscape { +#ifdef WITH_CSSBLEND +void set_cairo_blend_operator( DrawingContext &ct, unsigned blend_mode ) { + + // All of the blend modes are implemented in Cairo as of 1.10. + // For a detailed description, see: + // http://cairographics.org/operators/ + switch (blend_mode) { + case SP_CSS_BLEND_MULTIPLY: + ct.setOperator(CAIRO_OPERATOR_MULTIPLY); + break; + case SP_CSS_BLEND_SCREEN: + ct.setOperator(CAIRO_OPERATOR_SCREEN); + break; + case SP_CSS_BLEND_DARKEN: + ct.setOperator(CAIRO_OPERATOR_DARKEN); + break; + case SP_CSS_BLEND_LIGHTEN: + ct.setOperator(CAIRO_OPERATOR_LIGHTEN); + break; + case SP_CSS_BLEND_OVERLAY: + ct.setOperator(CAIRO_OPERATOR_OVERLAY); + break; + case SP_CSS_BLEND_COLORDODGE: + ct.setOperator(CAIRO_OPERATOR_COLOR_DODGE); + break; + case SP_CSS_BLEND_COLORBURN: + ct.setOperator(CAIRO_OPERATOR_COLOR_BURN); + break; + case SP_CSS_BLEND_HARDLIGHT: + ct.setOperator(CAIRO_OPERATOR_HARD_LIGHT); + break; + case SP_CSS_BLEND_SOFTLIGHT: + ct.setOperator(CAIRO_OPERATOR_SOFT_LIGHT); + break; + case SP_CSS_BLEND_DIFFERENCE: + ct.setOperator(CAIRO_OPERATOR_DIFFERENCE); + break; + case SP_CSS_BLEND_EXCLUSION: + ct.setOperator(CAIRO_OPERATOR_EXCLUSION); + break; + case SP_CSS_BLEND_HUE: + ct.setOperator(CAIRO_OPERATOR_HSL_HUE); + break; + case SP_CSS_BLEND_SATURATION: + ct.setOperator(CAIRO_OPERATOR_HSL_SATURATION); + break; + case SP_CSS_BLEND_COLOR: + ct.setOperator(CAIRO_OPERATOR_HSL_COLOR); + break; + case SP_CSS_BLEND_LUMINOSITY: + ct.setOperator(CAIRO_OPERATOR_HSL_LUMINOSITY); + break; + case SP_CSS_BLEND_NORMAL: + default: + ct.setOperator(CAIRO_OPERATOR_OVER); + break; + } +} +#endif + /** * @class DrawingItem * SVG drawing item for display. @@ -67,6 +127,8 @@ DrawingItem::DrawingItem(Drawing &drawing) , _propagate(0) // , _renders_opacity(0) , _pick_children(0) + , _isolation(SP_CSS_ISOLATION_AUTO) + , _blend_mode(SP_CSS_BLEND_NORMAL) {} DrawingItem::~DrawingItem() @@ -209,6 +271,22 @@ DrawingItem::setOpacity(float opacity) } void +DrawingItem::setIsolation(unsigned isolation) +{ + _isolation = isolation; + //if( isolation != 0 ) std::cout << "isolation: " << isolation << std::endl; + _markForRendering(); +} + +void +DrawingItem::setBlendMode(unsigned blend_mode) +{ + _blend_mode = blend_mode; + //if( blend_mode != 0 ) std::cout << "setBlendMode: " << blend_mode << std::endl; + _markForRendering(); +} + +void DrawingItem::setVisible(bool v) { _visible = v; @@ -494,6 +572,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (_cached) { if (_cache) { _cache->prepare(); +#ifdef WITH_CSSBLEND + set_cairo_blend_operator( ct, _blend_mode ); +#endif _cache->paintFromCache(ct, carea); if (!carea) return RENDER_OK; } else { @@ -522,6 +603,10 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag nir |= (_filter != NULL && render_filters); // 3. it has a filter nir |= needs_opacity; // 4. it is non-opaque nir |= (_cache != NULL); // 5. it is cached +#ifdef WITH_CSSBLEND + nir |= (_blend_mode != SP_CSS_BLEND_NORMAL); // 6. Blend mode not normal + nir |= (_isolation == SP_CSS_ISOLATION_ISOLATE); // 7. Explicit isolatiom +#endif /* How the rendering is done. * @@ -633,6 +718,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } ct.rectangle(*carea); ct.setSource(&intermediate); +#ifdef WITH_CSSBLEND + set_cairo_blend_operator( ct, _blend_mode ); +#endif ct.fill(); ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index e03bbd0f7..1796d29d6 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -108,6 +108,8 @@ public: void setCached(bool c, bool persistent = false); void setOpacity(float opacity); + void setIsolation(unsigned isolation); // CSS Compositing and Blending + void setBlendMode(unsigned blend_mode); void setTransform(Geom::Affine const &trans); void setClip(DrawingItem *item); void setMask(DrawingItem *item); @@ -204,6 +206,9 @@ protected: unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), /// otherwise the group is returned + unsigned _isolation : 1; + unsigned _blend_mode : 4; + friend class Drawing; }; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index f37f4d3c4..f652a2970 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -67,13 +67,11 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext _pick_bbox = Geom::IntRect(); _bbox = Geom::IntRect(); - Geom::OptRect b; - /* orignally it did the one line below, but it did not handle ws characters at all, and it had problems with scaling for overline/underline. Replaced with the section below, which seems to be much more stable. - b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); + Geom::OptRect b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); */ /* Make a bounding box that is a little taller and lower (currently 10% extra) than the font's drawing box. Extra space is to hold overline or underline, if present. All characters in a font use the same ascent and descent, @@ -81,37 +79,37 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext the bounding box is limited to the box surrounding the drawn parts of visible glyphs only, and draws outside are ignored. */ - float scale = 1.0; - if(_transform){ scale /= _transform->descrim(); } - - Geom::Rect bigbox(Geom::Point(0.0, _asc*scale*1.1),Geom::Point(_width*scale, -_dsc*scale*1.1)); - b = bigbox * ctx.ctm; + float scale_bigbox = 1.0; + if (_transform) { + scale_bigbox /= _transform->descrim(); + } - if (b && (ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE)) { - float width, scale; + Geom::Rect bigbox(Geom::Point(0.0, _asc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, -_dsc*scale_bigbox*1.1)); + Geom::Rect b = bigbox * ctx.ctm; + if (ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { // this expands the selection box for cases where the stroke is "thick" - scale = ctx.ctm.descrim(); + float scale = ctx.ctm.descrim(); if (_transform) { scale /= _transform->descrim(); // FIXME temporary hack } - width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); + float width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true - b->expandBy(0.5 * width); + b.expandBy(0.5 * width); } // save bbox without miters for picking - _pick_bbox = b->roundOutwards(); + _pick_bbox = b.roundOutwards(); float miterMax = width * ggroup->_nrstyle.miter_limit; if ( miterMax > 0.01 ) { // grunt mode. we should compute the various miters instead // (one for each point on the curve) - b->expandBy(miterMax); + b.expandBy(miterMax); } - _bbox = b->roundOutwards(); - } else if (b) { - _bbox = b->roundOutwards(); + _bbox = b.roundOutwards(); + } else { + _bbox = b.roundOutwards(); _pick_bbox = *_bbox; } /* diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index bff7405b7..099816bce 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -83,6 +83,43 @@ void FilterBlend::render_cairo(FilterSlot &slot) case BLEND_LIGHTEN: cairo_set_operator(out_ct, CAIRO_OPERATOR_LIGHTEN); break; +#ifdef WITH_CSSBLEND + // NEW + case BLEND_OVERLAY: + cairo_set_operator(out_ct, CAIRO_OPERATOR_OVERLAY); + break; + case BLEND_COLORDODGE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_DODGE); + break; + case BLEND_COLORBURN: + cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_BURN); + break; + case BLEND_HARDLIGHT: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HARD_LIGHT); + break; + case BLEND_SOFTLIGHT: + cairo_set_operator(out_ct, CAIRO_OPERATOR_SOFT_LIGHT); + break; + case BLEND_DIFFERENCE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_DIFFERENCE); + break; + case BLEND_EXCLUSION: + cairo_set_operator(out_ct, CAIRO_OPERATOR_EXCLUSION); + break; + case BLEND_HUE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_HUE); + break; + case BLEND_SATURATION: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_SATURATION); + break; + case BLEND_COLOR: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_COLOR); + break; + case BLEND_LUMINOSITY: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_LUMINOSITY); + break; +#endif + case BLEND_NORMAL: default: cairo_set_operator(out_ct, CAIRO_OPERATOR_OVER); @@ -128,9 +165,18 @@ void FilterBlend::set_input(int input, int slot) { } void FilterBlend::set_mode(FilterBlendMode mode) { - if (mode == BLEND_NORMAL || mode == BLEND_MULTIPLY || - mode == BLEND_SCREEN || mode == BLEND_DARKEN || - mode == BLEND_LIGHTEN) + if (mode == BLEND_NORMAL || mode == BLEND_MULTIPLY || + mode == BLEND_SCREEN || mode == BLEND_DARKEN || + mode == BLEND_LIGHTEN +#ifdef WITH_CSSBLEND + || mode == BLEND_OVERLAY || + mode == BLEND_COLORDODGE || mode == BLEND_COLORBURN || + mode == BLEND_HARDLIGHT || mode == BLEND_SOFTLIGHT || + mode == BLEND_DIFFERENCE || mode == BLEND_EXCLUSION || + mode == BLEND_HUE || mode == BLEND_SATURATION || + mode == BLEND_COLOR || mode == BLEND_LUMINOSITY +#endif + ) { _blend_mode = mode; } diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 957d3cfc8..0a2927d87 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -28,7 +28,21 @@ enum FilterBlendMode { BLEND_SCREEN, BLEND_DARKEN, BLEND_LIGHTEN, - BLEND_ENDMODE +#ifdef WITH_CSSBLEND + // New in CSS Compositing and Blending Level 1 + BLEND_OVERLAY, + BLEND_COLORDODGE, + BLEND_COLORBURN, + BLEND_HARDLIGHT, + BLEND_SOFTLIGHT, + BLEND_DIFFERENCE, + BLEND_EXCLUSION, + BLEND_HUE, + BLEND_SATURATION, + BLEND_COLOR, + BLEND_LUMINOSITY, +#endif + BLEND_ENDMODE, }; class FilterBlend : public FilterPrimitive { diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index f6decad0d..dc5e4278f 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -98,6 +98,33 @@ void FilterComposite::render_cairo(FilterSlot &slot) case COMPOSITE_XOR: cairo_set_operator(ct, CAIRO_OPERATOR_XOR); break; +#ifdef WITH_CSSCOMPOSITE + /* New CSS Operators */ + case COMPOSITE_CLEAR: + cairo_set_operator(ct, CAIRO_OPERATOR_CLEAR); + break; + case COMPOSITE_COPY: + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + break; + case COMPOSITE_DESTINATION: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST); + break; + case COMPOSITE_DESTINATION_OVER: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_OVER); + break; + case COMPOSITE_DESTINATION_IN: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_IN); + break; + case COMPOSITE_DESTINATION_OUT: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_OUT); + break; + case COMPOSITE_DESTINATION_ATOP: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_ATOP); + break; + case COMPOSITE_LIGHTER: + cairo_set_operator(ct, CAIRO_OPERATOR_ADD); + break; +#endif case COMPOSITE_OVER: case COMPOSITE_DEFAULT: default: @@ -129,13 +156,7 @@ void FilterComposite::set_input(int input, int slot) { void FilterComposite::set_operator(FeCompositeOperator op) { if (op == COMPOSITE_DEFAULT) { this->op = COMPOSITE_OVER; - } else if (op == COMPOSITE_OVER || - op == COMPOSITE_IN || - op == COMPOSITE_OUT || - op == COMPOSITE_ATOP || - op == COMPOSITE_XOR || - op == COMPOSITE_ARITHMETIC) - { + } else if (op != COMPOSITE_ENDOPERATOR) { this->op = op; } } diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 1dd3022c7..627bfb2ab 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -262,36 +262,38 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap // Display the tooltip, which reveals the type of snap source and the type of snap target gchar *tooltip_str = NULL; - if (p.getSource() != SNAPSOURCE_GRID_PITCH) { + if ( (p.getSource() != SNAPSOURCE_GRID_PITCH) && (p.getTarget() != SNAPTARGET_UNDEFINED) ) { tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); - } else { + } else if (p.getSource() != SNAPSOURCE_UNDEFINED) { tooltip_str = g_strdup(source_name); } double fontsize = prefs->getInt("/tools/measure/fontsize"); - Geom::Point tooltip_pos = p.getPoint(); - if (tools_isactive(_desktop, TOOLS_MEASURE)) { - // Make sure that the snap tooltips do not overlap the ones from the measure tool - tooltip_pos += _desktop->w2d(Geom::Point(0, -3*fontsize)); - } else { - tooltip_pos += _desktop->w2d(Geom::Point(0, -2*fontsize)); + if (tooltip_str) { + Geom::Point tooltip_pos = p.getPoint(); + if (tools_isactive(_desktop, TOOLS_MEASURE)) { + // Make sure that the snap tooltips do not overlap the ones from the measure tool + tooltip_pos += _desktop->w2d(Geom::Point(0, -3*fontsize)); + } else { + tooltip_pos += _desktop->w2d(Geom::Point(0, -2*fontsize)); + } + + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; + if (pre_snap) { + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f40; + } else { + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; + } + SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; + g_free(tooltip_str); + + _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); } - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); - sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); - SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; - SP_CANVASTEXT(canvas_tooltip)->outline = false; - SP_CANVASTEXT(canvas_tooltip)->background = true; - if (pre_snap) { - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f40; - } else { - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; - } - SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; - g_free(tooltip_str); - - _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); - // Display the bounding box, if we snapped to one Geom::OptRect const bbox = p.getTargetBBox(); if (bbox) { diff --git a/src/document.cpp b/src/document.cpp index e6166ee82..e56adee68 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1173,7 +1173,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group) return inGroup; } -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const p, bool take_insensitive) +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive) { g_return_val_if_fail(group, NULL); SPItem *bottomMost = 0; @@ -1209,7 +1209,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ -static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const &p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL; SPItem *newseen = NULL; @@ -1254,7 +1254,7 @@ static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ -static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) +static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const &p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1334,7 +1334,7 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point return items; } -SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const p, +SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const &p, gboolean const into_groups, SPItem *upto) const { g_return_val_if_fail(this->priv != NULL, NULL); @@ -1342,7 +1342,7 @@ SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const p, return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto); } -SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const p) const +SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const &p) const { g_return_val_if_fail(this->priv != NULL, NULL); diff --git a/src/document.h b/src/document.h index 0977fc7a8..cc565e3aa 100644 --- a/src/document.h +++ b/src/document.h @@ -222,7 +222,7 @@ public: /** * Returns the bottommost item from the list which is at the point, or NULL if none. */ - static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); + static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); // ToDo - Merge createDoc with createNewDoc static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); @@ -244,9 +244,9 @@ public: const GSList *getResourceList(const gchar *key) const; GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; - SPItem *getItemAtPoint(unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL) const; + SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, gboolean into_groups, SPItem *upto = NULL) const; GSList *getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; - SPItem *getGroupAtPoint(unsigned int key, Geom::Point const p) const; + SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(gchar const *uri); void emitResizedSignal(gdouble width, gdouble height); diff --git a/src/dom/ucd.cpp b/src/dom/ucd.cpp index f9c36ad19..f74af3956 100644 --- a/src/dom/ucd.cpp +++ b/src/dom/ucd.cpp @@ -2308,6 +2308,8 @@ typedef struct int map[3]; } CaseMapEntry; +/* + static CaseMapEntry caseMap[] = { { 0x1fc2, 2, { 0xffff, 0x0159 } }, @@ -2426,7 +2428,7 @@ static CaseMapEntry caseMap[] = }; - +*/ diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 7f844ec4b..9491468dc 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -48,6 +48,7 @@ #include "icon-size.h" #include "ege-adjustment-action.h" #include "ui/widget/gimpspinscale.h" +#include "ui/icon-names.h" static void ege_adjustment_action_finalize( GObject* object ); @@ -81,11 +82,11 @@ enum { /* TODO need to have appropriate icons setup for these: */ static const gchar *floogles[] = { - GTK_STOCK_REMOVE, - GTK_STOCK_ADD, - GTK_STOCK_GO_DOWN, - GTK_STOCK_ABOUT, - GTK_STOCK_GO_UP, + INKSCAPE_ICON("list-remove"), + INKSCAPE_ICON("list-add"), + INKSCAPE_ICON("go-down"), + INKSCAPE_ICON("help-about"), + INKSCAPE_ICON("go-up"), 0}; typedef struct _EgeAdjustmentDescr EgeAdjustmentDescr; @@ -982,7 +983,7 @@ static gboolean process_tab( GtkWidget* widget, int direction ) if ( mid && GTK_IS_TOOL_ITEM(mid->data) ) { /* potential target */ GtkWidget* child = gtk_bin_get_child( GTK_BIN(mid->data) ); - if ( child && GTK_IS_HBOX(child) ) { /* could be ours */ + if ( child && GTK_IS_BOX(child) ) { /* could be ours */ GList* subChildren = gtk_container_get_children( GTK_CONTAINER(child) ); if ( subChildren ) { GList* last = g_list_last(subChildren); @@ -1100,3 +1101,13 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) return wasConsumed; } +/* + 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:fileencoding=utf-8:textwidth=99 : diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 214bd4b29..9a7d7e318 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -221,7 +221,7 @@ void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ) /* Search for the things we built up in create_tool_item() */ GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) ); if ( children && children->data ) { - if ( GTK_IS_HBOX(children->data) ) { + if ( GTK_IS_BOX(children->data) ) { children = gtk_container_get_children( GTK_CONTAINER(children->data) ); if ( children && g_list_next(children) ) { GtkWidget* child = GTK_WIDGET( g_list_next(children)->data ); diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 184d1afb4..3facf7242 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -866,7 +866,7 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override ) } else if ( gtk_combo_box_get_active(combo) != active ) { gtk_combo_box_set_active( combo, active ); } - } else if ( GTK_IS_HBOX(children->data) ) { + } else if ( GTK_IS_BOX(children->data) ) { gpointer data = g_object_get_data( G_OBJECT(children->data), "ege-proxy_action-group" ); if ( data ) { GSList* group = (GSList*)data; @@ -921,7 +921,7 @@ void resync_sensitive( EgeSelectOneAction* act ) } if ( GTK_IS_COMBO_BOX(combodata) ) { /* Not implemented */ - } else if ( GTK_IS_HBOX(children->data) ) { + } else if ( GTK_IS_BOX(children->data) ) { gpointer data = g_object_get_data( G_OBJECT(children->data), "ege-proxy_action-group" ); if ( data ) { GSList* group = (GSList*)data; diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index 865e86698..aee46aaba 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -340,7 +340,13 @@ void ImageResolution::readmagick(char const *fn) { Magick::Image image; try { image.read(fn); - } catch (...) {} + } catch (Magick::Error & err) { + g_warning("ImageMagick error: %s", err.what()); + return; + } catch (...) { + g_warning("ImageResolution::readmagick: Unknown error"); + return; + } Magick::Geometry geo = image.density(); std::string type = image.magick(); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 3f37e4402..870e4061c 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -321,7 +321,7 @@ Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena /* WMF has no worldTransform, so this always returns 1.0. Retain it to keep WMF and WMF in sync as much as possible.*/ -double Wmf::current_scale(PWMF_CALLBACK_DATA d){ +double Wmf::current_scale(PWMF_CALLBACK_DATA /*d*/){ return 1.0; } @@ -341,7 +341,7 @@ std::string Wmf::current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int us } /* WMF has no worldTransform, so this always returns 0. Retain it to keep WMF and WMF in sync as much as possible.*/ -double Wmf::current_rotation(PWMF_CALLBACK_DATA d){ +double Wmf::current_rotation(PWMF_CALLBACK_DATA /*d*/){ return 0.0; } @@ -1025,7 +1025,7 @@ Wmf::_pix_y_to_point(PWMF_CALLBACK_DATA d, double py) double -Wmf::pix_to_x_point(PWMF_CALLBACK_DATA d, double px, double py) +Wmf::pix_to_x_point(PWMF_CALLBACK_DATA d, double px, double /*py*/) { double x = _pix_x_to_point(d, px); @@ -1033,7 +1033,7 @@ Wmf::pix_to_x_point(PWMF_CALLBACK_DATA d, double px, double py) } double -Wmf::pix_to_y_point(PWMF_CALLBACK_DATA d, double px, double py) +Wmf::pix_to_y_point(PWMF_CALLBACK_DATA d, double /*px*/, double py) { double y = _pix_y_to_point(d, py); diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index c9cea73d4..95ed04afc 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -66,7 +66,10 @@ ParamDescription::ParamDescription (const gchar * name, Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { - if (_gui_hidden) { + if (_gui_hidden) { + return NULL; + } + if (_value == NULL) { return NULL; } diff --git a/src/file.cpp b/src/file.cpp index cec634c9b..35039fed3 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -360,11 +360,8 @@ void sp_file_revert_dialog() bool do_revert = true; if (doc->isModifiedSinceSave()) { - gchar *text = g_strdup_printf(_("Changes will be lost! Are you sure you want to reload document %s?"), uri); - - bool response = desktop->warnDialog (text); - g_free(text); - + Glib::ustring tmpString = Glib::ustring::compose(_("Changes will be lost! Are you sure you want to reload document %1?"), uri); + bool response = desktop->warnDialog (tmpString); if (!response) { do_revert = false; } @@ -843,38 +840,30 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens if (extension) filename_extension = extension->get_extension(); - Glib::ustring save_path; - Glib::ustring save_loc; - - save_path = Inkscape::Extension::get_file_save_path(doc, save_method); + Glib::ustring save_path = Inkscape::Extension::get_file_save_path(doc, save_method); if (!Inkscape::IO::file_test(save_path.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - save_path = ""; + save_path.clear(); - if (save_path.size()<1) + if (save_path.empty()) save_path = g_get_home_dir(); - save_loc = save_path; + Glib::ustring save_loc = save_path; save_loc.append(G_DIR_SEPARATOR_S); - // TODO fixed buffer is bad: - char formatBuf[256]; int i = 1; if ( !doc->getURI() ) { // We are saving for the first time; create a unique default filename - snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str()); - save_loc.append(formatBuf); + save_loc = save_loc + Glib::ustring(_("drawing")) + filename_extension; while (Inkscape::IO::file_test(save_loc.c_str(), G_FILE_TEST_EXISTS)) { save_loc = save_path; save_loc.append(G_DIR_SEPARATOR_S); - snprintf(formatBuf, 255, _("drawing-%d%s"), i++, filename_extension.c_str()); - save_loc.append(formatBuf); + save_loc = save_loc + Glib::ustring::compose(_("drawing-%1"), i++) + filename_extension; } } else { - snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->getURI()).c_str()); - save_loc.append(formatBuf); + save_loc.append(Glib::path_get_basename(doc->getURI())); } // convert save_loc from utf-8 to locale @@ -882,7 +871,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens // Inkscape::IO? Glib::ustring save_loc_local = Glib::filename_from_utf8(save_loc); - if ( save_loc_local.size() > 0) + if (!save_loc_local.empty()) save_loc = save_loc_local; //# Show the SaveAs dialog @@ -909,28 +898,27 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens bool success = saveDialog->show(); if (!success) { delete saveDialog; + if(doc_title) g_free(doc_title); return success; } // set new title here (call RDF to ensure metadata and title element are updated) rdf_set_work_entity(doc, rdf_find_entity("title"), saveDialog->getDocTitle().c_str()); - // free up old string - if(doc_title) g_free(doc_title); Glib::ustring fileName = saveDialog->getFilename(); Inkscape::Extension::Extension *selectionType = saveDialog->getSelectionType(); delete saveDialog; - saveDialog = 0; + if(doc_title) g_free(doc_title); - if (fileName.size() > 0) { + if (!fileName.empty()) { Glib::ustring newFileName = Glib::filename_to_utf8(fileName); - if ( newFileName.size()>0 ) + if (!newFileName.empty()) fileName = newFileName; else - g_warning( "Error converting save filename to UTF-8." ); + g_warning( "Error converting filename for saving to UTF-8." ); Inkscape::Extension::Output *omod = dynamic_cast<Inkscape::Extension::Output *>(selectionType); if (omod) { diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp index 315b242bf..7ee57f7fa 100644 --- a/src/filter-enums.cpp +++ b/src/filter-enums.cpp @@ -48,11 +48,25 @@ const EnumDataConverter<FilterPrimitiveInput> FPInputConverter(FPInputData, FPIN // feBlend const EnumData<Inkscape::Filters::FilterBlendMode> BlendModeData[Inkscape::Filters::BLEND_ENDMODE] = { - {Inkscape::Filters::BLEND_NORMAL, _("Normal"), "normal"}, - {Inkscape::Filters::BLEND_MULTIPLY, _("Multiply"), "multiply"}, - {Inkscape::Filters::BLEND_SCREEN, _("Screen"), "screen"}, - {Inkscape::Filters::BLEND_DARKEN, _("Darken"), "darken"}, - {Inkscape::Filters::BLEND_LIGHTEN, _("Lighten"), "lighten"} + {Inkscape::Filters::BLEND_NORMAL, _("Normal"), "normal"}, + {Inkscape::Filters::BLEND_MULTIPLY, _("Multiply"), "multiply"}, + {Inkscape::Filters::BLEND_SCREEN, _("Screen"), "screen"}, + {Inkscape::Filters::BLEND_DARKEN, _("Darken"), "darken"}, + {Inkscape::Filters::BLEND_LIGHTEN, _("Lighten"), "lighten"}, +#ifdef WITH_CSSBLEND +// New in Compositing and Blending Level 1 + {Inkscape::Filters::BLEND_OVERLAY, _("Overlay"), "overlay"}, + {Inkscape::Filters::BLEND_COLORDODGE, _("Color Dodge"), "color-dodge"}, + {Inkscape::Filters::BLEND_COLORBURN, _("Color Burn"), "color-burn"}, + {Inkscape::Filters::BLEND_HARDLIGHT, _("Hard Light"), "hard-light"}, + {Inkscape::Filters::BLEND_SOFTLIGHT, _("Soft Light"), "soft-light"}, + {Inkscape::Filters::BLEND_DIFFERENCE, _("Difference"), "difference"}, + {Inkscape::Filters::BLEND_EXCLUSION, _("Exclusion"), "exclusion"}, + {Inkscape::Filters::BLEND_HUE, _("Hue"), "hue"}, + {Inkscape::Filters::BLEND_SATURATION, _("Saturation"), "saturation"}, + {Inkscape::Filters::BLEND_COLOR, _("Color"), "color"}, + {Inkscape::Filters::BLEND_LUMINOSITY, _("Luminosity"), "luminosity"} +#endif }; const EnumDataConverter<Inkscape::Filters::FilterBlendMode> BlendModeConverter(BlendModeData, Inkscape::Filters::BLEND_ENDMODE); @@ -67,13 +81,24 @@ const EnumDataConverter<Inkscape::Filters::FilterColorMatrixType> ColorMatrixTyp // feComposite const EnumData<FeCompositeOperator> CompositeOperatorData[COMPOSITE_ENDOPERATOR] = { - {COMPOSITE_DEFAULT, _("Default"), ""}, - {COMPOSITE_OVER, _("Over"), "over"}, - {COMPOSITE_IN, _("In"), "in"}, - {COMPOSITE_OUT, _("Out"), "out"}, - {COMPOSITE_ATOP, _("Atop"), "atop"}, - {COMPOSITE_XOR, _("XOR"), "xor"}, - {COMPOSITE_ARITHMETIC, _("Arithmetic"), "arithmetic"} + {COMPOSITE_DEFAULT, _("Default"), "" }, + {COMPOSITE_OVER, _("Over"), "over" }, + {COMPOSITE_IN, _("In"), "in" }, + {COMPOSITE_OUT, _("Out"), "out" }, + {COMPOSITE_ATOP, _("Atop"), "atop" }, + {COMPOSITE_XOR, _("XOR"), "xor" }, +#ifdef WITH_CSSCOMPOSITE +// New CSS + {COMPOSITE_CLEAR, _("Clear"), "clear" }, + {COMPOSITE_COPY, _("Copy"), "copy" }, + {COMPOSITE_DESTINATION, _("Destination"), "destination" }, + {COMPOSITE_DESTINATION_OVER, _("Destination Over"),"destination-over" }, + {COMPOSITE_DESTINATION_IN, _("Destination In"), "destination-in" }, + {COMPOSITE_DESTINATION_OUT, _("Destination Out"), "destination-out" }, + {COMPOSITE_DESTINATION_ATOP, _("Destination Atop"),"destination-atop" }, + {COMPOSITE_LIGHTER, _("Lighter"), "lighter" }, +#endif + {COMPOSITE_ARITHMETIC, _("Arithmetic"), "arithmetic" } }; const EnumDataConverter<FeCompositeOperator> CompositeOperatorConverter(CompositeOperatorData, COMPOSITE_ENDOPERATOR); diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 219a099d1..5c78f4f9f 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -96,16 +96,50 @@ static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value case 's': if (strncmp(value, "screen", 6) == 0) return Inkscape::Filters::BLEND_SCREEN; +#ifdef WITH_CSSBLEND + if (strncmp(value, "saturation", 6) == 0) + return Inkscape::Filters::BLEND_SATURATION; +#endif break; case 'd': if (strncmp(value, "darken", 6) == 0) return Inkscape::Filters::BLEND_DARKEN; +#ifdef WITH_CSSBLEND + if (strncmp(value, "difference", 10) == 0) + return Inkscape::Filters::BLEND_DIFFERENCE; +#endif break; case 'l': if (strncmp(value, "lighten", 7) == 0) return Inkscape::Filters::BLEND_LIGHTEN; +#ifdef WITH_CSSBLEND + if (strncmp(value, "luminosity", 10) == 0) + return Inkscape::Filters::BLEND_LUMINOSITY; + break; + case 'o': + if (strncmp(value, "overlay", 7) == 0) + return Inkscape::Filters::BLEND_OVERLAY; + break; + case 'c': + if (strncmp(value, "color-dodge", 11) == 0) + return Inkscape::Filters::BLEND_COLORDODGE; + if (strncmp(value, "color-burn", 10) == 0) + return Inkscape::Filters::BLEND_COLORBURN; + if (strncmp(value, "color", 5) == 0) + return Inkscape::Filters::BLEND_COLOR; break; + case 'h': + if (strncmp(value, "hard-light", 7) == 0) + return Inkscape::Filters::BLEND_HARDLIGHT; + if (strncmp(value, "hue", 3) == 0) + return Inkscape::Filters::BLEND_HUE; + break; + case 'e': + if (strncmp(value, "exclusion", 10) == 0) + return Inkscape::Filters::BLEND_EXCLUSION; +#endif default: + std::cout << "Inkscape::Filters::FilterBlendMode: Unimplemented mode: " << value << std::endl; // do nothing by default break; } @@ -201,15 +235,40 @@ Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XM char const *mode; switch(this->blend_mode) { case Inkscape::Filters::BLEND_NORMAL: - mode = "normal"; break; + mode = "normal"; break; case Inkscape::Filters::BLEND_MULTIPLY: - mode = "multiply"; break; + mode = "multiply"; break; case Inkscape::Filters::BLEND_SCREEN: - mode = "screen"; break; + mode = "screen"; break; case Inkscape::Filters::BLEND_DARKEN: - mode = "darken"; break; + mode = "darken"; break; case Inkscape::Filters::BLEND_LIGHTEN: - mode = "lighten"; break; + mode = "lighten"; break; +#ifdef WITH_CSSBLEND + // New + case Inkscape::Filters::BLEND_OVERLAY: + mode = "overlay"; break; + case Inkscape::Filters::BLEND_COLORDODGE: + mode = "color-dodge"; break; + case Inkscape::Filters::BLEND_COLORBURN: + mode = "color-burn"; break; + case Inkscape::Filters::BLEND_HARDLIGHT: + mode = "hard-light"; break; + case Inkscape::Filters::BLEND_SOFTLIGHT: + mode = "soft-light"; break; + case Inkscape::Filters::BLEND_DIFFERENCE: + mode = "difference"; break; + case Inkscape::Filters::BLEND_EXCLUSION: + mode = "exclusion"; break; + case Inkscape::Filters::BLEND_HUE: + mode = "hue"; break; + case Inkscape::Filters::BLEND_SATURATION: + mode = "saturation"; break; + case Inkscape::Filters::BLEND_COLOR: + mode = "color"; break; + case Inkscape::Filters::BLEND_LUMINOSITY: + mode = "luminosity"; break; +#endif default: mode = 0; } diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 3c214a7a1..257292f12 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -100,6 +100,26 @@ sp_feComposite_read_operator(gchar const *value) { } else if (strcmp(value, "arithmetic") == 0) { return COMPOSITE_ARITHMETIC; } +#ifdef WITH_CSSCOMPOSITE + else if (strcmp(value, "clear") == 0) { + return COMPOSITE_CLEAR; + } else if (strcmp(value, "copy") == 0) { + return COMPOSITE_COPY; + } else if (strcmp(value, "destination") == 0) { + return COMPOSITE_DESTINATION; + } else if (strcmp(value, "destination-over") == 0) { + return COMPOSITE_DESTINATION_OVER; + } else if (strcmp(value, "destination-in") == 0) { + return COMPOSITE_DESTINATION_IN; + } else if (strcmp(value, "destination-out") == 0) { + return COMPOSITE_DESTINATION_OUT; + } else if (strcmp(value, "destination-atop") == 0) { + return COMPOSITE_DESTINATION_ATOP; + } else if (strcmp(value, "lighter") == 0) { + return COMPOSITE_LIGHTER; + } +#endif + std::cout << "Inkscape::Filters::FilterCompositeOperator: Unimplemented operator: " << value << std::endl; return COMPOSITE_DEFAULT; } @@ -243,6 +263,25 @@ Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape comp_op = "xor"; break; case COMPOSITE_ARITHMETIC: comp_op = "arithmetic"; break; +#ifdef WITH_CSSCOMPOSITE + // New CSS operators + case COMPOSITE_CLEAR: + comp_op = "clear"; break; + case COMPOSITE_COPY: + comp_op = "copy"; break; + case COMPOSITE_DESTINATION: + comp_op = "destination"; break; + case COMPOSITE_DESTINATION_OVER: + comp_op = "destination-over"; break; + case COMPOSITE_DESTINATION_IN: + comp_op = "destination-in"; break; + case COMPOSITE_DESTINATION_OUT: + comp_op = "destination-out"; break; + case COMPOSITE_DESTINATION_ATOP: + comp_op = "destination-atop"; break; + case COMPOSITE_LIGHTER: + comp_op = "lighter"; break; +#endif default: comp_op = 0; } diff --git a/src/filters/composite.h b/src/filters/composite.h index b8c0178d1..42ec9d6b7 100644 --- a/src/filters/composite.h +++ b/src/filters/composite.h @@ -20,13 +20,24 @@ enum FeCompositeOperator { // Default value is 'over', but let's distinquish specifying the // default and implicitely using the default COMPOSITE_DEFAULT, - COMPOSITE_OVER, - COMPOSITE_IN, - COMPOSITE_OUT, - COMPOSITE_ATOP, + COMPOSITE_OVER, /* Source Over */ + COMPOSITE_IN, /* Source In */ + COMPOSITE_OUT, /* Source Out */ + COMPOSITE_ATOP, /* Source Atop */ COMPOSITE_XOR, - COMPOSITE_ARITHMETIC, - COMPOSITE_ENDOPERATOR + COMPOSITE_ARITHMETIC, /* Not a fundamental PorterDuff operator, nor Cairo */ +#ifdef WITH_CSSCOMPOSITE + // New in CSS + COMPOSITE_CLEAR, + COMPOSITE_COPY, /* Source */ + COMPOSITE_DESTINATION, + COMPOSITE_DESTINATION_OVER, + COMPOSITE_DESTINATION_IN, + COMPOSITE_DESTINATION_OUT, + COMPOSITE_DESTINATION_ATOP, + COMPOSITE_LIGHTER, /* Plus, Add (Not a fundamental PorterDuff operator */ +#endif + COMPOSITE_ENDOPERATOR /* Cairo Saturate is not included in CSS */ }; class SPFeComposite : public SPFilterPrimitive { diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index b0e00211a..7e10ccca1 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -106,7 +106,7 @@ void graphlayout(GSList const *const items) { return; } - using Inkscape::Util::GSListConstIterator; + using Inkscape::Util::GSListIterator; list<SPItem *> selected; filterConnectors(items,selected); if (selected.empty()) return; @@ -167,7 +167,7 @@ void graphlayout(GSList const *const items) { GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); list<SPItem *> connectors; - connectors.insert<GSListConstIterator<SPItem *> >(connectors.end(),nlist,NULL); + connectors.insert<GSListIterator<SPItem *> >(connectors.end(),nlist,NULL); for (list<SPItem *>::iterator j(connectors.begin()); j != connectors.end(); ++j) { diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 11636b0fc..20c95459d 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -67,25 +67,25 @@ bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const return (_snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE) && _snapmanager->getNamedView()->showguides); } -void Inkscape::GuideSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void Inkscape::GuideSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GUIDE, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); isr.guide_lines.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void Inkscape::GuideSnapper::_addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const &origin, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(origin, source, source_num, Inkscape::SNAPTARGET_GUIDE_ORIGIN, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void Inkscape::GuideSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void Inkscape::GuideSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); diff --git a/src/guide-snapper.h b/src/guide-snapper.h index 7aea2988b..938056410 100644 --- a/src/guide-snapper.h +++ b/src/guide-snapper.h @@ -32,10 +32,10 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const; - void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const; + void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const &origin, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; }; } diff --git a/src/helper-fns.h b/src/helper-fns.h index 95de4a1b0..699fbbe11 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -107,6 +107,7 @@ inline std::vector<gdouble> helperfns_read_vector(const gchar* value){ // We could leave this out, too. If strtod can't convert // anything, it will return zero. ret = 0; + break; } v.push_back(ret); diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 28cb40334..060bf317c 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -40,16 +40,16 @@ sp_action_class_init (SPActionClass *klass) static void sp_action_init (SPAction *action) { - action->sensitive = 0; - action->active = 0; - action->context = Inkscape::ActionContext(); - action->id = action->name = action->tip = NULL; - action->image = NULL; - - new (&action->signal_perform) sigc::signal<void>(); - new (&action->signal_set_sensitive) sigc::signal<void, bool>(); - new (&action->signal_set_active) sigc::signal<void, bool>(); - new (&action->signal_set_name) sigc::signal<void, Glib::ustring const &>(); + action->sensitive = 0; + action->active = 0; + action->context = Inkscape::ActionContext(); + action->id = action->name = action->tip = NULL; + action->image = NULL; + + new (&action->signal_perform) sigc::signal<void>(); + new (&action->signal_set_sensitive) sigc::signal<void, bool>(); + new (&action->signal_set_active) sigc::signal<void, bool>(); + new (&action->signal_set_name) sigc::signal<void, Glib::ustring const &>(); } /** @@ -84,17 +84,17 @@ sp_action_new(Inkscape::ActionContext const &context, const gchar *image, Inkscape::Verb * verb) { - SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); + SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); - action->context = context; - action->sensitive = TRUE; - action->id = g_strdup (id); - action->name = g_strdup (name); - action->tip = g_strdup (tip); - action->image = g_strdup (image); - action->verb = verb; + action->context = context; + action->sensitive = TRUE; + action->id = g_strdup (id); + action->name = g_strdup (name); + action->tip = g_strdup (tip); + action->image = g_strdup (image); + action->verb = verb; - return action; + return action; } namespace { @@ -129,11 +129,11 @@ public: */ void sp_action_perform(SPAction *action, void * /*data*/) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - Inkscape::Debug::EventTracker<ActionEvent> tracker(action); - action->signal_perform.emit(); + Inkscape::Debug::EventTracker<ActionEvent> tracker(action); + action->signal_perform.emit(); } /** @@ -142,10 +142,10 @@ void sp_action_perform(SPAction *action, void * /*data*/) void sp_action_set_active (SPAction *action, unsigned int active) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - action->signal_set_active.emit(active); + action->signal_set_active.emit(active); } /** @@ -154,15 +154,18 @@ sp_action_set_active (SPAction *action, unsigned int active) void sp_action_set_sensitive (SPAction *action, unsigned int sensitive) { - g_return_if_fail (action != NULL); - g_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - action->signal_set_sensitive.emit(sensitive); + action->signal_set_sensitive.emit(sensitive); } void sp_action_set_name (SPAction *action, Glib::ustring const &name) { + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); + g_free(action->name); action->name = g_strdup(name.data()); action->signal_set_name.emit(name); @@ -174,8 +177,8 @@ sp_action_set_name (SPAction *action, Glib::ustring const &name) SPDocument * sp_action_get_document (SPAction *action) { - g_return_val_if_fail (SP_IS_ACTION (action), NULL); - return action->context.getDocument(); + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getDocument(); } /** @@ -194,8 +197,8 @@ sp_action_get_selection (SPAction *action) Inkscape::UI::View::View * sp_action_get_view (SPAction *action) { - g_return_val_if_fail (SP_IS_ACTION (action), NULL); - return action->context.getView(); + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getView(); } /** @@ -209,7 +212,7 @@ sp_action_get_desktop (SPAction *action) // already the norm in the Inkscape codebase. This seems wrong. Surely // we should store an SPDesktop* in the first place? Is there a case // of actions being carried out on a View that is not an SPDesktop? - return static_cast<SPDesktop *>(sp_action_get_view(action)); + return static_cast<SPDesktop *>(sp_action_get_view(action)); } /* diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index df0e4fcf2..c9148a634 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -495,13 +495,13 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) /* * Converts all segments in all paths to Geom::LineSegment. There is an intermediate * stage where some may be converted to beziers. maxdisp is the maximum displacement from - * the line segment to the bezier curve. + * the line segment to the bezier curve; ** maxdisp is not used at this moment **. * * This is NOT a terribly fast method, but it should give a solution close to the one with the * fewest points. */ Geom::PathVector -pathv_to_linear( Geom::PathVector const &pathv, double maxdisp) +pathv_to_linear( Geom::PathVector const &pathv, double /*maxdisp*/) { Geom::PathVector output; Geom::PathVector tmppath = pathv_to_linear_and_cubic_beziers(pathv); @@ -536,12 +536,11 @@ pathv_to_linear( Geom::PathVector const &pathv, double maxdisp) pointlist, 0); pointlist.push_back(D); - Geom::Point r0; Geom::Point r1 = pointlist[0]; for (unsigned int i=1; i<pointlist.size();i++){ - r0 = r1; + Geom::Point prev_r1 = r1; r1 = pointlist[i]; - Geom::LineSegment ls(r0, r1); + Geom::LineSegment ls(prev_r1, r1); output.back().append(ls); } pointlist.clear(); diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 320472347..06ccc3739 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -31,6 +31,7 @@ #include <gdk/gdkkeysyms.h> #include "ink-comboboxentry-action.h" +#include "ui/icon-names.h" // Must handle both tool and menu items! static GtkWidget* create_tool_item( GtkAction* action ); @@ -535,18 +536,9 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* act if( action->warning != NULL ) { Glib::ustring missing = check_comma_separated_text( action ); if( !missing.empty() ) { - - GtkStockItem item; - gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); - if (isStock) { - gtk_entry_set_icon_from_stock( action->entry, - GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_DIALOG_WARNING ); - } else { gtk_entry_set_icon_from_icon_name( action->entry, GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_DIALOG_WARNING ); - } + INKSCAPE_ICON("dialog-warning") ); // Can't add tooltip until icon set Glib::ustring warning = action->warning; warning += ": "; @@ -579,10 +571,7 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* act if( !set && action->info != NULL ) { gtk_entry_set_icon_from_icon_name( GTK_ENTRY(action->entry), GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_SELECT_ALL ); - gtk_entry_set_icon_from_stock( GTK_ENTRY(action->entry), - GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_SELECT_ALL ); + INKSCAPE_ICON("edit-select-all") ); gtk_entry_set_icon_tooltip_text( action->entry, GTK_ENTRY_ICON_SECONDARY, action->info ); @@ -610,9 +599,6 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* act gtk_entry_set_icon_from_icon_name( GTK_ENTRY(action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); - gtk_entry_set_icon_from_stock( GTK_ENTRY(action->entry), - GTK_ENTRY_ICON_SECONDARY, - NULL ); } } diff --git a/src/inkview.cpp b/src/inkview.cpp index e65638df6..82bd08e34 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -70,6 +70,8 @@ Inkscape::Application *inkscape; #define bind_textdomain_codeset(p,c) #endif +#include "ui/icon-names.h" + extern char *optarg; extern int optind, opterr; @@ -353,16 +355,44 @@ static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss) #endif gtk_container_add(GTK_CONTAINER(ctrlwin), t); - GtkWidget *b = gtk_button_new_from_stock(GTK_STOCK_GOTO_FIRST); + +#if GTK_CHECK_VERSION(3,10,0) + GtkWidget *b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON); +#else + GtkWidget *b = gtk_button_new(); + GtkWidget *img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(b), img); +#endif gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss); - b = gtk_button_new_from_stock(GTK_STOCK_GO_BACK); +#if GTK_CHECK_VERSION(3,10,0) + b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON); +#else + b = gtk_button_new(); + img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(b), img); +#endif gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss); - b = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); +#if GTK_CHECK_VERSION(3,10,0) + b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON); +#else + b = gtk_button_new(); + img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(b), img); +#endif gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss); - b = gtk_button_new_from_stock(GTK_STOCK_GOTO_LAST); +#if GTK_CHECK_VERSION(3,10,0) + b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON); +#else + b = gtk_button_new(); + img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(b), img); +#endif gtk_container_add(GTK_CONTAINER(t), b); g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss); gtk_widget_show_all(ctrlwin); diff --git a/src/interface.cpp b/src/interface.cpp index 5d4022e7b..bdbedd311 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1392,7 +1392,7 @@ sp_ui_overwrite_file(gchar const *filename) dirName ); gtk_dialog_add_buttons( GTK_DIALOG(dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_NO, + _("_Cancel"), GTK_RESPONSE_NO, _("Replace"), GTK_RESPONSE_YES, NULL ); gtk_dialog_set_default_response( GTK_DIALOG(dialog), GTK_RESPONSE_YES ); @@ -1418,13 +1418,13 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) if (data || GTK_IS_BIN (data)) { void *child = gtk_bin_get_child (GTK_BIN (data)); //child is either - //- a GtkHBox, whose first child is a label displaying name if the menu + //- a GtkBox, whose first child is a label displaying name if the menu //item has an accel key //- a GtkLabel if the menu has no accel key if (child != NULL){ if (GTK_IS_LABEL(child)) { gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str()); - } else if (GTK_IS_HBOX(child)) { + } else if (GTK_IS_BOX(child)) { gtk_label_set_markup_with_mnemonic( GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data), name.c_str()); diff --git a/src/libcroco/cr-sel-eng.c b/src/libcroco/cr-sel-eng.c index 5bc58a96c..0eba2b403 100644 --- a/src/libcroco/cr-sel-eng.c +++ b/src/libcroco/cr-sel-eng.c @@ -150,9 +150,7 @@ lang_pseudo_class_handler (CRSelEng *const a_this, for (; node; node = get_next_parent_element_node (node_iface, node)) { char *val = node_iface->getProp (node, "lang"); if (val) { - if (!strqcmp (val, - a_sel->content.pseudo->extra->stryng->str, - a_sel->content.pseudo->extra->stryng->len)) { + if (!strcasecmp(val, a_sel->content.pseudo->extra->stryng->str)) { result = TRUE; break; } @@ -514,11 +512,11 @@ additional_selector_matches_node (CRSelEng * a_this, continue ; } else if (cur_add_sel->type == PSEUDO_CLASS_ADD_SELECTOR && cur_add_sel->content.pseudo) { - if (pseudo_class_add_sel_matches_node + if (!pseudo_class_add_sel_matches_node (a_this, cur_add_sel, a_node)) { - return TRUE; + return FALSE; } - return FALSE; + continue ; } } if (evaluated == TRUE) diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 12046079e..7b606d200 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -30,7 +30,8 @@ #include <pango/pangowin32.h> #else #include <pango/pangoft2.h> -#include <freetype/freetype.h> +#include <ft2build.h> +#include FT_FREETYPE_H #endif diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 759acfb26..89d0cb037 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -286,6 +286,8 @@ namespace Inkscape PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); const gchar* family = pango_font_description_get_family(descr); + if(!family) + family = "sans-serif"; Glib::ustring Family = family; // PANGO BUG... diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index d0c4c4583..930b7fca9 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -160,7 +160,7 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, // Will only be overridden in the guide-snapper class, because grid lines don't have an origin; the // grid-snapper classes will use this default empty method -void Inkscape::LineSnapper::_addSnappedLinesOrigin(IntermSnapResults &/*isr*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const +void Inkscape::LineSnapper::_addSnappedLinesOrigin(IntermSnapResults &/*isr*/, Geom::Point const &/*origin*/, Geom::Coord const &/*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const { } diff --git a/src/line-snapper.h b/src/line-snapper.h index e7995cdb6..4b165e0a5 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -50,13 +50,13 @@ private: */ virtual LineList _getSnapLines(Geom::Point const &p) const = 0; - virtual void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const = 0; + virtual void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const = 0; // Will only be implemented for guide lines, because grid lines don't have an origin - virtual void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + virtual void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const &origin, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - virtual void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; - virtual void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; + virtual void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; + virtual void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; }; } diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp index 4c5bdc1ac..2b35c9666 100644 --- a/src/livarot/ShapeRaster.cpp +++ b/src/livarot/ShapeRaster.cpp @@ -1241,8 +1241,8 @@ void Shape::QuickScan(float &pos, int &curP, float to, FloatLigne* line, float s if ( nbQRas > 1 ) { int curW = 0; - float lastX = 0; - float lastY = 0; + // float lastX = 0; + // float lastY = 0; int lastGuess = -1; int lastB = -1; @@ -1270,8 +1270,8 @@ void Shape::QuickScan(float &pos, int &curP, float to, FloatLigne* line, float s } else if ( curW%2 != 0 && oW%2 == 0 ) { - lastX = swrData[cb].curX; - lastY = swrData[cb].curY; + // lastX = swrData[cb].curX; + // lastY = swrData[cb].curY; lastB = cb; swrData[cb].guess = -1; diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 30ca5e2d6..c60db4fc4 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -50,12 +50,12 @@ LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : method(_("Method:"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST), width(_("Pen width:"), _("Maximal stroke width"), "width", &wr, this, 25), roundness(_("Pen roundness:"), _("Min/Max width ratio"), "roundness", &wr, this, .2), - angle(_("Angle:"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45), + angle(_("Angle:"), _("direction of thickest strokes (opposite = thinnest)"), "angle", &wr, this, 45), // modulo_pi(_("modulo pi"), _("Give forward and backward moves in one direction the same thickness "), "modulo_pi", &wr, this, false), start_cap(_("Start:"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP), end_cap(_("End:"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP), - growfor(_("Grow for:"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100), - fadefor(_("Fade for:"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100), + growfor(_("Grow for:"), _("Make the stroke thinner near it's start"), "growfor", &wr, this, 100), + fadefor(_("Fade for:"), _("Make the stroke thinner near it's end"), "fadefor", &wr, this, 100), round_ends(_("Round ends"), _("Strokes end with a round end"), "round_ends", &wr, this, false), capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") { diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 6e1d9476d..6c4f2a100 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -29,6 +29,7 @@ #include "inkscape.h" #include "desktop-handles.h" #include "selection.h" +#include "ui/icon-names.h" namespace Inkscape { @@ -59,7 +60,7 @@ OriginalPathParam::param_newWidget() } { // Paste path to link button - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 77f7eabcc..cdbbef1db 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -46,6 +46,7 @@ #include <gtkmm/button.h> #include <gtkmm/label.h> +#include "ui/icon-names.h" namespace Inkscape { @@ -153,7 +154,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "tool-node-editor", Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -163,7 +164,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Edit on-canvas")); - pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_COPY, Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -173,7 +174,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Copy path")); - pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -183,7 +184,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Paste path")); - pIcon = Gtk::manage( sp_icon_get_icon( "edit-clone", Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/main.cpp b/src/main.cpp index c6427dc6f..079944af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,12 +26,13 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "path-prefix.h" // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include <png.h> -#include "ui/widget/panel.h" +#include "ui/widget/panel.h" // This has to be the first to include <glib.h> because of Glibmm's dependence on a deprecated feature... + +#include "path-prefix.h" #ifdef HAVE_IEEEFP_H #include <ieeefp.h> @@ -583,11 +584,14 @@ static void _win32_set_inkscape_env(gchar const *exe) } else { printf("python not found\n\n"); }*/ - + // INKSCAPE_LOCALEDIR is needed by Python/Gettext gchar *localepath = g_build_filename(exe, PACKAGE_LOCALE_DIR, NULL); g_setenv("INKSCAPE_LOCALEDIR", localepath, TRUE); - + + // prevent "please insert disk" messages. fixes bug #950781 + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + g_free(python); g_free(scripts); g_free(perl); diff --git a/src/preferences.cpp b/src/preferences.cpp index 0dcebbb90..b4b873dc8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -668,6 +668,9 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c // No longer necessary, can cause problems with input devices which have a dot in the name // g_assert( pref_key.find('.') == Glib::ustring::npos ); + if (_prefs_doc == NULL){ + return NULL; + } Inkscape::XML::Node *node = _prefs_doc->root(); Inkscape::XML::Node *child = NULL; gchar **splits = g_strsplit(pref_key.c_str(), "/", 0); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 26e575439..f9649d62f 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -372,10 +372,10 @@ static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) { for (GSList const *i = items ; i ; i = i->next ) { - sp_object_ref((SPObject *)i->data, NULL); + sp_object_ref(static_cast<SPItem *>(i->data), NULL); } for (GSList const *i = items; i != NULL; i = i->next) { - SPItem *item = reinterpret_cast<SPItem *>(i->data); + SPItem *item = static_cast<SPItem *>(i->data); item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); } @@ -403,11 +403,11 @@ void sp_selection_delete(SPDesktop *desktop) return; } - GSList const *selected = g_slist_copy(const_cast<GSList *>(selection->itemList())); + GSList *selected = g_slist_copy(const_cast<GSList *>(selection->itemList())); selection->clear(); sp_selection_delete_impl(selected); - g_slist_free(const_cast<GSList *>(selected)); - reinterpret_cast<SPObject *>(desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + g_slist_free(selected); + desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); /* a tool may have set up private information in it's selection context * that depends on desktop items. I think the only sane way to deal with @@ -2879,17 +2879,13 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) _("Objects to marker")); } -static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool wholegroups) { +static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item) && !wholegroups) { for (GSList *i = sp_item_group_item_list(SP_GROUP(item)); i != NULL; i = i->next) { - sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); + sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); } } else { item->convert_to_guides(); - - if (deleteitem) { - item->deleteObject(true); - } } } @@ -2909,13 +2905,24 @@ void sp_selection_to_guides(SPDesktop *desktop) } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool deleteitem = !prefs->getBool("/tools/cvg_keep_objects", 0); + bool deleteitems = !prefs->getBool("/tools/cvg_keep_objects", 0); bool wholegroups = prefs->getBool("/tools/cvg_convert_whole_groups", 0); + // If an object is earlier in the selection list than its clone, and it is deleted, then the clone will have changed + // and its entry in the selection list is invalid (crash). + // Therefore: first convert all, then delete all. + for (GSList const *i = items; i != NULL; i = i->next) { - sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); + sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); } + if (deleteitems) { + selection->clear(); + sp_selection_delete_impl(items); + } + + g_slist_free(items); + DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } @@ -3065,8 +3072,9 @@ void sp_selection_unsymbol(SPDesktop *desktop) // Need to delete <symbol>; all other <use> elements that referenced <symbol> should // auto-magically reference <g>. - symbol->deleteObject(true); + symbol->setAttribute("id","todelete"); group->setAttribute("id",id.c_str()); // After we delete symbol with same id. + symbol->deleteObject(true); parent->getRepr()->appendChild(group); SPItem *group_item = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(group)); diff --git a/src/selection.cpp b/src/selection.cpp index 7c696daf0..17b7253f2 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -154,6 +154,7 @@ bool Selection::includes(SPObject *obj) const { void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { g_return_if_fail(obj != NULL); g_return_if_fail(SP_IS_OBJECT(obj)); + g_return_if_fail(obj->document != NULL); if (includes(obj)) { return; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f961e309d..78d9958c4 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1460,7 +1460,8 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand // Calculate the absolute affine while taking into account the scaling of the stroke width Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, transform_stroke, + bool preserve = prefs->getBool("/options/preservetransform/value", false); + Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, _strokewidth, transform_stroke, preserve, new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]); // Calculate the scaled geometrical bbox @@ -1499,15 +1500,19 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_ Geom::Point new_bbox_max = _visual_bbox->max() * abs_affine; bool transform_stroke = false; - gdouble strokewidth = 0; + bool preserve = false; + gdouble stroke_x = 0; + gdouble stroke_y = 0; if ( _snap_bbox_type != SPItem::GEOMETRIC_BBOX) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); transform_stroke = prefs->getBool("/options/transform/stroke", true); - strokewidth = _strokewidth; + preserve = prefs->getBool("/options/preservetransform/value", false); + stroke_x = _visual_bbox->width() - _geometric_bbox->width(); + stroke_y = _visual_bbox->height() - _geometric_bbox->height(); } - _absolute_affine = get_scale_transform_for_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, + _absolute_affine = get_scale_transform_for_uniform_stroke (*_visual_bbox, stroke_x, stroke_y, transform_stroke, preserve, new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]); // return the new handle position diff --git a/src/snapped-point.h b/src/snapped-point.h index 7ab572e82..bf440c450 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -66,7 +66,7 @@ public: bool getConstrainedSnap() const {return _constrained_snap;} bool getSnapped() const {return _distance < Geom::infinity();} Geom::Point getTransformation() const {return _transformation;} - void setTransformation(Geom::Point const t) {_transformation = t;} + void setTransformation(Geom::Point const &t) {_transformation = t;} void setTarget(SnapTargetType const target) {_target = target;} SnapTargetType getTarget() const {return _target;} void setTargetBBox(Geom::OptRect const target) {_target_bbox = target;} diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 7e5dda871..697b80608 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -506,6 +506,11 @@ void SPGenericEllipse::set_shape() Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform) { + // Allow live effects + if (hasPathEffect() && pathEffectsEnabled()) { + return xform; + } + /* Calculate ellipse start in parent coords. */ Geom::Point pos(Geom::Point(this->cx.computed, this->cy.computed) * xform); diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 9d45c92fc..c3e7d217e 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -220,7 +220,7 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML // Original from sp-item-group.cpp if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { - repr = doc->createElement("svg:this"); + repr = doc->createElement("svg:filter"); } GSList *l = NULL; diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 4ac3278d7..62cf521d3 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -179,7 +179,7 @@ void SPFont::update(SPCtx *ctx, guint flags) { Inkscape::XML::Node* SPFont::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:this"); + repr = xml_doc->createElement("svg:font"); } sp_repr_set_svg_double(repr, "horiz-origin-x", this->horiz_origin_x); diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index a27a1bc78..250713beb 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -84,8 +84,10 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) * the strokewidth, which is either constant or scales width the area of the object. This function takes care of the calculation * of the affine transformation: * @param bbox_visual Current visual bounding box - * @param strokewidth Strokewidth + * @param stroke_x Apparent strokewidth in horizontal direction + * @param stroke_y Apparent strokewidth in vertical direction * @param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * @param preserve If true then the transform element will be preserved in XML, and evaluated after stroke is applied * @param x0 Coordinate of the target visual bounding box * @param y0 Coordinate of the target visual bounding box * @param x1 Coordinate of the target visual bounding box @@ -94,7 +96,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) * not possible here because it will only allow for a positive width and height, and therefore cannot mirror * @return */ -Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visual, gdouble stroke_x, gdouble stroke_y, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -103,13 +105,14 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua Geom::Affine unbudge = Geom::Translate (0, 0); // moves the object(s) to compensate for the drift caused by stroke width change // 1) We start with a visual bounding box (w0, h0) which we want to transfer into another visual bounding box (w1, h1) - // 2) The stroke is r0, equal for all edges + // 2) The stroke is r0, equal for all edges, if preserve transforms is false // 3) Given this visual bounding box we can calculate the geometric bounding box by subtracting half the stroke from each side; // -> The width and height of the geometric bounding box will therefore be (w0 - 2*0.5*r0) and (h0 - 2*0.5*r0) + // 4) If preserve transforms is true, then stroke_x != stroke_y, since these are the apparent stroke widths, after transforming gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road gdouble h0 = bbox_visual.height(); - gdouble r0 = fabs(strokewidth); + gdouble r0 = sqrt(stroke_x*stroke_y); // r0 is redundant, used only for those cases where stroke_x = stroke_y // We also know the width and height of the new visual bounding box gdouble w1 = x1 - x0; // can have any sign @@ -124,7 +127,6 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua // Therefore we will use the absolute values from this point on w1 = fabs(w1); h1 = fabs(h1); - r0 = fabs(r0); // w0 and h0 will always be positive due to the definition of the width() and height() methods. // We will now try to calculate the affine transformation required to transform the first visual bounding box into @@ -134,71 +136,73 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua return Geom::Affine(); } - Geom::Affine direct; - gdouble ratio_x = 1; - gdouble ratio_y = 1; gdouble scale_x = 1; gdouble scale_y = 1; gdouble r1 = r0; - if (fabs(w0 - r0) < 1e-6) { // We have a vertical line at hand - direct = Geom::Scale(flip_x, flip_y * h1 / h0); - ratio_x = 1; - ratio_y = (h1 - r0) / (h0 - r0); + if ((fabs(w0 - r0) < 1e-6) || w1 == 0) { // We have a vertical line at hand r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; scale_x = 1; - scale_y = (h1 - r1)/(h0 - r0); - } else if (fabs(h0 - r0) < 1e-6) { // We have a horizontal line at hand - direct = Geom::Scale(flip_x * w1 / w0, flip_y); - ratio_x = (w1 - r0) / (w0 - r0); - ratio_y = 1; + scale_y = preserve ? h1/h0 : (h1 - r1)/(h0 - r0); + } else if ((fabs(h0 - r0) < 1e-6) || h1 == 0) { // We have a horizontal line at hand r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; - scale_x = (w1 - r1)/(w0 - r0); + scale_x = preserve ? w1/w0 : (w1 - r1)/(w0 - r0); scale_y = 1; } else { // We have a true 2D object at hand - direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box - ratio_x = (w1 - r0) / (w0 - r0); // Only valid when the stroke is kept constant, in which case r1 = r0 - ratio_y = (h1 - r0) / (h0 - r0); - /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) - * Desired area of the geometric bounding box: A1 = (w1-r1)*(h1-r1) - * This is how the stroke should scale: r1^2 / A1 = r0^2 / A0 - * So therefore we will need to solve this equation: - * - * r1^2 * (w0-r0) * (h1-r1) = r0^2 * (w1-r1) * (h0-r0) - * - * This is a quadratic equation in r1, of which the roots can be found using the ABC formula - * */ - gdouble A = -w0*h0 + r0*(w0 + h0); - gdouble B = -(w1 + h1) * r0*r0; - gdouble C = w1 * h1 * r0*r0; - if (B*B - 4*A*C > 0) { - // Of the two roots, I verified experimentally that this is the one we need - r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); - // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); - // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier - scale_x = (w1 - r1)/(w0 - r0); - scale_y = (h1 - r1)/(h0 - r0); - } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? - r1 = r0; + if (transform_stroke && !preserve) { + /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) + * Desired area of the geometric bounding box: A1 = (w1-r1)*(h1-r1) + * This is how the stroke should scale: r1^2 / A1 = r0^2 / A0 + * So therefore we will need to solve this equation: + * + * r1^2 * (w0-r0) * (h0-r0) = r0^2 * (w1-r1) * (h1-r1) + * + * This is a quadratic equation in r1, of which the roots can be found using the ABC formula + * */ + gdouble A = -w0*h0 + r0*(w0 + h0); + gdouble B = -(w1 + h1) * r0*r0; + gdouble C = w1 * h1 * r0*r0; + if (B*B - 4*A*C < 0) { + g_message("stroke scaling error : %d, %f, %f, %f, %f, %f", preserve, r0, w0, h0, w1, h1); + } else { + r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); + // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); + // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier + scale_x = (w1 - r1)/(w0 - r0); + scale_y = (h1 - r1)/(h0 - r0); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed + unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); + } + } else if (!transform_stroke && !preserve) { // scale the geometric bbox with constant stroke + scale_x = (w1 - r0) / (w0 - r0); + scale_y = (h1 - r0) / (h0 - r0); + unbudge *= Geom::Translate (-flip_x * 0.5 * r0 * (scale_x - 1), -flip_y * 0.5 * r0 * (scale_y - 1)); + } else if (!transform_stroke) { // 'Preserve Transforms' was chosen. + // geometric mean of stroke_x and stroke_y will be preserved + // new_stroke_x = stroke_x*sqrt(scale_x/scale_y) + // new_stroke_y = stroke_y*sqrt(scale_y/scale_x) + // scale_x = (w1 - new_stroke_x)/(w0 - stroke_x) + // scale_y = (h1 - new_stroke_y)/(h0 - stroke_y) + gdouble A = h1*(w0 - stroke_x); + gdouble B = (h0*stroke_x - w0*stroke_y); + gdouble C = -w1*(h0 - stroke_y); + gdouble Sx_div_Sy; // Sx_div_Sy = sqrt(scale_x/scale_y) + if (B*B - 4*A*C < 0) { + g_message("stroke scaling error : %d, %f, %f, %f, %f, %f, %f", preserve, stroke_x, stroke_y, w0, h0, w1, h1); + } else { + Sx_div_Sy = (-B + sqrt(B*B - 4*A*C))/2/A; + scale_x = (w1 - stroke_x*Sx_div_Sy)/(w0 - stroke_x); + scale_y = (h1 - stroke_y/Sx_div_Sy)/(h0 - stroke_y); + unbudge *= Geom::Translate (-flip_x * 0.5 * stroke_x * scale_x * (1.0 - sqrt(1.0/scale_x/scale_y)), -flip_y * 0.5 * stroke_y * scale_y * (1.0 - sqrt(1.0/scale_x/scale_y))); + } + } else { // 'Preserve Transforms' was chosen, and stroke is scaled scale_x = w1 / w0; scale_y = h1 / h0; } } - // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find - if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // Check if there's stroke, and we need to scale it - // Now we account for mirroring by flipping if needed - scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); - // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed - unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); - } else { // The stroke should not be scaled, or is zero - if (r0 == 0 || r0 == Geom::infinity() ) { // Strokewidth is zero or infinite - scale *= direct; - } else { // Nonscaling strokewidth - scale *= Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); // Scaling of the geometric bounding box for constant stroke width - unbudge *= Geom::Translate (flip_x * 0.5 * r0 * (1 - ratio_x), flip_y * 0.5 * r0 * (1 - ratio_y)); - } - } + // Now we account for mirroring by flipping if needed + scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); return (p2o * scale * unbudge * o2n); } @@ -222,6 +226,7 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua * @param bbox_visual Current visual bounding box * @param bbox_geometric Current geometric bounding box (allows for calculating the strokewidth of each edge) * @param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * @param preserve If true then the transform element will be preserved in XML, and evaluated after stroke is applied * @param x0 Coordinate of the target visual bounding box * @param y0 Coordinate of the target visual bounding box * @param x1 Coordinate of the target visual bounding box @@ -230,7 +235,7 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua * not possible here because it will only allow for a positive width and height, and therefore cannot mirror * @return */ -Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -268,79 +273,10 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu return Geom::Affine(); } - Geom::Affine direct; - gdouble ratio_x = 1; - gdouble ratio_y = 1; - gdouble scale_x = 1; - gdouble scale_y = 1; - gdouble r1h = r0h; - gdouble r1w = r0w; - - if (fabs(w0 - r0w) < 1e-6) { // We have a vertical line at hand - direct = Geom::Scale(flip_x, flip_y * h1 / h0); - ratio_x = 1; - ratio_y = (h1 - r0h) / (h0 - r0h); - r1h = transform_stroke ? r0h * sqrt(h1/h0) : r0h; - scale_x = 1; - scale_y = (h1 - r1h)/(h0 - r0h); - } else if (fabs(h0 - r0h) < 1e-6) { // We have a horizontal line at hand - direct = Geom::Scale(flip_x * w1 / w0, flip_y); - ratio_x = (w1 - r0w) / (w0 - r0w); - ratio_y = 1; - r1w = transform_stroke ? r0w * sqrt(w1/w0) : r0w; - scale_x = (w1 - r1w)/(w0 - r0w); - scale_y = 1; - } else { // We have a true 2D object at hand - direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box - ratio_x = (w1 - r0w) / (w0 - r0w); // Only valid when the stroke is kept constant, in which case r1 = r0 - ratio_y = (h1 - r0h) / (h0 - r0h); - /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) - * Desired area of the geometric bounding box: A1 = (w1-r1w)*(h1-r1h) - * This is how the stroke should scale: r1w^2 = A1/A0 * r0w^2, AND - * r1h^2 = A1/A0 * r0h^2 - * Now we have to solve this set of two equations and find r1w and r1h; this too complicated to do by hand, - * so I used wxMaxima for that (http://wxmaxima.sourceforge.net/). These lines can be copied into Maxima - * - * A1: (w1-r1w)*(h1-r1h); - * s: A1/A0; - * expr1a: r1w^2 = s*r0w^2; - * expr1b: r1h^2 = s*r0h^2; - * sol: solve([expr1a, expr1b], [r1h, r1w]); - * sol[1][1]; sol[2][1]; sol[3][1]; sol[4][1]; - * sol[1][2]; sol[2][2]; sol[3][2]; sol[4][2]; - * - * PS1: The last two lines are only needed for readability of the output, and can be omitted if desired - * PS2: A0 is known beforehand and assumed to be constant, instead of using A0 = (w0-r0w)*(h0-r0h). This reduces the - * length of the results significantly - * PS3: You'll get 8 solutions, 4 for each of the strokewidths r1w and r1h. Some experiments quickly showed which of the solutions - * lead to meaningful strokewidths - * */ - gdouble r0h2 = r0h*r0h; - gdouble r0h3 = r0h2*r0h; - gdouble r0w2 = r0w*r0w; - gdouble w12 = w1*w1; - gdouble h12 = h1*h1; - gdouble A0 = bbox_geom.area(); - gdouble A02 = A0*A0; - - gdouble operant = 4*h1*w1*A0+r0h2*w12-2*h1*r0h*r0w*w1+h12*r0w2; - if (operant >= 0) { - // Of the eight roots, I verified experimentally that these are the two we need - r1h = fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); - r1w = fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); - // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); - // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier - scale_x = (w1 - r1w)/(w0 - r0w); - scale_y = (h1 - r1h)/(h0 - r0h); - } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? - scale_x = w1 / w0; - scale_y = h1 / h0; - } - } - // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which // occurs for example for clipped objects (see launchpad bug #811819) if (r0w < 0 || r0h < 0) { + Geom::Affine direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, // so for now we simply return the direct scaling return (p2o * direct * o2n); @@ -352,21 +288,95 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu gdouble stroke_ratio_w = fabs(r0w) < 1e-6 ? 1 : (bbox_geom[Geom::X].min() - bbox_visual[Geom::X].min())/r0w; gdouble stroke_ratio_h = fabs(r0h) < 1e-6 ? 1 : (bbox_geom[Geom::Y].min() - bbox_visual[Geom::Y].min())/r0h; - // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find - if (transform_stroke && r0w != 0 && r0w != Geom::infinity() && r0h != 0 && r0h != Geom::infinity()) { // Check if there's stroke, and we need to scale it - // Now we account for mirroring by flipping if needed - scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); - // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed - unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * (r0w * scale_x - r1w), -flip_y * stroke_ratio_h * (r0h * scale_y - r1h)); - } else { // The stroke should not be scaled, or is zero (or infinite) - if (r0w == 0 || r0w == Geom::infinity() || r0h == 0 || r0h == Geom::infinity()) { // can't calculate, because apparently strokewidth is zero or infinite - scale *= direct; - } else { - scale *= Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); // Scaling of the geometric bounding box for constant stroke width - unbudge *= Geom::Translate (flip_x * stroke_ratio_w * r0w * (1 - ratio_x), flip_y * stroke_ratio_h * r0h * (1 - ratio_y)); + gdouble scale_x = 1; + gdouble scale_y = 1; + gdouble r1h = r0h; + gdouble r1w = r0w; + + if ((fabs(w0 - r0w) < 1e-6) || w1 == 0) { // We have a vertical line at hand + r1h = transform_stroke ? r0h * sqrt(h1/h0) : r0h; + scale_x = 1; + scale_y = preserve ? h1/h0 : (h1 - r1h)/(h0 - r0h); + } else if ((fabs(h0 - r0h) < 1e-6) || h1 == 0) { // We have a horizontal line at hand + r1w = transform_stroke ? r0w * sqrt(w1/w0) : r0w; + scale_x = preserve ? w1/w0 : (w1 - r1w)/(w0 - r0w); + scale_y = 1; + } else { // We have a true 2D object at hand + if (transform_stroke && !preserve) { + /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) + * Desired area of the geometric bounding box: A1 = (w1-r1w)*(h1-r1h) + * This is how the stroke should scale: r1w^2 = A1/A0 * r0w^2, AND + * r1h^2 = A1/A0 * r0h^2 + * Now we have to solve this set of two equations and find r1w and r1h; this too complicated to do by hand, + * so I used wxMaxima for that (http://wxmaxima.sourceforge.net/). These lines can be copied into Maxima + * + * A1: (w1-r1w)*(h1-r1h); + * s: A1/A0; + * expr1a: r1w^2 = s*r0w^2; + * expr1b: r1h^2 = s*r0h^2; + * sol: solve([expr1a, expr1b], [r1h, r1w]); + * sol[1][1]; sol[2][1]; sol[3][1]; sol[4][1]; + * sol[1][2]; sol[2][2]; sol[3][2]; sol[4][2]; + * + * PS1: The last two lines are only needed for readability of the output, and can be omitted if desired + * PS2: A0 is known beforehand and assumed to be constant, instead of using A0 = (w0-r0w)*(h0-r0h). This reduces the + * length of the results significantly + * PS3: You'll get 8 solutions, 4 for each of the strokewidths r1w and r1h. Some experiments quickly showed which of the solutions + * lead to meaningful strokewidths + * */ + gdouble r0h2 = r0h*r0h; + gdouble r0h3 = r0h2*r0h; + gdouble r0w2 = r0w*r0w; + gdouble w12 = w1*w1; + gdouble h12 = h1*h1; + gdouble A0 = bbox_geom.area(); + gdouble A02 = A0*A0; + + gdouble operant = 4*h1*w1*A0+r0h2*w12-2*h1*r0h*r0w*w1+h12*r0w2; + if (operant < 0) { + g_message("variable stroke scaling error : %d, %d, %f, %f, %f, %f, %f, %f", transform_stroke, preserve, r0w, r0h, w0, h0, w1, h1); + } else { + // Of the eight roots, I verified experimentally that these are the two we need + r1h = fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); + r1w = fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); + // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); + // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier + scale_x = (w1 - r1w)/(w0 - r0w); + scale_y = (h1 - r1h)/(h0 - r0h); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed + unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * (r0w * scale_x - r1w), -flip_y * stroke_ratio_h * (r0h * scale_y - r1h)); + } + } else if (!transform_stroke && !preserve) { // scale the geometric bbox with constant stroke + scale_x = (w1 - r0w) / (w0 - r0w); + scale_y = (h1 - r0h) / (h0 - r0h); + unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * r0w * (scale_x - 1), -flip_y * stroke_ratio_h * r0h * (scale_y - 1)); + } else if (!transform_stroke) { // 'Preserve Transforms' was chosen. + // geometric mean of r0w and r0h will be preserved + // new_r0w = r0w*sqrt(scale_x/scale_y) + // new_r0h = r0h*sqrt(scale_y/scale_x) + // scale_x = (w1 - new_r0w)/(w0 - r0w) + // scale_y = (h1 - new_r0h)/(h0 - r0h) + gdouble A = h1*(w0 - r0w); + gdouble B = (h0*r0w - w0*r0h); + gdouble C = -w1*(h0 - r0h); + gdouble Sx_div_Sy; // Sx_div_Sy = sqrt(scale_x/scale_y) + if (B*B - 4*A*C < 0) { + g_message("variable stroke scaling error : %d, %d, %f, %f, %f, %f, %f, %f", transform_stroke, preserve, r0w, r0h, w0, h0, w1, h1); + } else { + Sx_div_Sy = (-B + sqrt(B*B - 4*A*C))/2/A; + scale_x = (w1 - r0w*Sx_div_Sy)/(w0 - r0w); + scale_y = (h1 - r0h/Sx_div_Sy)/(h0 - r0h); + unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * r0w * scale_x * (1.0 - sqrt(1.0/scale_x/scale_y)), -flip_y * stroke_ratio_h * r0h * scale_y * (1.0 - sqrt(1.0/scale_x/scale_y))); + } + } else { // 'Preserve Transforms' was chosen, and stroke is scaled + scale_x = w1 / w0; + scale_y = h1 / h0; } } + // Now we account for mirroring by flipping if needed + scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); + return (p2o * scale * unbudge * o2n); } diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 5e67dd276..230d5a3dd 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -11,8 +11,8 @@ void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); -Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble stroke_x, gdouble stroke_y, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1); Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c6daa853c..5e126f486 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -599,6 +599,8 @@ void SPItem::update(SPCtx* /*ctx*/, guint flags) { if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = item->display; v != NULL; v = v->next) { v->arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(object->style->opacity.value)); + v->arenaitem->setIsolation( object->style->isolation.value ); + v->arenaitem->setBlendMode( object->style->blend_mode.value ); v->arenaitem->setVisible(!item->isHidden()); } } @@ -1023,6 +1025,9 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned display = sp_item_view_new_prepend(display, this, flags, key, ai); ai->setTransform(transform); ai->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value)); + ai->setIsolation( style->isolation.value ); + ai->setBlendMode( style->blend_mode.value ); + //ai->setCompositeOperator( style->composite_op.value ); ai->setVisible(!isHidden()); ai->setSensitive(sensitive); if (clip_ref->getObject()) { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 4a32c9470..0e6eef6ae 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -119,7 +119,7 @@ SPObject::SPObject() _successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT), _label(NULL), _default_label(NULL) { - debug("id=%x, typename=%s",this, g_type_name_from_instance((GTypeInstance*)object)); + debug("id=%p, typename=%s",this, g_type_name_from_instance((GTypeInstance*)this)); //used XML Tree here. this->getRepr(); // TODO check why this call is made @@ -607,14 +607,14 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPObject::release() { SPObject* object = this; - debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); + debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); while (object->children) { object->detach(object->children); } } void SPObject::remove_child(Inkscape::XML::Node* child) { - debug("id=%x, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this)); + debug("id=%p, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this)); SPObject *ochild = this->get_child_by_repr(child); @@ -638,7 +638,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { SPObject* object = this; /* Nothing specific here */ - debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); + debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); object->readAttr("xml:space"); object->readAttr("inkscape:label"); @@ -665,7 +665,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned) { - debug("id=%x, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this)); + debug("id=%p, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this)); //g_assert(object != NULL); //g_assert(SP_IS_OBJECT(object)); diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 10d097e70..302905a62 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -82,9 +82,12 @@ Inkscape::XML::Node* SPPolygon::write(Inkscape::XML::Document *xml_doc, Inkscape } /* We can safely write points here, because all subclasses require it too (Lauris) */ - gchar *str = sp_svg_write_polygon(this->_curve->get_pathvector()); - repr->setAttribute("points", str); - g_free(str); + /* While saving polygon element without points attribute _curve is NULL (see bug 1202753) */ + if (this->_curve != NULL) { + gchar *str = sp_svg_write_polygon(this->_curve->get_pathvector()); + repr->setAttribute("points", str); + g_free(str); + } SPShape::write(xml_doc, repr, flags); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index ffb875f2a..9ef73d56d 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -440,6 +440,11 @@ Geom::Affine SPSpiral::set_transform(Geom::Affine const &xform) return xform; } + // Allow live effects + if (hasPathEffect() && pathEffectsEnabled()) { + return xform; + } + /* Calculate spiral start in parent coords. */ Geom::Point pos( Geom::Point(this->cx, this->cy) * xform ); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index da10eeaa3..eac33ed7b 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -520,6 +520,11 @@ Geom::Affine SPStar::set_transform(Geom::Affine const &xform) return xform; } + // Allow live effects + if (hasPathEffect() && pathEffectsEnabled()) { + return xform; + } + /* Calculate star start in parent coords. */ Geom::Point pos( this->center * xform ); diff --git a/src/sp-string.cpp b/src/sp-string.cpp index be450b248..08755a5fc 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -108,7 +108,7 @@ void SPString::read_content() { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void SPString::update(SPCtx *ctx, unsigned flags) { +void SPString::update(SPCtx * /*ctx*/, unsigned /*flags*/) { // SPObject::onUpdate(ctx, flags); // if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG)) { diff --git a/src/sp-text.cpp b/src/sp-text.cpp index d2f433eba..ef46e890f 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -235,7 +235,7 @@ void SPText::modified(guint flags) { Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { - repr = xml_doc->createElement("svg:this"); + repr = xml_doc->createElement("svg:text"); } GSList *l = NULL; diff --git a/src/style.cpp b/src/style.cpp index fc0c97c15..bb5603f1c 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -303,6 +303,33 @@ static SPStyleEnum const enum_overflow[] = { {NULL, -1} }; +// CSS Compositing and Blending Level 1 +static SPStyleEnum const enum_isolation[] = { + {"auto", SP_CSS_ISOLATION_AUTO}, + {"isolate", SP_CSS_ISOLATION_ISOLATE}, + {NULL, -1} +}; + +static SPStyleEnum const enum_blend_mode[] = { + {"normal", SP_CSS_BLEND_NORMAL}, + {"multiply", SP_CSS_BLEND_MULTIPLY}, + {"screen", SP_CSS_BLEND_SCREEN}, + {"darken", SP_CSS_BLEND_DARKEN}, + {"lighten", SP_CSS_BLEND_LIGHTEN}, + {"overlay", SP_CSS_BLEND_OVERLAY}, + {"color-dodge", SP_CSS_BLEND_COLORDODGE}, + {"color-burn", SP_CSS_BLEND_COLORBURN}, + {"hard-light", SP_CSS_BLEND_HARDLIGHT}, + {"soft-light", SP_CSS_BLEND_SOFTLIGHT}, + {"difference", SP_CSS_BLEND_DIFFERENCE}, + {"exclusion", SP_CSS_BLEND_EXCLUSION}, + {"hue", SP_CSS_BLEND_HUE}, + {"saturation", SP_CSS_BLEND_SATURATION}, + {"color", SP_CSS_BLEND_COLOR}, + {"luminosity", SP_CSS_BLEND_LUMINOSITY}, + {NULL, -1} +}; + static SPStyleEnum const enum_display[] = { {"none", SP_CSS_DISPLAY_NONE}, {"inline", SP_CSS_DISPLAY_INLINE}, @@ -643,6 +670,11 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) SPS_READ_PENUM_IF_UNSET(&style->visibility, repr, "visibility", enum_visibility, true); SPS_READ_PENUM_IF_UNSET(&style->display, repr, "display", enum_display, true); SPS_READ_PENUM_IF_UNSET(&style->overflow, repr, "overflow", enum_overflow, true); + + /* CSS Compositing and Blending Level 1 */ + SPS_READ_PENUM_IF_UNSET(&style->isolation, repr, "isolation", enum_isolation, true); + SPS_READ_PENUM_IF_UNSET(&style->blend_mode, repr, "mix_blend_mode", enum_blend_mode, true); + /* Font */ SPS_READ_PFONTSIZE_IF_UNSET(&style->font_size, repr, "font-size"); SPS_READ_PENUM_IF_UNSET(&style->font_style, repr, "font-style", enum_font_style, true); @@ -1207,6 +1239,13 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) case SP_PROP_VISIBILITY: SPS_READ_IENUM_IF_UNSET(&style->visibility, val, enum_visibility, true); break; + case SP_PROP_ISOLATION: + SPS_READ_IENUM_IF_UNSET(&style->isolation, val, enum_isolation, true); + break; + case SP_PROP_BLEND_MODE: + SPS_READ_IENUM_IF_UNSET(&style->blend_mode, val, enum_blend_mode, true); + break; + /* SVG */ /* Clip/Mask */ case SP_PROP_CLIP_PATH: @@ -2180,6 +2219,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare /* Enum values that don't have any relative settings (other than `inherit'). */ { SPIEnum SPStyle::*const fields[] = { + &SPStyle::blend_mode, &SPStyle::clip_rule, &SPStyle::color_interpolation, &SPStyle::color_interpolation_filters, @@ -2189,6 +2229,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare &SPStyle::font_style, &SPStyle::font_variant, &SPStyle::image_rendering, + &SPStyle::isolation, //nyi: SPStyle::pointer_events, &SPStyle::shape_rendering, &SPStyle::stroke_linecap, @@ -2791,6 +2832,8 @@ sp_style_write_string(SPStyle const *const style, guint const flags) p += sp_style_write_ienum(p, c + BMAX - p, "visibility", enum_visibility, &style->visibility, NULL, flags); p += sp_style_write_ienum(p, c + BMAX - p, "display", enum_display, &style->display, NULL, flags); p += sp_style_write_ienum(p, c + BMAX - p, "overflow", enum_overflow, &style->overflow, NULL, flags); + p += sp_style_write_ienum(p, c + BMAX - p, "isolation", enum_isolation, &style->isolation, NULL, flags); + p += sp_style_write_ienum(p, c + BMAX - p, "mix-blend-mode", enum_blend_mode, &style->blend_mode, NULL, flags); /* filter: */ p += sp_style_write_ifilter(p, c + BMAX - p, "filter", &style->filter, NULL, flags); @@ -2949,6 +2992,8 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) p += sp_style_write_ienum(p, c + BMAX - p, "visibility", enum_visibility, &from->visibility, &to->visibility, SP_STYLE_FLAG_IFSET); p += sp_style_write_ienum(p, c + BMAX - p, "display", enum_display, &from->display, &to->display, SP_STYLE_FLAG_IFSET); p += sp_style_write_ienum(p, c + BMAX - p, "overflow", enum_overflow, &from->overflow, &to->overflow, SP_STYLE_FLAG_IFSET); + p += sp_style_write_ienum(p, c + BMAX - p, "isolation", enum_isolation, &from->isolation, &to->isolation, SP_STYLE_FLAG_IFSET); + p += sp_style_write_ienum(p, c + BMAX - p, "mix-blend-mode", enum_blend_mode, &from->blend_mode, &to->blend_mode, SP_STYLE_FLAG_IFSET); /* filter: */ p += sp_style_write_ifilter(p, c + BMAX - p, "filter", &from->filter, &to->filter, SP_STYLE_FLAG_IFDIFF); @@ -3168,6 +3213,12 @@ sp_style_clear(SPStyle *style) style->overflow.set = FALSE; style->overflow.inherit = FALSE; style->overflow.value = style->overflow.computed = SP_CSS_OVERFLOW_VISIBLE; + style->isolation.set = FALSE; + style->isolation.inherit = FALSE; + style->isolation.value = style->isolation.computed = SP_CSS_ISOLATION_AUTO; + style->blend_mode.set = FALSE; + style->blend_mode.inherit = FALSE; + style->blend_mode.value = style->blend_mode.computed = SP_CSS_BLEND_NORMAL; style->color.clear(); style->color.setColor(0.0, 0.0, 0.0); diff --git a/src/style.h b/src/style.h index bc4df96e2..014d2b72f 100644 --- a/src/style.h +++ b/src/style.h @@ -364,6 +364,11 @@ struct SPStyle { /** opacity */ SPIScale24 opacity; + /** mix-blend-mode: CSS Compositing and Blending Level 1 */ + SPIEnum isolation; + // Could be shared with Filter blending mode + SPIEnum blend_mode; + /** color */ SPIPaint color; /** color-interpolation */ @@ -606,6 +611,30 @@ enum SPCSSDisplay { SP_CSS_DISPLAY_TABLE_CAPTION }; +enum SPIsolation { + SP_CSS_ISOLATION_AUTO, + SP_CSS_ISOLATION_ISOLATE +}; + +enum SPBlendMode { + SP_CSS_BLEND_NORMAL, + SP_CSS_BLEND_MULTIPLY, + SP_CSS_BLEND_SCREEN, + SP_CSS_BLEND_DARKEN, + SP_CSS_BLEND_LIGHTEN, + SP_CSS_BLEND_OVERLAY, + SP_CSS_BLEND_COLORDODGE, + SP_CSS_BLEND_COLORBURN, + SP_CSS_BLEND_HARDLIGHT, + SP_CSS_BLEND_SOFTLIGHT, + SP_CSS_BLEND_DIFFERENCE, + SP_CSS_BLEND_EXCLUSION, + SP_CSS_BLEND_HUE, + SP_CSS_BLEND_SATURATION, + SP_CSS_BLEND_COLOR, + SP_CSS_BLEND_LUMINOSITY +}; + enum SPEnableBackground { SP_CSS_BACKGROUND_ACCUMULATE, SP_CSS_BACKGROUND_NEW diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 532d19e02..aa2d81427 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -246,6 +246,7 @@ text_remove_all_kerns_recursively(SPObject *o) for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) { text_remove_all_kerns_recursively(i); + i->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 32f23d55f..d324d2d1b 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -57,6 +57,7 @@ #include <gtkmm/table.h> #include <2geom/transforms.h> +#include "ui/icon-names.h" using std::pair; @@ -609,10 +610,22 @@ void DocumentProperties::build_cms() label_avail->set_markup (_("<b>Available Color Profiles:</b>")); _link_btn.set_tooltip_text(_("Link Profile")); - _link_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + _link_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_link = Gtk::manage(new Gtk::Image()); + image_link->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _link_btn.set_image(*image_link); +#endif _unlink_btn.set_tooltip_text(_("Unlink Profile")); - _unlink_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + _unlink_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_unlink = Gtk::manage(new Gtk::Image()); + image_unlink->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _unlink_btn.set_image(*image_unlink); +#endif _page_cms->set_spacing(4); gint row = 0; @@ -734,11 +747,22 @@ void DocumentProperties::build_scripting() label_external->set_markup (_("<b>External script files:</b>")); _external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file")); - _external_add_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + _external_add_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_ext_add = Gtk::manage(new Gtk::Image()); + image_ext_add->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _external_add_btn.set_image(*image_ext_add); +#endif _external_remove_btn.set_tooltip_text(_("Remove")); - _external_remove_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); - +#if GTK_CHECK_VERSION(3,10,0) + _external_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_ext_rm = Gtk::manage(new Gtk::Image()); + image_ext_rm->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _external_remove_btn.set_image(*image_ext_rm); +#endif _page_external_scripts->set_spacing(4); gint row = 0; @@ -812,10 +836,22 @@ void DocumentProperties::build_scripting() label_embedded->set_markup (_("<b>Embedded script files:</b>")); _embed_new_btn.set_tooltip_text(_("New")); - _embed_new_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + _embed_new_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_embed_new = Gtk::manage(new Gtk::Image()); + image_embed_new->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _embed_new_btn.set_image(*image_embed_new); +#endif _embed_remove_btn.set_tooltip_text(_("Remove")); - _embed_remove_btn.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + _embed_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_embed_rm = Gtk::manage(new Gtk::Image()); + image_embed_rm->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + _embed_remove_btn.set_image(*image_embed_rm); +#endif #if !WITH_GTKMM_3_0 // TODO: This has been removed from Gtkmm 3.0. Check that diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 8ea1a09fa..340a3dad0 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -813,7 +813,7 @@ void Export::onAreaToggled () /* If we still don't have a filename -- let's build one that's nice */ if (filename.empty()) { - const gchar * id = NULL; + const gchar * id = "object"; const GSList * reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); for(; reprlst != NULL; reprlst = reprlst->next) { Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; @@ -1295,8 +1295,8 @@ void Export::onBrowse () fs = gtk_file_chooser_dialog_new (_("Select a filename for exporting"), (GtkWindow*)desktop->getToplevel(), GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Save"), GTK_RESPONSE_ACCEPT, NULL ); #ifdef WITH_GNOME_VFS @@ -1343,7 +1343,15 @@ void Export::onBrowse () wcsncpy(_filename, reinterpret_cast<wchar_t*>(utf16_path_string), _MAX_PATH); g_free(utf16_path_string); - opf.hwndOwner = (HWND)(GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(this)))); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Glib::RefPtr<const Gdk::Window> parentWindow = desktop->getToplevel()->get_window(); + g_assert(parentWindow->gobj() != NULL); + +#if WITH_GTKMM_3_0 + opf.hwndOwner = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); +#else + opf.hwndOwner = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); +#endif opf.lpstrFilter = filter_string; opf.lpstrCustomFilter = 0; opf.nMaxCustFilter = 0L; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 12fdf6b7d..381810f1e 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -881,30 +881,30 @@ LayersPanel::LayersPanel() : SPDesktop* targetDesktop = getDesktop(); Gtk::Button* btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, C_("Layers", "New") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, INKSCAPE_ICON("list-add"), C_("Layers", "New") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) ); _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, INKSCAPE_ICON("go-bottom"), C_("Layers", "Bot") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) ); _watchingNonBottom.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, C_("Layers", "Dn") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("go-down"), C_("Layers", "Dn") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) ); _watchingNonBottom.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("go-up"), C_("Layers", "Up") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) ); _watchingNonTop.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, INKSCAPE_ICON("go-top"), C_("Layers", "Top") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) ); _watchingNonTop.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); @@ -914,7 +914,7 @@ LayersPanel::LayersPanel() : // _buttonsRow.add( *btn ); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, GTK_STOCK_REMOVE, _("X") ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, INKSCAPE_ICON("list-remove"), _("X") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) ); _watching.push_back( btn ); _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK); @@ -944,8 +944,8 @@ LayersPanel::LayersPanel() : _popupMenu.append(*manage(new Gtk::SeparatorMenuItem())); - _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up", (int)BUTTON_UP ) ); - _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Down", (int)BUTTON_DOWN ) ); + _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("go-up"), "Up", (int)BUTTON_UP ) ); + _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("go-down"), "Down", (int)BUTTON_DOWN ) ); _popupMenu.show_all_children(); } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 30b16cee0..b81b300e2 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -107,19 +107,43 @@ LivePathEffectEditor::LivePathEffectEditor() effectcontrol_frame.add(effectcontrol_vbox); button_add.set_tooltip_text(_("Add path effect")); - button_add.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + button_add.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_add = Gtk::manage(new Gtk::Image()); + image_add->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + button_add.set_image(*image_add); +#endif button_add.set_relief(Gtk::RELIEF_NONE); button_remove.set_tooltip_text(_("Delete current path effect")); - button_remove.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + button_remove.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_remove = Gtk::manage(new Gtk::Image()); + image_remove->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + button_remove.set_image(*image_remove); +#endif button_remove.set_relief(Gtk::RELIEF_NONE); button_up.set_tooltip_text(_("Raise the current path effect")); - button_up.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_GO_UP, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + button_up.set_image_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_up = Gtk::manage(new Gtk::Image()); + image_up->set_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + button_up.set_image(*image_up); +#endif button_up.set_relief(Gtk::RELIEF_NONE); button_down.set_tooltip_text(_("Lower the current path effect")); - button_down.set_image(*manage(Glib::wrap(gtk_image_new_from_stock ( GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_SMALL_TOOLBAR ) ))); +#if GTK_CHECK_VERSION(3,10,0) + button_down.set_image_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR); +#else + Gtk::Image *image_down = Gtk::manage(new Gtk::Image()); + image_down->set_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR); + button_down.set_image(*image_down); +#endif button_down.set_relief(Gtk::RELIEF_NONE); // Add toolbar items to toolbar diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 2595e2cf5..177f15195 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -34,7 +34,7 @@ NewFromTemplate::NewFromTemplate() align->set_padding(0, 0, 0, 15); align->add(_create_template_button); - _create_template_button.signal_pressed().connect( + _create_template_button.signal_clicked().connect( sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); show_all(); diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index ca0edfadd..93fcab863 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -16,13 +16,14 @@ # include <config.h> #endif +#include "ocaldialogs.h" + #include <stdio.h> // rename() #include <unistd.h> // close() #include <errno.h> // errno #include <string.h> // strerror() #include "path-prefix.h" -#include "ocaldialogs.h" #include "filedialogimpl-gtkmm.h" #include "interface.h" #include "gc-core.h" @@ -42,6 +43,7 @@ #include <glibmm/main.h> #include <glibmm/markup.h> #include <glibmm/miscutils.h> +#include "ui/icon-names.h" namespace Inkscape { @@ -577,8 +579,8 @@ SearchEntry::SearchEntry() : Gtk::Entry() signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed)); signal_icon_press().connect(sigc::mem_fun(*this, &SearchEntry::_on_icon_pressed)); - set_icon_from_stock(Gtk::Stock::FIND, Gtk::ENTRY_ICON_PRIMARY); - gtk_entry_set_icon_from_stock(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); + set_icon_from_icon_name(INKSCAPE_ICON("edit-find"), Gtk::ENTRY_ICON_PRIMARY); + gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); } void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* /*event*/) @@ -595,9 +597,9 @@ void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const G void SearchEntry::_on_changed() { if (get_text().empty()) { - gtk_entry_set_icon_from_stock(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); + gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); } else { - set_icon_from_stock(Gtk::Stock::CLEAR, Gtk::ENTRY_ICON_SECONDARY); + set_icon_from_icon_name(INKSCAPE_ICON("edit-clear"), Gtk::ENTRY_ICON_SECONDARY); } } #endif diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index cc7bbb277..ce5b6584d 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -159,7 +159,7 @@ PixelArtDialogImpl::PixelArtDialogImpl() : // Heuristics { - curvesMultiplierLabel.set_label(_("_Curves (multiplier)")); + curvesMultiplierLabel.set_label(_("_Curves (multiplier):")); curvesMultiplierLabel.set_use_underline(true); curvesMultiplierLabel.set_mnemonic_widget(curvesMultiplierSpinner); curvesMultiplierLabel.set_tooltip_text(_("Favors connections that are part of a long curve")); @@ -173,7 +173,7 @@ PixelArtDialogImpl::PixelArtDialogImpl() : curvesMultiplierHBox.pack_end(curvesMultiplierSpinner, false, false); heuristicsVBox.pack_start(curvesMultiplierHBox, false, false); - islandsWeightLabel.set_label(_("_Islands (weight)")); + islandsWeightLabel.set_label(_("_Islands (weight):")); islandsWeightLabel.set_use_underline(true); islandsWeightLabel.set_mnemonic_widget(islandsWeightSpinner); islandsWeightLabel.set_tooltip_text(_("Avoid single disconnected pixels")); @@ -188,7 +188,7 @@ PixelArtDialogImpl::PixelArtDialogImpl() : islandsWeightHBox.pack_end(islandsWeightSpinner, false, false); heuristicsVBox.pack_start(islandsWeightHBox, false, false); - sparsePixelsRadiusLabel.set_label(_("Sparse pixels (window _radius)")); + sparsePixelsRadiusLabel.set_label(_("Sparse pixels (window _radius):")); sparsePixelsRadiusLabel.set_use_underline(true); sparsePixelsRadiusLabel.set_mnemonic_widget(sparsePixelsRadiusSpinner); @@ -198,7 +198,7 @@ PixelArtDialogImpl::PixelArtDialogImpl() : .connect(sigc::mem_fun(*this, &PixelArtDialogImpl::updatePreview)); sparsePixelsRadiusSpinner.set_tooltip_text(_("The radius of the window analyzed")); - sparsePixelsMultiplierLabel.set_label(_("Sparse pixels (_multiplier)")); + sparsePixelsMultiplierLabel.set_label(_("Sparse pixels (_multiplier):")); sparsePixelsMultiplierLabel.set_use_underline(true); sparsePixelsMultiplierLabel.set_mnemonic_widget(sparsePixelsMultiplierSpinner); @@ -373,8 +373,8 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) = Glib::wrap(img->pixbuf->getPixbufRaw(), true); if ( pixbuf->get_width() > 256 || pixbuf->get_height() > 256 ) { - char *msg = _("Image looks too big. Process may take a while and is" - " wise to save your document before continue." + char *msg = _("Image looks too big. Process may take a while and it is" + " wise to save your document before continuing." "\n\nContinue the procedure (without saving)?"); Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, true); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index d4d80c9b1..3f161ad28 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -247,7 +247,7 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g { gboolean handled = FALSE; - if ( (event->button == 3) && (event->type == GDK_BUTTON_PRESS) ) { + if ( event && (event->button == 3) && (event->type == GDK_BUTTON_PRESS) ) { SwatchesPanel* swp = findContainingPanel( widget ); if ( !popupMenu ) { @@ -309,8 +309,8 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g gtk_widget_show_all(popupMenu); } - ColorItem* item = reinterpret_cast<ColorItem*>(user_data); - if ( item ) { + if ( user_data ) { + ColorItem* item = reinterpret_cast<ColorItem*>(user_data); bool show = swp && (swp->getSelectedIndex() == 0); for ( std::vector<GtkWidget*>::iterator it = popupExtras.begin(); it != popupExtras.end(); ++ it) { gtk_widget_set_sensitive(*it, show); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 6427eb9cc..fb353fec1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -271,6 +271,10 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::mem_fun(*this, &SymbolsDialog::selectionChanged)); instanceConns.push_back(selectionChangedConn); + sigc::connection documentReplacedConn = currentDesktop->connectDocumentReplaced( + sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); + instanceConns.push_back(documentReplacedConn); + get_symbols(); draw_symbols( currentDocument ); /* Defaults to current document */ @@ -378,6 +382,11 @@ void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { } } +void SymbolsDialog::documentReplaced(SPDesktop */*desktop*/, SPDocument */*document*/) +{ + rebuild(); +} + SPDocument* SymbolsDialog::selectedSymbols() { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ Glib::ustring symbolSetString = symbolSet->get_active_text(); diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 54b1a3ab0..074af6764 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -72,6 +72,7 @@ private: void revertSymbol(); void defsModified(SPObject *object, guint flags); void selectionChanged(Inkscape::Selection *selection); + void documentReplaced(SPDesktop *desktop, SPDocument *document); SPDocument* selectedSymbols(); Glib::ustring selectedSymbolId(); void iconChanged(); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 8e33cf503..057eff337 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -9,7 +9,6 @@ */ #include "template-widget.h" - #include "template-load-tab.h" #include <gtkmm/messagedialog.h> @@ -83,6 +82,11 @@ void TemplateLoadTab::createTemplate() } +void TemplateLoadTab::_onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*) +{ + _info_widget->create(); +} + void TemplateLoadTab::_displayTemplateInfo() { Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = _tlist_view.get_selection(); @@ -119,9 +123,11 @@ void TemplateLoadTab::_initLists() _tlist_view.get_selection(); templateSelectionRef->signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _tlist_view.signal_row_activated().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_onRowActivated)); } - void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 744a2a9fb..920ae6ca2 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -101,6 +101,8 @@ private: void _getTemplatesFromDir(const std::string &); void _keywordSelected(); TemplateData _processTemplateFile(const std::string &); + + void _onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*); }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 898903f2b..d1697244e 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -53,7 +53,7 @@ TemplateWidget::TemplateWidget() pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); - _more_info_button.signal_pressed().connect( + _more_info_button.signal_clicked().connect( sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); } diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 9124681a0..17c29c69f 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -94,10 +94,10 @@ TextEdit::TextEdit() fontsel_hbox.pack_start(*Gtk::manage(Glib::wrap(fontsel)), true, true); /* Align buttons */ - styleButton(&align_left, _("Align left"), GTK_STOCK_JUSTIFY_LEFT, NULL); - styleButton(&align_center, _("Align center"), GTK_STOCK_JUSTIFY_CENTER, &align_left); - styleButton(&align_right, _("Align right"), GTK_STOCK_JUSTIFY_RIGHT, &align_left); - styleButton(&align_justify, _("Justify (only flowed text)"), GTK_STOCK_JUSTIFY_FILL, &align_left); + styleButton(&align_left, _("Align left"), INKSCAPE_ICON("format-justify-left"), NULL); + styleButton(&align_center, _("Align center"), INKSCAPE_ICON("format-justify-center"), &align_left); + styleButton(&align_right, _("Align right"), INKSCAPE_ICON("format-justify-right"), &align_left); + styleButton(&align_justify, _("Justify (only flowed text)"), INKSCAPE_ICON("format-justify-fill"), &align_left); #if WITH_GTKMM_3_0 align_sep.set_orientation(Gtk::ORIENTATION_VERTICAL); @@ -237,7 +237,7 @@ void TextEdit::styleButton(Gtk::RadioButton *button, gchar const *tooltip, gchar { GtkWidget *icon = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, icon_name ); if (!GTK_IS_IMAGE(icon)) { - icon = gtk_image_new_from_stock ( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR ); + icon = gtk_image_new_from_icon_name ( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR ); } if (group_button) { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index ce8af3f1f..a7f0b068e 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -813,7 +813,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double scaleY = _scalar_scale_vertical.getValue("px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; + bool transform_stroke = prefs->getBool("/options/transform/stroke", true); + bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); @@ -835,7 +836,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; - Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); item->set_i2d_affine(item->i2dt_affine() * scaler); item->doWriteTransform(item->getRepr(), item->transform); } @@ -858,7 +859,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double y0 = bbox_pref->midpoint()[Geom::Y] - new_height/2; double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; - Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); sp_selection_apply_affine(selection, scaler); } diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 519c4ac6a..1c683f717 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -339,23 +339,27 @@ void MultiPathManipulator::setSegmentType(SegmentType type) void MultiPathManipulator::insertNodes() { + if (_selection.empty()) return; invokeForAll(&PathManipulator::insertNodes); _done(_("Add nodes")); } void MultiPathManipulator::insertNodesAtExtrema(ExtremumType extremum) { + if (_selection.empty()) return; invokeForAll(&PathManipulator::insertNodeAtExtremum, extremum); _done(_("Add extremum nodes")); } void MultiPathManipulator::duplicateNodes() { + if (_selection.empty()) return; invokeForAll(&PathManipulator::duplicateNodes); _done(_("Duplicate nodes")); } void MultiPathManipulator::joinNodes() { + if (_selection.empty()) return; invokeForAll(&PathManipulator::hideDragPoint); // Node join has two parts. In the first one we join two subpaths by fusing endpoints // into one. In the second we fuse nodes in each subpath. @@ -433,6 +437,7 @@ void MultiPathManipulator::deleteNodes(bool keep_shape) /** Join selected endpoints to create segments. */ void MultiPathManipulator::joinSegments() { + if (_selection.empty()) return; IterPairList joins; find_join_iterators(_selection, joins); @@ -465,6 +470,7 @@ void MultiPathManipulator::deleteSegments() void MultiPathManipulator::alignNodes(Geom::Dim2 d) { + if (_selection.empty()) return; _selection.align(d); if (d == Geom::X) { _done("Align nodes to a horizontal line"); @@ -475,6 +481,7 @@ void MultiPathManipulator::alignNodes(Geom::Dim2 d) void MultiPathManipulator::distributeNodes(Geom::Dim2 d) { + if (_selection.empty()) return; _selection.distribute(d); if (d == Geom::X) { _done("Distrubute nodes horizontally"); @@ -496,6 +503,7 @@ void MultiPathManipulator::reverseSubpaths() void MultiPathManipulator::move(Geom::Point const &delta) { + if (_selection.empty()) return; _selection.transform(Geom::Translate(delta)); _done("Move nodes"); } @@ -729,7 +737,7 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G case GDK_KEY_u: case GDK_KEY_U: if (held_only_shift(event->key)) { - // Shift+L - make segments curves + // Shift+U - make segments curves setSegmentType(SEGMENT_CUBIC_BEZIER); return true; } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f21e1661a..7d5c9bf0c 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -450,7 +450,7 @@ protected: virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) const { return format_tip(C_("Transform handle tip", "Rotate by %.2f°"), - _last_angle * 360.0); + _last_angle * 180.0 / M_PI); } virtual bool _hasDragTips() const { return true; } diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 80cc75e79..2e345fef1 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -515,7 +515,7 @@ bool Box3dTool::root_handler(GdkEvent* event) { return ret; } -void Box3dTool::drag(guint state) { +void Box3dTool::drag(guint /*state*/) { if (!this->box3d) { if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return; diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 8a950b528..7e33b1a4c 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -625,7 +625,7 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { } } -void NodeTool::select_point(Geom::Point const &sel, GdkEventButton *event) { +void NodeTool::select_point(Geom::Point const &/*sel*/, GdkEventButton *event) { using namespace Inkscape::UI; // pull in event helpers if (!event) { diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 26e47abbb..55683871d 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -148,7 +148,7 @@ struct EditWidgetInterface virtual bool showInfoDialog( Glib::ustring const &message ) = 0; /// Open yes/no dialog with warning text and confirmation question. - virtual bool warnDialog (gchar*) = 0; + virtual bool warnDialog (Glib::ustring const &) = 0; virtual Inkscape::UI::Widget::Dock* getDock () = 0; }; diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index f9f9a3807..d99646a64 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -174,6 +174,13 @@ gimp_spin_scale_init (GimpSpinScale *scale) { GimpSpinScalePrivate *private = GET_PRIVATE (scale); + gtk_widget_add_events (GTK_WIDGET (scale), + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_LEAVE_NOTIFY_MASK); + gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE); @@ -218,26 +225,20 @@ gimp_spin_scale_set_property (GObject *object, GParamSpec *pspec) { GimpSpinScalePrivate *private = GET_PRIVATE (object); + GimpSpinScale *scale = GIMP_SPIN_SCALE (object); switch (property_id) { case PROP_LABEL: - g_free (private->label); - private->label = g_value_dup_string (value); - if (private->layout) - { - g_object_unref (private->layout); - private->layout = NULL; - } - gtk_widget_queue_resize (GTK_WIDGET (object)); + gimp_spin_scale_set_label (scale, g_value_get_string (value)); break; case PROP_FOCUS_WIDGET: - { + { /* TODO unhook prior */ - private->focusWidget = (GtkWidget*)g_value_get_pointer( value ); - } - break; + private->focusWidget = GTK_WIDGET (g_value_get_pointer (value)); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -252,16 +253,17 @@ gimp_spin_scale_get_property (GObject *object, GParamSpec *pspec) { GimpSpinScalePrivate *private = GET_PRIVATE (object); + GimpSpinScale *scale = GIMP_SPIN_SCALE (object); switch (property_id) { case PROP_LABEL: - g_value_set_string (value, private->label); + g_value_set_string (value, gimp_spin_scale_get_label (scale)); break; case PROP_FOCUS_WIDGET: - g_value_set_pointer( value, private->focusWidget ); - break; + g_value_set_pointer (value, private->focusWidget); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -292,47 +294,24 @@ gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance) } } +#if GTK_CHECK_VERSION(3,0,0) static void -#if WITH_GTKMM_3_0 gimp_spin_scale_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) -#else -gimp_spin_scale_size_request (GtkWidget *widget, - GtkRequisition *requisition) -#endif { GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkStyle *style = gtk_widget_get_style (widget); PangoContext *context = gtk_widget_get_pango_context (widget); PangoFontMetrics *metrics; -#if WITH_GTKMM_3_0 GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, - minimum_width, - natural_width); -#else - gint height; - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); -#endif + minimum_width, + natural_width); - metrics = pango_context_get_metrics (context, style->font_desc, + metrics = pango_context_get_metrics (context, + pango_context_get_font_description (context), pango_context_get_language (context)); -#if WITH_GTKMM_3_0 -#else - height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + - pango_font_metrics_get_descent (metrics)); - - if (private->appearanceMode == APPEARANCE_COMPACT) { - requisition->height += 1; - } else { - requisition->height += height; - } - -#endif - - if (private->label) { gint char_width; @@ -343,26 +322,19 @@ gimp_spin_scale_size_request (GtkWidget *widget, digit_width = pango_font_metrics_get_approximate_digit_width (metrics); char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); -#if WITH_GTKMM_3_0 + /* ~3 chars for the ellipse */ *minimum_width += char_pixels * 3; *natural_width += char_pixels * 3; -#else - /* ~3 chars for the ellipses */ - requisition->width += char_pixels * 3; -#endif - } pango_font_metrics_unref (metrics); } -#if WITH_GTKMM_3_0 static void gimp_spin_scale_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { - GtkStyle *style = gtk_widget_get_style (widget); PangoContext *context = gtk_widget_get_pango_context (widget); PangoFontMetrics *metrics; //gint height; @@ -371,7 +343,8 @@ gimp_spin_scale_get_preferred_height (GtkWidget *widget, minimum_height, natural_height); - metrics = pango_context_get_metrics (context, style->font_desc, + metrics = pango_context_get_metrics (context, + pango_context_get_font_description (context), pango_context_get_language (context)); //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + @@ -382,6 +355,47 @@ gimp_spin_scale_get_preferred_height (GtkWidget *widget, pango_font_metrics_unref (metrics); } +#else +static void +gimp_spin_scale_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + GtkStyle *style = gtk_widget_get_style (widget); + PangoContext *context = gtk_widget_get_pango_context (widget); + PangoFontMetrics *metrics; + gint height; + + GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + + metrics = pango_context_get_metrics (context, style->font_desc, + pango_context_get_language (context)); + + height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + + pango_font_metrics_get_descent (metrics)); + + if (private->appearanceMode == APPEARANCE_COMPACT) { + requisition->height += 1; + } else { + requisition->height += height; + } + + if (private->label) + { + gint char_width; + gint digit_width; + gint char_pixels; + + char_width = pango_font_metrics_get_approximate_char_width (metrics); + digit_width = pango_font_metrics_get_approximate_digit_width (metrics); + char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); + + /* ~3 chars for the ellipses */ + requisition->width += char_pixels * 3; + } + + pango_font_metrics_unref (metrics); +} #endif static void @@ -401,67 +415,81 @@ gimp_spin_scale_style_set (GtkWidget *widget, static gboolean - -#if WITH_GTKMM_3_0 - gimp_spin_scale_draw (GtkWidget *widget, cairo_t *cr) +#if GTK_CHECK_VERSION(3,0,0) + gimp_spin_scale_draw (GtkWidget *widget, + cairo_t *cr) #else - gimp_spin_scale_expose (GtkWidget *widget, GdkEventExpose *event) + gimp_spin_scale_expose (GtkWidget *widget, + GdkEventExpose *event) #endif { - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - -#if WITH_GTKMM_3_0 - GtkStyleContext *style = gtk_widget_get_style_context(widget); - GtkAllocation allocation; - GdkRGBA color; + GimpSpinScalePrivate *private = GET_PRIVATE (widget); +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *style = gtk_widget_get_style_context(widget); + GtkAllocation allocation; + GdkRGBA color; - cairo_save (cr); - GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); - cairo_restore (cr); + cairo_save (cr); + GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); + cairo_restore (cr); - gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation (widget, &allocation); #else - GtkStyle *style = gtk_widget_get_style (widget); - cairo_t *cr; - gint w; + GtkStyle *style = gtk_widget_get_style (widget); + cairo_t *cr; + gint w; - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - cr = gdk_cairo_create (event->window); - gdk_cairo_region (cr, event->region); - cairo_clip (cr); + cr = gdk_cairo_create (event->window); + gdk_cairo_region (cr, event->region); + cairo_clip (cr); - w = gdk_window_get_width (event->window); + w = gdk_window_get_width (event->window); #endif - cairo_set_line_width (cr, 1.0); + cairo_set_line_width (cr, 1.0); - -#if WITH_GTKMM_3_0 - if (private->label) - { - GdkRectangle text_area; - gint minimum_width; - gint natural_width; +#if GTK_CHECK_VERSION(3,0,0) + if (private->label) + { + GdkRectangle text_area; + gint minimum_width; + gint natural_width; #else - if (private->label && - gtk_widget_is_drawable (widget) && - event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) - { - GtkRequisition requisition; - GtkAllocation allocation; + if (private->label && + gtk_widget_is_drawable (widget) && + event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) + { + GtkRequisition requisition; + GtkAllocation allocation; #endif - PangoRectangle logical; gint layout_offset_x; gint layout_offset_y; +#if GTK_CHECK_VERSION(3,0,0) + GtkStateFlags state; + GdkRGBA text_color; + GdkRGBA bar_text_color; +#else + GtkStateType state; + GdkColor text_color; + GdkColor bar_text_color; + gint window_width; + gint window_height; +#endif + gdouble progress_fraction; + gint progress_x; + gint progress_y; + gint progress_width; + gint progress_height; -#if WITH_GTKMM_3_0 +#if GTK_CHECK_VERSION(3,0,0) gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, - &minimum_width, - &natural_width); + &minimum_width, + &natural_width); #else GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition); gtk_widget_get_allocation (widget, &allocation); @@ -476,17 +504,17 @@ static gboolean pango_layout_set_width (private->layout, PANGO_SCALE * -#if WITH_GTKMM_3_0 - (allocation.width - minimum_width + 10)); +#if GTK_CHECK_VERSION(3,0,0) + (allocation.width - minimum_width)); #else - (allocation.width - requisition.width + 10)); + (allocation.width - requisition.width)); #endif pango_layout_get_pixel_extents (private->layout, NULL, &logical); gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) -#if WITH_GTKMM_3_0 +#if GTK_CHECK_VERSION(3,0,0) layout_offset_x = text_area.x + text_area.width - logical.width - 4; #else layout_offset_x = w - logical.width - 4; @@ -496,25 +524,97 @@ static gboolean layout_offset_x -= logical.x; -#if WITH_GTKMM_3_0 +#if GTK_CHECK_VERSION(3,0,0) + state = gtk_widget_get_state_flags (widget); + + gtk_style_context_get_color (style, state, &text_color); + + gtk_style_context_save (style); + gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR); + gtk_style_context_get_color (style, state, &bar_text_color); + gtk_style_context_restore (style); +#else + state = GTK_STATE_SELECTED; + if (! gtk_widget_get_sensitive (widget)) + state = GTK_STATE_INSENSITIVE; + text_color = style->text[gtk_widget_get_state (widget)]; + bar_text_color = style->fg[state]; + + window_width = gdk_window_get_width (event->window); + window_height = gdk_window_get_height (event->window); +#endif + + progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget)); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + progress_fraction = 1.0 - progress_fraction; + +#if GTK_CHECK_VERSION(3,0,0) + progress_x = text_area.width * progress_fraction; +#else + progress_x = window_width * progress_fraction; +#endif + progress_y = 0; +#if GTK_CHECK_VERSION(3,0,0) + progress_width = text_area.width - progress_x; + progress_height = text_area.height; +#else + progress_width = window_width - progress_x; + progress_height = window_height; +#endif + } + else + { + progress_x = 0; + progress_y = 0; +#if GTK_CHECK_VERSION(3,0,0) + progress_width = text_area.width * progress_fraction; + progress_height = text_area.height; +#else + progress_width = window_width * progress_fraction; + progress_height = window_height; +#endif + } + + cairo_save (cr); + + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); +#if GTK_CHECK_VERSION(3,0,0) + cairo_rectangle (cr, 0, 0, text_area.width, text_area.height); +#else + cairo_rectangle (cr, 0, 0, window_width, window_height); +#endif + cairo_rectangle (cr, progress_x, progress_y, + progress_width, progress_height); + cairo_clip (cr); + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); + +#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); - - gtk_style_context_get_color (style, gtk_widget_get_state_flags (widget), - &color); - - gdk_cairo_set_source_rgba (cr, &color); + gdk_cairo_set_source_rgba (cr, &text_color); #else cairo_move_to (cr, layout_offset_x, layout_offset_y-3); - - gdk_cairo_set_source_color (cr, - &style->text[gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &text_color); #endif + pango_cairo_show_layout (cr, private->layout); + cairo_restore (cr); + + cairo_rectangle (cr, progress_x, progress_y, + progress_width, progress_height); + cairo_clip (cr); +#if GTK_CHECK_VERSION(3,0,0) + cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); + gdk_cairo_set_source_rgba (cr, &bar_text_color); +#else + cairo_move_to (cr, layout_offset_x, layout_offset_y-3); + gdk_cairo_set_source_color (cr, &bar_text_color); +#endif pango_cairo_show_layout (cr, private->layout); } -#if WITH_GTKMM_3_0 -#else +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); #endif @@ -845,6 +945,9 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, GdkEventMotion *event) { GimpSpinScalePrivate *private = GET_PRIVATE (widget); + + gdk_event_request_motions (event); + #if WITH_GTKMM_3_0 gint x, y; @@ -973,7 +1076,6 @@ gimp_spin_scale_value_changed (GtkSpinButton *spin_button) value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper); - gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button), pow ((value - lower) / (upper - lower), 1.0 / private->gamma)); @@ -1003,6 +1105,41 @@ gimp_spin_scale_new (GtkAdjustment *adjustment, } void +gimp_spin_scale_set_label (GimpSpinScale *scale, + const gchar *label) +{ + GimpSpinScalePrivate *private; + + g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); + + private = GET_PRIVATE (scale); + + if (label == private->label) + return; + + g_free (private->label); + private->label = g_strdup (label); + + if (private->layout) + { + g_object_unref (private->layout); + private->layout = NULL; + } + + gtk_widget_queue_resize (GTK_WIDGET (scale)); + + g_object_notify (G_OBJECT (scale), "label"); +} + +const gchar * +gimp_spin_scale_get_label (GimpSpinScale *scale) +{ + g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL); + + return GET_PRIVATE (scale)->label; +} + +void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, gdouble lower, gdouble upper) @@ -1029,33 +1166,6 @@ gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, } void -gimp_spin_scale_set_gamma (GimpSpinScale *scale, - gdouble gamma) -{ - GimpSpinScalePrivate *private; - - g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); - - private = GET_PRIVATE (scale); - - private->gamma = gamma; - - gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); -} - -gdouble -gimp_spin_scale_get_gamma (GimpSpinScale *scale) -{ - GimpSpinScalePrivate *private; - - g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); - - private = GET_PRIVATE (scale); - - return private->gamma; -} - -void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale) { GimpSpinScalePrivate *private; @@ -1090,3 +1200,26 @@ gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, return private->scale_limits_set; } + +void +gimp_spin_scale_set_gamma (GimpSpinScale *scale, + gdouble gamma) +{ + GimpSpinScalePrivate *private; + + g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); + + private = GET_PRIVATE (scale); + + private->gamma = gamma; + + gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); +} + +gdouble +gimp_spin_scale_get_gamma (GimpSpinScale *scale) +{ + g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); + + return GET_PRIVATE(scale)->gamma; +} diff --git a/src/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h index ad63625ac..b42a0faf8 100644 --- a/src/ui/widget/gimpspinscale.h +++ b/src/ui/widget/gimpspinscale.h @@ -49,27 +49,33 @@ struct _GimpSpinScaleClass }; -GType gimp_spin_scale_get_type (void) G_GNUC_CONST; +GType gimp_spin_scale_get_type (void) G_GNUC_CONST; -GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment, - const gchar *label, - gint digits); +GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment, + const gchar *label, + gint digits); -void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, - gdouble lower, - gdouble upper); -void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale); -gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, - gdouble *lower, - gdouble *upper); +void gimp_spin_scale_set_label (GimpSpinScale *scale, + const gchar *label); +const gchar * gimp_spin_scale_get_label (GimpSpinScale *scale); -void gimp_spin_scale_set_gamma (GimpSpinScale *scale, - gdouble gamma); -gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale); +void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, + gdouble lower, + gdouble upper); +void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale); +gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, + gdouble *lower, + gdouble *upper); -void gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget ); +void gimp_spin_scale_set_gamma (GimpSpinScale *scale, + gdouble gamma); +gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale); -void gimp_spin_scale_set_appearance( GtkWidget *scale, const gchar *appearance); +void gimp_spin_scale_set_focuswidget (GtkWidget *scale, + GtkWidget *widget); + +void gimp_spin_scale_set_appearance (GtkWidget *scale, + const gchar *appearance); G_END_DECLS diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index aa617353c..d29554c41 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -107,7 +107,7 @@ typedef enum { // pointers/types used need to be read-only. So until we correct the using // code, those warnings are actually desired. They say "Hey! Fix this". We // definitely don't want to hide/ignore them. --JonCruz -static GtkTargetEntry ui_drop_target_entries [] = { +static const GtkTargetEntry ui_drop_target_entries [] = { {"application/x-color", 0, APP_X_COLOR} }; diff --git a/src/verbs.cpp b/src/verbs.cpp index 329e63115..8b333383f 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2353,19 +2353,19 @@ Verb *Verb::_base_verbs[] = { // File new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"), - GTK_STOCK_NEW ), + INKSCAPE_ICON("document-new")), new FileVerb(SP_VERB_FILE_OPEN, "FileOpen", N_("_Open..."), - N_("Open an existing document"), GTK_STOCK_OPEN ), + N_("Open an existing document"), INKSCAPE_ICON("document-open")), new FileVerb(SP_VERB_FILE_REVERT, "FileRevert", N_("Re_vert"), - N_("Revert to the last saved version of document (changes will be lost)"), GTK_STOCK_REVERT_TO_SAVED ), + N_("Revert to the last saved version of document (changes will be lost)"), INKSCAPE_ICON("document-revert")), new FileVerb(SP_VERB_FILE_SAVE, "FileSave", N_("_Save"), N_("Save document"), - GTK_STOCK_SAVE ), + INKSCAPE_ICON("document-save")), new FileVerb(SP_VERB_FILE_SAVE_AS, "FileSaveAs", N_("Save _As..."), - N_("Save document under a new name"), GTK_STOCK_SAVE_AS ), + N_("Save document under a new name"), INKSCAPE_ICON("document-save-as")), new FileVerb(SP_VERB_FILE_SAVE_A_COPY, "FileSaveACopy", N_("Save a Cop_y..."), N_("Save a copy of the document under a new name"), NULL ), new FileVerb(SP_VERB_FILE_PRINT, "FilePrint", N_("_Print..."), N_("Print document"), - GTK_STOCK_PRINT ), + INKSCAPE_ICON("document-print")), // TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions) new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Clean _up document"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"), INKSCAPE_ICON("document-cleanup") ), @@ -2381,22 +2381,22 @@ Verb *Verb::_base_verbs[] = { new FileVerb(SP_VERB_FILE_PREV_DESKTOP, "PrevWindow", N_("P_revious Window"), N_("Switch to the previous document window"), INKSCAPE_ICON("window-previous")), new FileVerb(SP_VERB_FILE_CLOSE_VIEW, "FileClose", N_("_Close"), - N_("Close this document window"), GTK_STOCK_CLOSE), - new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), GTK_STOCK_QUIT), + N_("Close this document window"), INKSCAPE_ICON("window-close")), + new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), INKSCAPE_ICON("application-exit")), new FileVerb(SP_VERB_FILE_TEMPLATES, "FileTemplates", N_("_Templates..."), N_("Create new project from template"), INKSCAPE_ICON("dialog-templates")), // Edit new EditVerb(SP_VERB_EDIT_UNDO, "EditUndo", N_("_Undo"), N_("Undo last action"), - GTK_STOCK_UNDO), + INKSCAPE_ICON("edit-undo")), new EditVerb(SP_VERB_EDIT_REDO, "EditRedo", N_("_Redo"), - N_("Do again the last undone action"), GTK_STOCK_REDO), + N_("Do again the last undone action"), INKSCAPE_ICON("edit-redo")), new EditVerb(SP_VERB_EDIT_CUT, "EditCut", N_("Cu_t"), - N_("Cut selection to clipboard"), GTK_STOCK_CUT), + N_("Cut selection to clipboard"), INKSCAPE_ICON("edit-cut")), new EditVerb(SP_VERB_EDIT_COPY, "EditCopy", N_("_Copy"), - N_("Copy selection to clipboard"), GTK_STOCK_COPY), + N_("Copy selection to clipboard"), INKSCAPE_ICON("edit-copy")), new EditVerb(SP_VERB_EDIT_PASTE, "EditPaste", N_("_Paste"), - N_("Paste objects from clipboard to mouse point, or paste text"), GTK_STOCK_PASTE), + N_("Paste objects from clipboard to mouse point, or paste text"), INKSCAPE_ICON("edit-paste")), new EditVerb(SP_VERB_EDIT_PASTE_STYLE, "EditPasteStyle", N_("Paste _Style"), N_("Apply the style of the copied object to selection"), INKSCAPE_ICON("edit-paste-style")), new EditVerb(SP_VERB_EDIT_PASTE_SIZE, "EditPasteSize", N_("Paste Si_ze"), @@ -2420,7 +2420,7 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_REMOVE_FILTER, "RemoveFilter", N_("_Remove Filters"), N_("Remove any filters from selected objects"), NULL), new EditVerb(SP_VERB_EDIT_DELETE, "EditDelete", N_("_Delete"), - N_("Delete selection"), GTK_STOCK_DELETE), + N_("Delete selection"), INKSCAPE_ICON("edit-delete")), new EditVerb(SP_VERB_EDIT_DUPLICATE, "EditDuplicate", N_("Duplic_ate"), N_("Duplicate selected objects"), INKSCAPE_ICON("edit-duplicate")), new EditVerb(SP_VERB_EDIT_CLONE, "EditClone", N_("Create Clo_ne"), @@ -2448,19 +2448,19 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_CLEAR_ALL, "EditClearAll", N_("Clea_r All"), N_("Delete all objects from document"), NULL), new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"), - N_("Select all objects or all nodes"), GTK_STOCK_SELECT_ALL), + N_("Select all objects or all nodes"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"), N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON("edit-select-all-layers")), new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, "EditSelectSameFillStroke", N_("Fill _and Stroke"), - N_("Select all objects with the same fill and stroke as the selected objects"), GTK_STOCK_SELECT_ALL), + N_("Select all objects with the same fill and stroke as the selected objects"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_COLOR, "EditSelectSameFillColor", N_("_Fill Color"), - N_("Select all objects with the same fill as the selected objects"), GTK_STOCK_SELECT_ALL), + N_("Select all objects with the same fill as the selected objects"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE_COLOR, "EditSelectSameStrokeColor", N_("_Stroke Color"), - N_("Select all objects with the same stroke as the selected objects"), GTK_STOCK_SELECT_ALL), + N_("Select all objects with the same stroke as the selected objects"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE_STYLE, "EditSelectSameStrokeStyle", N_("Stroke St_yle"), - N_("Select all objects with the same stroke style (width, dash, markers) as the selected objects"), GTK_STOCK_SELECT_ALL), + N_("Select all objects with the same stroke style (width, dash, markers) as the selected objects"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_SELECT_SAME_OBJECT_TYPE, "EditSelectSameObjectType", N_("_Object Type"), - N_("Select all objects with the same object type (rect, arc, text, path, bitmap etc) as the selected objects"), GTK_STOCK_SELECT_ALL), + N_("Select all objects with the same object type (rect, arc, text, path, bitmap etc) as the selected objects"), INKSCAPE_ICON("edit-select-all")), new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"), N_("Invert selection (unselect what is selected and select everything else)"), INKSCAPE_ICON("edit-select-invert")), new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"), @@ -2808,18 +2808,20 @@ Verb *Verb::_base_verbs[] = { // Dialogs new DialogVerb(SP_VERB_DIALOG_DISPLAY, "DialogPreferences", N_("P_references..."), - N_("Edit global Inkscape preferences"), GTK_STOCK_PREFERENCES ), + N_("Edit global Inkscape preferences"), INKSCAPE_ICON("preferences-system")), new DialogVerb(SP_VERB_DIALOG_NAMEDVIEW, "DialogDocumentProperties", N_("_Document Properties..."), - N_("Edit properties of this document (to be saved with the document)"), GTK_STOCK_PROPERTIES ), + N_("Edit properties of this document (to be saved with the document)"), INKSCAPE_ICON("document-properties")), new DialogVerb(SP_VERB_DIALOG_METADATA, "DialogMetadata", N_("Document _Metadata..."), N_("Edit document metadata (to be saved with the document)"), INKSCAPE_ICON("document-metadata") ), new DialogVerb(SP_VERB_DIALOG_FILL_STROKE, "DialogFillStroke", N_("_Fill and Stroke..."), N_("Edit objects' colors, gradients, arrowheads, and other fill and stroke properties..."), INKSCAPE_ICON("dialog-fill-and-stroke")), + // FIXME: Probably better to either use something from the icon naming spec or ship our own "select-font" icon new DialogVerb(SP_VERB_DIALOG_GLYPHS, "DialogGlyphs", N_("Gl_yphs..."), - N_("Select characters from a glyphs palette"), GTK_STOCK_SELECT_FONT), + N_("Select characters from a glyphs palette"), INKSCAPE_ICON("gtk-select-font")), + // FIXME: Probably better to either use something from the icon naming spec or ship our own "select-color" icon // TRANSLATORS: "Swatches" means: color samples new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."), - N_("Select colors from a swatches palette"), GTK_STOCK_SELECT_COLOR), + N_("Select colors from a swatches palette"), INKSCAPE_ICON("gtk-select-color")), new DialogVerb(SP_VERB_DIALOG_SYMBOLS, "DialogSymbols", N_("S_ymbols..."), N_("Select symbol from a symbols palette"), INKSCAPE_ICON("symbols")), new DialogVerb(SP_VERB_DIALOG_TRANSFORM, "DialogTransform", N_("Transfor_m..."), @@ -2835,11 +2837,11 @@ Verb *Verb::_base_verbs[] = { new DialogVerb(SP_VERB_DIALOG_XML_EDITOR, "DialogXMLEditor", N_("_XML Editor..."), N_("View and edit the XML tree of the document"), INKSCAPE_ICON("dialog-xml-editor")), new DialogVerb(SP_VERB_DIALOG_FIND, "DialogFind", N_("_Find/Replace..."), - N_("Find objects in document"), GTK_STOCK_FIND ), + N_("Find objects in document"), INKSCAPE_ICON("edit-find")), new DialogVerb(SP_VERB_DIALOG_FINDREPLACE, "DialogFindReplace", N_("Find and _Replace Text..."), - N_("Find and replace text in document"), GTK_STOCK_FIND_AND_REPLACE ), + N_("Find and replace text in document"), INKSCAPE_ICON("edit-find-replace")), new DialogVerb(SP_VERB_DIALOG_SPELLCHECK, "DialogSpellcheck", N_("Check Spellin_g..."), - N_("Check spelling of text in document"), GTK_STOCK_SPELL_CHECK ), + N_("Check spelling of text in document"), INKSCAPE_ICON("tools-check-spelling")), new DialogVerb(SP_VERB_DIALOG_DEBUG, "DialogDebug", N_("_Messages..."), N_("View debug messages"), INKSCAPE_ICON("dialog-messages")), new DialogVerb(SP_VERB_DIALOG_TOGGLE, "DialogsToggle", N_("Show/Hide D_ialogs"), diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp index 9f08d3462..73484d1b5 100644 --- a/src/widgets/calligraphy-toolbar.cpp +++ b/src/widgets/calligraphy-toolbar.cpp @@ -638,7 +638,7 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "ProfileEditAction", _("Add/Edit Profile"), _("Add or edit calligraphic profile"), - GTK_STOCK_PROPERTIES, + INKSCAPE_ICON("document-properties"), Inkscape::ICON_SIZE_DECORATION ); g_object_set( inky, "short_label", _("Edit"), NULL ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_ddc_edit_profile), (GObject*)holder ); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 7e254cdcd..cf6a908b6 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -71,6 +71,7 @@ #include "verbs.h" #include <gtkmm/paned.h> +#include <gtkmm/messagedialog.h> #include <gtk/gtk.h> @@ -1123,8 +1124,8 @@ SPDesktopWidget::shutdown() gtk_widget_show(close_button); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), close_button, GTK_RESPONSE_NO); - gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_SAVE, GTK_RESPONSE_YES); + gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Save"), GTK_RESPONSE_YES); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES); gint response; @@ -1185,7 +1186,7 @@ SPDesktopWidget::shutdown() gtk_widget_show(save_button); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), close_button, GTK_RESPONSE_NO); - gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), save_button, GTK_RESPONSE_YES); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES); @@ -1397,24 +1398,14 @@ bool SPDesktopWidget::showInfoDialog( Glib::ustring const &message ) return result; } -bool -SPDesktopWidget::warnDialog (gchar* text) +bool SPDesktopWidget::warnDialog (Glib::ustring const &text) { - GtkWindow *w =GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(this))); - if (w) - { - GtkWidget *dialog = gtk_message_dialog_new( - w, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_YES_NO, - "%s", text); - gint response = gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - if (response == GTK_RESPONSE_YES) - return true; - } - return false; + Gtk::MessageDialog dialog (*window, text, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL); + gint response = dialog.run(); + if (response == Gtk::RESPONSE_OK) + return true; + else + return false; } void diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 58739cf3b..a77d56fc3 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -212,7 +212,7 @@ struct SPDesktopWidget { return _dtw->showInfoDialog( message ); } - virtual bool warnDialog (gchar* text) + virtual bool warnDialog (Glib::ustring const &text) { return _dtw->warnDialog (text); } virtual Inkscape::UI::Widget::Dock* getDock () @@ -232,7 +232,7 @@ struct SPDesktopWidget { void setWindowTransient (void *p, int transient_policy); void presentWindow(); bool showInfoDialog( Glib::ustring const &message ); - bool warnDialog (gchar *text); + bool warnDialog (Glib::ustring const &text); void setToolboxFocusTo (gchar const *); void setToolboxAdjustmentValue (gchar const * id, double value); void setToolboxSelectOneValue (gchar const * id, gint value); diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 5ac994509..871d1ee4c 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -36,6 +36,7 @@ #include "paint-selector.h" #include "style.h" #include "id-clash.h" +#include "ui/icon-names.h" enum { GRABBED, @@ -196,8 +197,13 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) //sel->nonsolid.push_back(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); +#if GTK_CHECK_VERSION(3,10,0) + sel->add = gtk_button_new_from_icon_name(INKSCAPE_ICON("list-add"), GTK_ICON_SIZE_SMALL_TOOLBAR); +#else sel->add = gtk_button_new (); - gtk_button_set_image(GTK_BUTTON(sel->add), gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); + GtkWidget *img = gtk_image_new_from_icon_name(INKSCAPE_ICON("list-add"), GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_button_set_image(GTK_BUTTON(sel->add), img); +#endif sel->nonsolid.push_back(sel->add); gtk_box_pack_start (GTK_BOX (hb), sel->add, FALSE, FALSE, 0); @@ -207,8 +213,14 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) gtk_button_set_relief(GTK_BUTTON(sel->add), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text( sel->add, _("Create a duplicate gradient")); + // FIXME: Probably better to either use something from the icon naming spec or ship our own "edit-gradient" icon +#if GTK_CHECK_VERSION(3,10,0) + sel->edit = gtk_button_new_from_icon_name(INKSCAPE_ICON("gtk-edit"), GTK_ICON_SIZE_SMALL_TOOLBAR); +#else sel->edit = gtk_button_new (); - gtk_button_set_image(GTK_BUTTON(sel->edit), gtk_image_new_from_stock ( GTK_STOCK_EDIT, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); + img = gtk_image_new_from_icon_name(INKSCAPE_ICON("gtk-edit"), GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_button_set_image(GTK_BUTTON(sel->edit), img); +#endif sel->nonsolid.push_back(sel->edit); gtk_box_pack_start (GTK_BOX (hb), sel->edit, FALSE, FALSE, 0); @@ -217,8 +229,13 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) gtk_button_set_relief(GTK_BUTTON(sel->edit), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text( sel->edit, _("Edit gradient")); +#if GTK_CHECK_VERSION(3,10,0) + sel->del = gtk_button_new_from_icon_name(INKSCAPE_ICON("list-remove"), GTK_ICON_SIZE_SMALL_TOOLBAR); +#else sel->del = gtk_button_new (); - gtk_button_set_image(GTK_BUTTON(sel->del), gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); + img = gtk_image_new_from_icon_name(INKSCAPE_ICON("list-remove"), GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_button_set_image(GTK_BUTTON(sel->del), img); +#endif sel->swatch_widgets.push_back(sel->del); gtk_box_pack_start (GTK_BOX (hb), sel->del, FALSE, FALSE, 0); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index f02185a15..8fa29e60a 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1156,7 +1156,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GtkTreeIter iter; gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_set(store, &iter, 0, _("No stops"), 1, NULL, 2, NULL, -1); EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientEditStopsAction", _("Stops"), _("Select a stop for the current gradient"), NULL, GTK_TREE_MODEL(store) ); g_object_set( act1, "short_label", _("Stops:"), NULL ); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index feb69cc64..768a835c9 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -45,6 +45,7 @@ #include "util/units.h" #include "icon.h" +#include "ui/icon-names.h" struct IconImpl { static GtkWidget *newFull( Inkscape::IconSize lsize, gchar const *name ); @@ -171,8 +172,8 @@ sp_icon_init(SPIcon *icon) gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE); icon->lsize = Inkscape::ICON_SIZE_BUTTON; icon->psize = 0; - icon->name = 0; - icon->pb = 0; + icon->name = NULL; + icon->pb = NULL; } void IconImpl::dispose(GObject *object) @@ -181,7 +182,7 @@ void IconImpl::dispose(GObject *object) clear(icon); if ( icon->name ) { g_free( icon->name ); - icon->name = 0; + icon->name = NULL; } (G_OBJECT_CLASS(sp_icon_parent_class))->dispose(object); @@ -324,7 +325,7 @@ void IconImpl::fetchPixbuf( SPIcon *icon ) GdkPixbuf* IconImpl::renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) { GtkIconTheme *theme = gtk_icon_theme_get_default(); - GdkPixbuf *pb = 0; + GdkPixbuf *pb = NULL; if (gtk_icon_theme_has_icon(theme, name)) { pb = gtk_icon_theme_load_icon(theme, name, psize, (GtkIconLookupFlags) 0, NULL); } @@ -451,13 +452,13 @@ void IconImpl::validateCache() std::string present; { - gchar *contents = 0; + gchar *contents = NULL; if ( g_file_get_contents(iconCacheFile.c_str(), &contents, 0, 0) ) { if ( contents ) { present = contents; } g_free(contents); - contents = 0; + contents = NULL; } } bool cacheValid = (present == wanted); @@ -783,53 +784,29 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) { static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); - GtkWidget *widget = 0; + GtkWidget *widget = NULL; gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) ); if ( !sizeMapDone ) { injectCustomSize(); } GtkIconSize mappedSize = iconSizeLookup[trySize]; - GtkStockItem stock; - gboolean stockFound = gtk_stock_lookup( name, &stock ); - - GtkWidget *img = 0; if ( legacyNames.empty() ) { setupLegacyNaming(); } - if ( stockFound ) { - img = gtk_image_new_from_stock( name, mappedSize ); - } else { - img = gtk_image_new_from_icon_name( name, mappedSize ); - if ( dump ) { - g_message("gtk_image_new_from_icon_name( '%s', %d ) = %p", name, mappedSize, img); - GtkImageType thing = gtk_image_get_storage_type(GTK_IMAGE(img)); - g_message(" Type is %d %s", (int)thing, (thing == GTK_IMAGE_EMPTY ? "Empty" : "ok")); - } + GtkWidget *img = gtk_image_new_from_icon_name( name, mappedSize ); + if ( dump ) { + g_message("gtk_image_new_from_icon_name( '%s', %d ) = %p", name, mappedSize, img); + GtkImageType thing = gtk_image_get_storage_type(GTK_IMAGE(img)); + g_message(" Type is %d %s", (int)thing, (thing == GTK_IMAGE_EMPTY ? "Empty" : "ok")); } if ( img ) { GtkImageType type = gtk_image_get_storage_type( GTK_IMAGE(img) ); - if ( type == GTK_IMAGE_STOCK ) { - if ( !stockFound ) { - // It's not showing as a stock ID, so assume it will be present internally - addPreRender( mappedSize, name ); - - // Add a hook to render if set visible before prerender is done. - g_signal_connect( G_OBJECT(img), "map", G_CALLBACK(imageMapCB), GINT_TO_POINTER(static_cast<int>(mappedSize)) ); - if ( dump ) { - g_message(" connecting %p for imageMapCB for [%s] %d", img, name, (int)mappedSize); - } - } - widget = GTK_WIDGET(img); - img = 0; - if ( dump ) { - g_message( "loaded gtk '%s' %d (GTK_IMAGE_STOCK) %s on %p", name, mappedSize, (stockFound ? "STOCK" : "local"), widget ); - } - } else if ( type == GTK_IMAGE_ICON_NAME ) { + if ( type == GTK_IMAGE_ICON_NAME ) { widget = GTK_WIDGET(img); - img = 0; + img = NULL; // Add a hook to render if set visible before prerender is done. g_signal_connect( G_OBJECT(widget), "map", G_CALLBACK(imageMapNamedCB), GINT_TO_POINTER(0) ); @@ -842,10 +819,10 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) } } else { if ( dump ) { - g_message( "skipped gtk '%s' %d (not GTK_IMAGE_STOCK)", name, lsize ); + g_message( "skipped gtk '%s' %d (not GTK_IMAGE_ICON_NAME)", name, lsize ); } //g_object_unref(G_OBJECT(img)); - img = 0; + img = NULL; } } @@ -878,7 +855,7 @@ GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize lsize, gchar const *name ) // PUBLIC CALL: Gtk::Widget *sp_icon_get_icon( Glib::ustring const &oid, Inkscape::IconSize size ) { - Gtk::Widget *result = 0; + Gtk::Widget *result = NULL; GtkWidget *widget = IconImpl::newFull( static_cast<Inkscape::IconSize>(Inkscape::getRegisteredIconSize(size)), oid.c_str() ); if ( widget ) { @@ -1033,7 +1010,7 @@ int IconImpl::getPhysSize(int size) // "The rendered pixbuf may not even correspond to the width/height returned by // gtk_icon_size_lookup(), because themes are free to render the pixbuf however // they like, including changing the usual size." - gchar const *id = GTK_STOCK_OPEN; + gchar const *id = INKSCAPE_ICON("document-open"); GdkPixbuf *pb = gtk_widget_render_icon( icon, id, gtkSizes[i], NULL); if (pb) { width = gdk_pixbuf_get_width(pb); @@ -1265,7 +1242,7 @@ Glib::ustring icon_cache_key(Glib::ustring const & name, unsigned psize) } GdkPixbuf *get_cached_pixbuf(Glib::ustring const &key) { - GdkPixbuf* pb = 0; + GdkPixbuf* pb = NULL; std::map<Glib::ustring, GdkPixbuf *>::iterator found = pb_cache.find(key); if ( found != pb_cache.end() ) { pb = found->second; @@ -1299,7 +1276,7 @@ guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names, guchar *px = NULL; for (std::list<gchar*>::iterator i = sources.begin(); (i != sources.end()) && !px; ++i) { gchar *doc_filename = *i; - SVGDocCache *info = 0; + SVGDocCache *info = NULL; // Did we already load this doc? Glib::ustring key(doc_filename); @@ -1334,9 +1311,9 @@ guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names, static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, unsigned psize) { static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); - GtkStockItem stock; - gboolean stockFound = gtk_stock_lookup( name, &stock ); - if ( !stockFound ) { + Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); + bool icon_found = icon_theme->has_icon(name); + if ( !icon_found ) { Gtk::IconTheme::add_builtin_icon( name, psize, Glib::wrap(pb) ); if (dump) { g_message(" set in a builtin for %s:%d:%d", name, lsize, psize); @@ -1346,10 +1323,8 @@ static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, un void Inkscape::queueIconPrerender( Glib::ustring const &name, Inkscape::IconSize lsize ) { - GtkStockItem stock; - gboolean stockFound = gtk_stock_lookup( name.c_str(), &stock ); gboolean themedFound = gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str()); - if (!stockFound && !themedFound ) { + if ( !themedFound ) { gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) ); if ( !sizeMapDone ) { IconImpl::injectCustomSize(); @@ -1615,9 +1590,9 @@ gboolean IconImpl::prerenderTask(gpointer /*data*/) { void IconImpl::imageMapCB(GtkWidget* widget, gpointer user_data) { - gchar* id = 0; + gchar const* id = NULL; GtkIconSize size = GTK_ICON_SIZE_INVALID; - gtk_image_get_stock(GTK_IMAGE(widget), &id, &size); + gtk_image_get_icon_name(GTK_IMAGE(widget), &id, &size); GtkIconSize lsize = static_cast<GtkIconSize>(GPOINTER_TO_INT(user_data)); if ( id ) { int psize = getPhysSize(lsize); @@ -1642,33 +1617,34 @@ void IconImpl::imageMapCB(GtkWidget* widget, gpointer user_data) void IconImpl::imageMapNamedCB(GtkWidget* widget, gpointer user_data) { GtkImage* img = GTK_IMAGE(widget); - gchar const* iconName = 0; + gchar const* iconName = NULL; GtkIconSize size = GTK_ICON_SIZE_INVALID; gtk_image_get_icon_name(img, &iconName, &size); if ( iconName ) { GtkImageType type = gtk_image_get_storage_type( GTK_IMAGE(img) ); if ( type == GTK_IMAGE_ICON_NAME ) { - gint iconSize = 0; - gchar* iconName = 0; + GtkIconSize iconSize = GTK_ICON_SIZE_INVALID; + gchar const* iconName_two = NULL; { g_object_get(G_OBJECT(widget), - "icon-name", &iconName, + "icon-name", &iconName_two, "icon-size", &iconSize, NULL); } for ( std::vector<preRenderItem>::iterator it = pendingRenders.begin(); it != pendingRenders.end(); ++it ) { - if ( (it->_name == iconName) && (it->_lsize == size) ) { - int psize = getPhysSize(size); - prerenderIcon(iconName, size, psize); + /// @todo fix pointer string comparison here!!! "it->_name == iconName_two", that seems very bug-prone + if ( (it->_name == iconName_two) && (it->_lsize == iconSize) ) { + int psize = getPhysSize(iconSize); + prerenderIcon(iconName_two, iconSize, psize); pendingRenders.erase(it); break; } } - gtk_image_set_from_icon_name(img, "", (GtkIconSize)iconSize); - gtk_image_set_from_icon_name(img, iconName, (GtkIconSize)iconSize); + gtk_image_set_from_icon_name(img, "", iconSize); + gtk_image_set_from_icon_name(img, iconName_two, iconSize); } else { g_warning("UNEXPECTED TYPE of %d", (int)type); } diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 6a0968424..a4ea52287 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -244,7 +244,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb Unit const *unit = tracker->getActiveUnit(); NodeTool *nt = get_node_tool(); - if (!nt || nt->_selected_nodes->empty()) { + if (!nt || !(nt->_selected_nodes) ||nt->_selected_nodes->empty()) { // no path selected gtk_action_set_sensitive(xact, FALSE); gtk_action_set_sensitive(yact, FALSE); diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp index 8c4de2b32..a9962b209 100644 --- a/src/widgets/paintbucket-toolbar.cpp +++ b/src/widgets/paintbucket-toolbar.cpp @@ -232,7 +232,7 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions GtkAction* act = gtk_action_new( "PaintbucketResetAction", _("Defaults"), _("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - GTK_STOCK_CLEAR ); + INKSCAPE_ICON("edit-clear")); g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(paintbucket_defaults), holder ); gtk_action_group_add_action( mainActions, act ); gtk_action_set_sensitive( act, TRUE ); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 8abf35fb3..f609a007b 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -323,7 +323,7 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkAction* inky = ink_action_new( "PencilResetAction", _("Defaults"), _("Reset pencil parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - GTK_STOCK_CLEAR, + INKSCAPE_ICON("edit-clear"), Inkscape::ICON_SIZE_SMALL_TOOLBAR ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_pencil_tb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 2604ebf22..5d5151343 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -269,11 +269,17 @@ sp_ruler_init (SPRuler *ruler) priv->font_scale = DEFAULT_RULER_FONT_SCALE; #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,8,0) + const gchar *str = + "SPRuler {\n" + " background-color: @theme_bg_color;\n" + "}\n"; + #else const gchar *str = "SPRuler {\n" " background-color: @bg_color;\n" "}\n"; - + #endif GtkCssProvider *css = gtk_css_provider_new (); gtk_css_provider_load_from_data (css, str, -1, NULL); gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (ruler)), diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 58d7134b3..1cd4347d6 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -249,17 +249,18 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed sp_desktop_canvas(desktop)->forceFullRedrawAfterInterruptions(0); - int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; + bool transform_stroke = prefs->getBool("/options/transform/stroke", true); + bool preserve = prefs->getBool("/options/preservetransform/value", false); Geom::Affine scaler; if (bbox_type == SPItem::VISUAL_BBOX) { - scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); + scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); } else { // 1) We could have use the newer get_scale_transform_for_variable_stroke() here, but to avoid regressions // we'll just use the old get_scale_transform_for_uniform_stroke() for now. // 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); + scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, 0, false, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 6b10bfce9..b95c1c41e 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -136,7 +136,7 @@ static void sp_spl_tb_defaults(GtkWidget * /*widget*/, GObject *obj) GtkAdjustment *adj; // fixme: make settable - gdouble rev = 5; + gdouble rev = 3; gdouble exp = 1.0; gdouble t0 = 0.0; @@ -299,7 +299,7 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkAction* inky = ink_action_new( "SpiralResetAction", _("Defaults"), _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - GTK_STOCK_CLEAR, + INKSCAPE_ICON("edit-clear"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_spl_tb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index bac0271db..1691a9b25 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -571,7 +571,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje GtkAction* act = gtk_action_new( "StarResetAction", _("Defaults"), _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - GTK_STOCK_CLEAR ); + INKSCAPE_ICON("edit-clear")); g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_stb_defaults), holder ); gtk_action_group_add_action( mainActions, act ); gtk_action_set_sensitive( act, TRUE ); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 750fa1de6..6d5d54871 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1348,7 +1348,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_list_store_set( model, &iter, 0, _("Align left"), 1, _("Align left"), - 2, GTK_STOCK_JUSTIFY_LEFT, + 2, INKSCAPE_ICON("format-justify-left"), 3, true, -1 ); @@ -1356,7 +1356,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_list_store_set( model, &iter, 0, _("Align center"), 1, _("Align center"), - 2, GTK_STOCK_JUSTIFY_CENTER, + 2, INKSCAPE_ICON("format-justify-center"), 3, true, -1 ); @@ -1364,7 +1364,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_list_store_set( model, &iter, 0, _("Align right"), 1, _("Align right"), - 2, GTK_STOCK_JUSTIFY_RIGHT, + 2, INKSCAPE_ICON("format-justify-right"), 3, true, -1 ); @@ -1372,14 +1372,14 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_list_store_set( model, &iter, 0, _("Justify"), 1, _("Justify (only flowed text)"), - 2, GTK_STOCK_JUSTIFY_FILL, + 2, INKSCAPE_ICON("format-justify-fill"), 3, false, -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "TextAlignAction", // Name _("Alignment"), // Label _("Text alignment"), // Tooltip - NULL, // StockID + NULL, // Icon name GTK_TREE_MODEL(model) ); // Model g_object_set( act, "short_label", "NotUsed", NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); @@ -1420,7 +1420,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name _("Orientation"), // Label _("Text orientation"), // Tooltip - NULL, // StockID + NULL, // Icon name GTK_TREE_MODEL(model) ); // Model g_object_set( act, "short_label", "NotUsed", NULL ); diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index c9e001d05..02c12dfb0 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -23,13 +23,15 @@ size_t xml_quoted_strlen(char const *val) { size_t ret = 0; - for (; *val != '\0'; val++) { - switch (*val) { - case '"': ret += sizeof(""") - 1; break; - case '&': ret += sizeof("&") - 1; break; - case '<': ret += sizeof("<") - 1; break; - case '>': ret += sizeof(">") - 1; break; - default: ++ret; break; + if (val != NULL) { + for (; *val != '\0'; val++) { + switch (*val) { + case '"': ret += sizeof(""") - 1; break; + case '&': ret += sizeof("&") - 1; break; + case '<': ret += sizeof("<") - 1; break; + case '>': ret += sizeof(">") - 1; break; + default: ++ret; break; + } } } return ret; |
