From 98bc928471d3bc96a9eed9b5b120b2dcd46324d9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 12 Mar 2014 18:55:15 +0100 Subject: Allow ungrouping switches (bzr r13136) --- src/selection-chemistry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index fad2dff5b..5a981c6a0 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -794,7 +794,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) GSList *groups = NULL; for (GSList *item = old_select; item; item = item->next) { SPItem *obj = static_cast(item->data); - if (SP_IS_GROUP(obj) && !SP_IS_SWITCH(obj)) { + if (SP_IS_GROUP(obj)) { groups = g_slist_prepend(groups, obj); } } -- cgit v1.2.3 From f4e088a3cb74021e0f6f61d6a7ca124f258ede6d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 12 Mar 2014 19:07:33 +0100 Subject: Do not transform render cache for transforms which are not integer translations - the entire cache was dirtied anyway in these cases. Fixes performance regression when zooming out. Fixed bugs: - https://launchpad.net/bugs/1288838 (bzr r13137) --- src/display/drawing-surface.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 30579134b..1e9c8e048 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -215,7 +215,7 @@ DrawingCache::prepare() bool is_identity = _pending_transform.isIdentity(); if (is_identity && _pending_area == old_area) return; // no change - bool is_integer_translation = false; + bool is_integer_translation = is_identity; if (!is_identity && _pending_transform.isTranslation()) { Geom::IntPoint t = _pending_transform.translation().round(); if (Geom::are_near(Geom::Point(t), _pending_transform.translation())) { @@ -224,6 +224,7 @@ DrawingCache::prepare() if (old_area + t == _pending_area) { // if the areas match, the only thing to do // is to ensure that the clean area is not too large + // we can exit early cairo_rectangle_int_t limit = _convertRect(_pending_area); cairo_region_intersect_rectangle(_clean_region, &limit); _origin += t; @@ -232,33 +233,35 @@ DrawingCache::prepare() } } } - // otherwise, we need to transform the cache + + // the area has changed, so the cache content needs to be copied Geom::IntPoint old_origin = old_area.min(); cairo_surface_t *old_surface = _surface; _surface = NULL; _pixels = _pending_area.dimensions(); _origin = _pending_area.min(); - cairo_t *ct = createRawContext(); - if (!is_identity) { - ink_cairo_transform(ct, _pending_transform); - } - cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - - cairo_surface_destroy(old_surface); - cairo_destroy(ct); + if (is_integer_translation) { + // transform the cache only for integer translations and identities + cairo_t *ct = createRawContext(); + if (!is_identity) { + ink_cairo_transform(ct, _pending_transform); + } + cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); - if (!is_identity && !is_integer_translation) { + cairo_rectangle_int_t limit = _convertRect(_pending_area); + cairo_region_intersect_rectangle(_clean_region, &limit); + } else { // dirty everything cairo_region_destroy(_clean_region); _clean_region = cairo_region_create(); - } else { - cairo_rectangle_int_t limit = _convertRect(_pending_area); - cairo_region_intersect_rectangle(_clean_region, &limit); } + //std::cout << _pending_transform << old_area << _pending_area << std::endl; + cairo_surface_destroy(old_surface); _pending_transform.setIdentity(); } -- cgit v1.2.3 From a7748056fd02ca684e479eecde601aac0f5e6de5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 12 Mar 2014 19:13:42 +0100 Subject: Use NEAREST filter when transforming cache (bzr r13138) --- src/display/drawing-surface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 1e9c8e048..d2540de66 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -249,6 +249,7 @@ DrawingCache::prepare() } cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]); cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_pattern_set_filter(cairo_get_source(ct), CAIRO_FILTER_NEAREST); cairo_paint(ct); cairo_destroy(ct); -- cgit v1.2.3 From 76be008fcda64acffe569af78f77a07b0d4ea593 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Wed, 12 Mar 2014 14:34:51 -0400 Subject: incorrect gradient transform on copy&paste.. committing for mathog Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13139) --- src/document.cpp | 3 ++- src/id-clash.cpp | 7 ++++--- src/sp-gradient.cpp | 19 +++++++++++++++++++ src/sp-gradient.h | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index d71fd97df..4756110f6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1552,7 +1552,8 @@ void SPDocument::importDefs(SPDocument *source) SPGradient *gr = SP_GRADIENT(src); for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { if (trg && SP_IS_GRADIENT(trg) && src != trg) { - if (gr->isEquivalent(SP_GRADIENT(trg))) { + if (gr->isEquivalent(SP_GRADIENT(trg)) && + gr->isAligned(SP_GRADIENT(trg))) { // Change object references to the existing equivalent gradient change_def_references(src, trg); duplicate = true; diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 76b8e6ff8..f59b3b920 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -215,9 +215,10 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, SPObject *cd_obj = current_doc->getObjectById(id); if (cd_obj && SP_IS_GRADIENT(cd_obj)) { - SPGradient *cd_gr = SP_GRADIENT(cd_obj); - if (cd_gr->isEquivalent(SP_GRADIENT(elem))) { - fix_clashing_ids = false; + SPGradient *cd_gr = SP_GRADIENT(cd_obj); + if ( cd_gr->isEquivalent(SP_GRADIENT(elem)) && + cd_gr->isAligned(SP_GRADIENT(elem))) { + fix_clashing_ids = false; } } } diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 04fb18cf3..e2ae98ec5 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -135,6 +135,25 @@ gboolean SPGradient::isEquivalent(SPGradient *that) return TRUE; } +/** + * return true if this gradient is "aligned" to that gradient. + * Aligned means that they have exactly the same transform. + * @param that - A gradient to compare this to + */ +gboolean SPGradient::isAligned(SPGradient *that) +{ + bool status = FALSE; + + while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function + if(this->gradientTransform_set != that->gradientTransform_set) { break; } + if(this->gradientTransform_set && + (this->gradientTransform != that->gradientTransform)) { break; } + status = TRUE; + break; + } + return status; +} + /* * Gradient diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 46eb41cdb..1dfff22ee 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -147,6 +147,7 @@ public: int getStopCount() const; gboolean isEquivalent(SPGradient *b); + gboolean isAligned(SPGradient *b); /** Mesh Gradients **************/ -- cgit v1.2.3 From da0a34bdba9070b53f02e09b74d70b822899f554 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 00:35:43 +0100 Subject: Disconnect before destroying URI (bzr r13140) --- src/uri-references.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 1da890c56..6db2ed21f 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -115,10 +115,10 @@ void URIReference::attach(const URI &uri) throw(BadURIException) /* FIXME !!! validate id as an NCName somewhere */ + _connection.disconnect(); delete _uri; _uri = new URI(uri); - _connection.disconnect(); _setObject(document->getObjectById(id)); _connection = document->connectIdChanged(id, sigc::mem_fun(*this, &URIReference::_setObject)); -- cgit v1.2.3 From 2d43266d790e7e0a1262fe9b22ce7c2897c2ab7a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 00:41:33 +0100 Subject: Remove redundant variable from SPFeImage (bzr r13141) --- src/filters/image.cpp | 7 ++----- src/filters/image.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 6e50a0e3c..116939e0f 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -42,7 +42,6 @@ namespace { } SPFeImage::SPFeImage() : SPFilterPrimitive() { - this->document = NULL; this->href = NULL; this->from_element = 0; this->SVGElemRef = NULL; @@ -60,10 +59,8 @@ SPFeImage::~SPFeImage() { * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void SPFeImage::build(SPDocument *document, Inkscape::XML::Node *repr) { - // Save document reference so we can load images with relative paths. - this->document = document; - +void SPFeImage::build(SPDocument *document, Inkscape::XML::Node *repr) +{ SPFilterPrimitive::build(document, repr); /*LOAD ATTRIBUTES FROM REPR HERE*/ diff --git a/src/filters/image.h b/src/filters/image.h index 452e08134..9299f259e 100644 --- a/src/filters/image.h +++ b/src/filters/image.h @@ -32,7 +32,6 @@ public: unsigned int aspect_align : 4; unsigned int aspect_clip : 1; - SPDocument *document; bool from_element; SPItem* SVGElem; Inkscape::URIReference* SVGElemRef; -- cgit v1.2.3 From b389a703003a324321822e6f0f991d7bbc4531e0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 01:11:43 +0100 Subject: pdfinput: Do not use an extremely ugly static variable in SvgBuilder (bzr r13142) --- src/extension/internal/pdfinput/svg-builder.cpp | 56 ++++++++++++------------- src/extension/internal/pdfinput/svg-builder.h | 2 + 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 20cd74cdb..680e6ca94 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -56,9 +56,6 @@ namespace Internal { #define TRACE(_args) IFTRACE(g_print _args) -static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix -static bool ttm_is_set = false; // flag to forbid setting ttm - /** * \struct SvgTransparencyGroup * \brief Holds information about a PDF transparency group @@ -94,6 +91,9 @@ SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) _preferences = _xml_doc->createElement("svgbuilder:prefs"); _preferences->setAttribute("embedImages", "1"); _preferences->setAttribute("localFonts", "1"); + + _ttm[0] = 1; _ttm[1] = 0; _ttm[2] = 0; _ttm[3] = 1; _ttm[4] = 0; _ttm[5] = 0; + _ttm_is_set = false; } SvgBuilder::SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root) { @@ -216,9 +216,9 @@ Inkscape::XML::Node *SvgBuilder::pushGroup() { } } if (_container->parent()->attribute("inkscape:groupmode") != NULL) { - ttm[0] = ttm[3] = 1.0; // clear ttm if parent is a layer - ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0; - ttm_is_set = false; + _ttm[0] = _ttm[3] = 1.0; // clear ttm if parent is a layer + _ttm[1] = _ttm[2] = _ttm[4] = _ttm[5] = 0.0; + _ttm_is_set = false; } return _container; } @@ -570,14 +570,14 @@ bool SvgBuilder::getTransform(double *transform) { void SvgBuilder::setTransform(double c0, double c1, double c2, double c3, double c4, double c5) { // do not remember the group which is a layer - if ((_container->attribute("inkscape:groupmode") == NULL) && !ttm_is_set) { - ttm[0] = c0; - ttm[1] = c1; - ttm[2] = c2; - ttm[3] = c3; - ttm[4] = c4; - ttm[5] = c5; - ttm_is_set = true; + if ((_container->attribute("inkscape:groupmode") == NULL) && !_ttm_is_set) { + _ttm[0] = c0; + _ttm[1] = c1; + _ttm[2] = c2; + _ttm[3] = c3; + _ttm[4] = c4; + _ttm[5] = c5; + _ttm_is_set = true; } // Avoid transforming a group with an already set clip-path @@ -633,15 +633,15 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_ // construct a (pattern space) -> (current space) transform matrix ptm = shading_pattern->getMatrix(); - det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; + det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; if (det) { double ittm[6]; // invert ttm - ittm[0] = ttm[3] / det; - ittm[1] = -ttm[1] / det; - ittm[2] = -ttm[2] / det; - ittm[3] = ttm[0] / det; - ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; - ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + ittm[0] = _ttm[3] / det; + ittm[1] = -_ttm[1] / det; + ittm[2] = -_ttm[2] / det; + ittm[3] = _ttm[0] / det; + ittm[4] = (_ttm[2] * _ttm[5] - _ttm[3] * _ttm[4]) / det; + ittm[5] = (_ttm[1] * _ttm[4] - _ttm[0] * _ttm[5]) / det; m[0] = ptm[0] * ittm[0] + ptm[1] * ittm[2]; m[1] = ptm[0] * ittm[1] + ptm[1] * ittm[3]; m[2] = ptm[2] * ittm[0] + ptm[3] * ittm[2]; @@ -676,15 +676,15 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, double *p2u = tiling_pattern->getMatrix(); double m[6] = {1, 0, 0, 1, 0, 0}; double det; - det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; // see LP Bug 1168908 + det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; // see LP Bug 1168908 if (det) { double ittm[6]; // invert ttm - ittm[0] = ttm[3] / det; - ittm[1] = -ttm[1] / det; - ittm[2] = -ttm[2] / det; - ittm[3] = ttm[0] / det; - ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; - ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + ittm[0] = _ttm[3] / det; + ittm[1] = -_ttm[1] / det; + ittm[2] = -_ttm[2] / det; + ittm[3] = _ttm[0] / det; + ittm[4] = (_ttm[2] * _ttm[5] - _ttm[3] * _ttm[4]) / det; + ittm[5] = (_ttm[1] * _ttm[4] - _ttm[0] * _ttm[5]) / det; m[0] = p2u[0] * ittm[0] + p2u[1] * ittm[2]; m[1] = p2u[0] * ittm[1] + p2u[1] * ittm[3]; m[2] = p2u[2] * ittm[0] + p2u[3] * ittm[2]; diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 610822959..f1ce02cf0 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -223,6 +223,8 @@ private: Inkscape::XML::Node *_preferences; // Preferences container node double _width; // Document size in px double _height; // Document size in px + double _ttm[6]; ///< temporary transform matrix + bool _ttm_is_set; }; -- cgit v1.2.3 From 11ed091ae647cd7e56ec5a60359b293b94a3bfec Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 01:15:11 +0100 Subject: Render zero-width PDF lines as 1px lines compensated for current transform. Partially fixes import of some LibreOffice charts. See LP bug #1283537 Fixed bugs: - https://launchpad.net/bugs/1283537 (bzr r13143) --- src/extension/internal/pdfinput/pdf-parser.cpp | 5 +---- src/extension/internal/pdfinput/svg-builder.cpp | 17 ++++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 7edb758fd..30e120d26 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -718,10 +718,7 @@ void PdfParser::opSetMiterLimit(Object args[], int /*numArgs*/) // TODO not good that numArgs is ignored but args[] is used: void PdfParser::opSetLineWidth(Object args[], int /*numArgs*/) { - if (args[0].getNum() > 0.0) - state->setLineWidth(args[0].getNum()); - else - state->setLineWidth(1.0); // default + state->setLineWidth(args[0].getNum()); builder->updateStyle(state); } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 680e6ca94..71e6dc6ae 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -298,14 +298,6 @@ static gchar *svgInterpretPath(GfxPath *path) { * Uses the given SPCSSAttr for storing the style properties */ void SvgBuilder::_setStrokeStyle(SPCSSAttr *css, GfxState *state) { - - // Check line width - if ( state->getLineWidth() <= 0.0 ) { - // Ignore stroke - sp_repr_css_set_property(css, "stroke", "none"); - return; - } - // Stroke color/pattern if ( state->getStrokeColorSpace()->getMode() == csPattern ) { gchar *urltext = _createPattern(state->getStrokePattern(), state, true); @@ -326,7 +318,14 @@ void SvgBuilder::_setStrokeStyle(SPCSSAttr *css, GfxState *state) { // Line width Inkscape::CSSOStringStream os_width; - os_width << state->getLineWidth(); + double lw = state->getLineWidth(); + if (lw > 0.0) { + os_width << lw; + } else { + // emit a stroke which is 1px in toplevel user units + double pxw = Inkscape::Util::Quantity::convert(1.0, "pt", "px"); + os_width << 1.0 / state->transformWidth(pxw); + } sp_repr_css_set_property(css, "stroke-width", os_width.str().c_str()); // Line cap -- cgit v1.2.3 From e7a3f5b74d1f5a95390ee95b06371d184c1812f7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 05:45:38 +0100 Subject: Provide a toggle in the document properties to optionally turn off antialiasing for display and export. Fixes a nearly 10 year old bug #170356 Fixed bugs: - https://launchpad.net/bugs/170356 (bzr r13144) --- src/attributes.cpp | 1 + src/attributes.h | 1 + src/desktop.cpp | 2 ++ src/display/drawing-group.cpp | 17 +++++++++++++++++ src/display/drawing-group.h | 2 ++ src/display/sp-canvas.cpp | 1 - src/sp-namedview.cpp | 6 ++++++ src/sp-namedview.h | 1 + src/sp-root.cpp | 10 ++++++++++ src/sp-root.h | 2 ++ src/ui/dialog/document-properties.cpp | 19 +++++++++++-------- src/ui/dialog/document-properties.h | 1 + 12 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/attributes.cpp b/src/attributes.cpp index ee2a80fd3..1c62ea841 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -117,6 +117,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"}, {SP_ATTR_UNITS, "units"}, {SP_ATTR_INKSCAPE_CONNECTOR_SPACING, "inkscape:connector-spacing"}, + {SP_ATTR_INKSCAPE_ANTIALIASING, "inkscape:antialiasing"}, /* SPColorProfile */ {SP_ATTR_LOCAL, "local"}, {SP_ATTR_NAME, "name"}, diff --git a/src/attributes.h b/src/attributes.h index b8843fcb7..530c9d11a 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -118,6 +118,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_DOCUMENT_UNITS, SP_ATTR_UNITS, SP_ATTR_INKSCAPE_CONNECTOR_SPACING, + SP_ATTR_INKSCAPE_ANTIALIASING, /* SPColorProfile */ SP_ATTR_LOCAL, SP_ATTR_NAME, diff --git a/src/desktop.cpp b/src/desktop.cpp index a02baeac8..234831e69 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1736,6 +1736,8 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) if (flags & SP_OBJECT_MODIFIED_FLAG) { + desktop->getDocument()->getRoot()->setAntialiasing(nv->antialiasing); + /* Show/hide page background */ if (nv->pagecolor | (0xff != 0xffffffff)) { sp_canvas_item_show (desktop->table); diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 38ace001f..c03e0f3ba 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -22,6 +22,7 @@ DrawingGroup::DrawingGroup(Drawing &drawing) : DrawingItem(drawing) , _style(NULL) , _child_transform(NULL) + , _uses_antialiasing(true) {} DrawingGroup::~DrawingGroup() @@ -47,6 +48,15 @@ DrawingGroup::setStyle(SPStyle *style) _setStyleCommon(_style, style); } +void +DrawingGroup::setAntialiasing(bool a) +{ + if (_uses_antialiasing != a) { + _uses_antialiasing = a; + _markForUpdate(STATE_ALL, true); + } +} + /** * Set additional transform for the group. * This is applied after the normal transform and mainly useful for @@ -100,6 +110,13 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { + DrawingContext::Save aa_save; + + if (!_uses_antialiasing) { + aa_save.save(dc); + cairo_set_antialias(dc.raw(), CAIRO_ANTIALIAS_NONE); + } + if (stop_at == NULL) { // normal rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 651e9d8af..c7f1c70ce 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -30,6 +30,7 @@ public: void setStyle(SPStyle *style); void setChildTransform(Geom::Affine const &new_trans); + void setAntialiasing(bool a); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -42,6 +43,7 @@ protected: SPStyle *_style; Geom::Affine *_child_transform; + bool _uses_antialiasing; }; bool is_drawing_group(DrawingItem *item); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c502daf64..6d903867b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -35,7 +35,6 @@ #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" -#include "sp-namedview.h" using Inkscape::Debug::GdkEventLatencyTracker; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index a01ba891e..03c124117 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -90,6 +90,7 @@ SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->grids_visible = false; this->showborder = TRUE; this->showpageshadow = TRUE; + this->antialiasing = TRUE; this->guides = NULL; this->viewcount = 0; @@ -248,6 +249,7 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:snap-page" ); this->readAttr( "inkscape:current-layer" ); this->readAttr( "inkscape:connector-spacing" ); + this->readAttr( "inkscape:antialiasing" ); /* Construct guideline list */ for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { @@ -603,6 +605,10 @@ void SPNamedView::set(unsigned int key, const gchar* value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } + case SP_ATTR_INKSCAPE_ANTIALIASING: + this->antialiasing = value ? sp_str_to_bool(value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; default: SPObjectGroup::set(key, value); break; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 05cbcc398..b6e32206e 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -44,6 +44,7 @@ public: unsigned int showborder : 1; unsigned int showpageshadow : 1; unsigned int borderlayer : 2; + unsigned int antialiasing : 1; double zoom; double cx; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 12570e03e..12ac1bad4 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -25,6 +25,7 @@ #include "document.h" #include "inkscape-version.h" #include "sp-defs.h" +#include "sp-namedview.h" #include "sp-root.h" #include "display/drawing-group.h" #include "svg/stringstream.h" @@ -307,6 +308,7 @@ void SPRoot::update(SPCtx *ctx, guint flags) for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setChildTransform(this->c2p); + g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } } @@ -373,6 +375,7 @@ Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key if (ai) { Inkscape::DrawingGroup *g = dynamic_cast(ai); g->setChildTransform(this->c2p); + g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } return ai; @@ -391,6 +394,13 @@ const char *SPRoot::displayName() const { return "SVG"; // Do not translate } +void SPRoot::setAntialiasing(bool s) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + g->setAntialiasing(s); + } +} + /* Local Variables: mode:c++ diff --git a/src/sp-root.h b/src/sp-root.h index a25e8030c..a1954c42f 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -50,6 +50,8 @@ public: */ SPDefs *defs; + void setAntialiasing(bool a); + virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, gchar const* value); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0411c789c..ef7c9ee1d 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -106,6 +106,7 @@ DocumentProperties::DocumentProperties() _page_metadata1(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), _page_metadata2(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), //--------------------------------------------------------------- + _rcb_antialias(_("Use antialiasing"), _("If unset, no antialiasing will be done on the drawing"), "inkscape:antialiasing", _wr, false), _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), _rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false), @@ -239,7 +240,8 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con yoptions = Gtk::FILL|Gtk::EXPAND; } if (docum_prop_flag) { - if( i==(n-4) || i==(n-6) ) { + // this sets the padding for subordinate widgets on the "Page" page + if( i==(n-8) || i==(n-10) ) { #if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); arr[i+1]->set_margin_left(20); @@ -316,28 +318,28 @@ void DocumentProperties::build_page() Gtk::Label* label_gen = manage (new Gtk::Label); label_gen->set_markup (_("General")); - Gtk::Label* label_col = manage (new Gtk::Label); - label_col->set_markup (_("Color")); - Gtk::Label* label_bor = manage (new Gtk::Label); - label_bor->set_markup (_("Border")); Gtk::Label *label_for = manage (new Gtk::Label); label_for->set_markup (_("Page Size")); + Gtk::Label* label_dsp = manage (new Gtk::Label); + label_dsp->set_markup (_("Display")); _page_sizer.init(); Gtk::Widget *const widget_array[] = { label_gen, 0, 0, &_rum_deflt, - label_col, 0, - _rcp_bg._label, &_rcp_bg, + //label_col, 0, + //_rcp_bg._label, &_rcp_bg, 0, 0, label_for, 0, 0, &_page_sizer, 0, 0, - label_bor, 0, + label_dsp, 0, 0, &_rcb_canb, 0, &_rcb_bord, 0, &_rcb_shad, + 0, &_rcb_antialias, + _rcp_bg._label, &_rcp_bg, _rcp_bord._label, &_rcp_bord, }; @@ -1472,6 +1474,7 @@ void DocumentProperties::update() _rcb_bord.setActive (nv->borderlayer == SP_BORDER_LAYER_TOP); _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); + _rcb_antialias.setActive(nv->antialiasing); if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index e3ca91731..495f3177d 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -117,6 +117,7 @@ protected: UI::Widget::Registry _wr; //--------------------------------------------------------------- + UI::Widget::RegisteredCheckButton _rcb_antialias; UI::Widget::RegisteredCheckButton _rcb_canb; UI::Widget::RegisteredCheckButton _rcb_bord; UI::Widget::RegisteredCheckButton _rcb_shad; -- cgit v1.2.3 From 5ece992a297ec8fb400a32f4c8dbb34c592236a8 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Thu, 13 Mar 2014 21:55:24 +0100 Subject: Fix gradient position on document import (bug #1283193) Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13145) --- src/document.cpp | 7 ++--- src/sp-gradient.cpp | 83 ++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 66 insertions(+), 24 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index 4756110f6..dc7ed254c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1133,12 +1133,11 @@ static gint sp_document_idle_handler(gpointer data) { SPDocument *doc = static_cast(data); - if (doc->_updateDocument()) { + bool status = !doc->_updateDocument(); // method TRUE if it does NOT need further modification, so invert + if (!status) { doc->modified_id = 0; - return false; - } else { - return true; } + return status; } /** diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index e2ae98ec5..115cb754a 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -111,33 +111,45 @@ gboolean SPGradient::isEquivalent(SPGradient *that) { //TODO Make this work for mesh gradients - if (this->getStopCount() != that->getStopCount()) - return FALSE; - - if (this->hasStops() != that->hasStops()) - return FALSE; - - if (!this->getVector() || !that->getVector()) - return FALSE; + bool status = FALSE; + + while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function + if (this->getStopCount() != that->getStopCount()) { break; } + if (this->hasStops() != that->hasStops()) { break; } + if (!this->getVector() || !that->getVector()) { break; } + if ( (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) || + (SP_IS_RADIALGRADIENT(this) && SP_IS_RADIALGRADIENT(that)) || + (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that))) { + /* OK! */ + } + else { break; } - SPStop *as = this->getVector()->getFirstStop(); - SPStop *bs = that->getVector()->getFirstStop(); + SPStop *as = this->getVector()->getFirstStop(); + SPStop *bs = that->getVector()->getFirstStop(); - while (as && bs) { - if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || - as->offset != bs->offset) { - return FALSE; + bool effective = TRUE; + while (effective && (as && bs)) { + if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || + as->offset != bs->offset) { + effective = FALSE; + break; + } + else { + as = as->getNextStop(); + bs = bs->getNextStop(); + } } - as = as->getNextStop(); - bs = bs->getNextStop(); - } + if(!effective)break; - return TRUE; + status = TRUE; + break; + } + return status; } /** * return true if this gradient is "aligned" to that gradient. - * Aligned means that they have exactly the same transform. + * Aligned means that they have exactly the same coordinates and transform. * @param that - A gradient to compare this to */ gboolean SPGradient::isAligned(SPGradient *that) @@ -148,13 +160,44 @@ gboolean SPGradient::isAligned(SPGradient *that) if(this->gradientTransform_set != that->gradientTransform_set) { break; } if(this->gradientTransform_set && (this->gradientTransform != that->gradientTransform)) { break; } + if (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) { + SPLinearGradient *sg=SP_LINEARGRADIENT(this); + SPLinearGradient *tg=SP_LINEARGRADIENT(that); + + if( !sg->x1._set || !tg->x1._set || // assume that if these are set so will be all the others + (sg->x1.computed != tg->x1.computed) || + (sg->y1.computed != tg->y1.computed) || + (sg->x2.computed != tg->x2.computed) || + (sg->y2.computed != tg->y2.computed) + ) { break; } + } else if (SP_IS_RADIALGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) { + SPRadialGradient *sg=SP_RADIALGRADIENT(this); + SPRadialGradient *tg=SP_RADIALGRADIENT(that); + if( !sg->cx._set || !tg->cx._set || // assume that if these are set so will be all the others + (sg->cx.computed != tg->cx.computed) || + (sg->cy.computed != tg->cy.computed) || + (sg->r.computed != tg->r.computed ) || + (sg->fx.computed != tg->fx.computed) || + (sg->fy.computed != tg->fy.computed) + ) { break; } + } else if (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that)) { + SPMeshGradient *sg=SP_MESHGRADIENT(this); + SPMeshGradient *tg=SP_MESHGRADIENT(that); + + if( !sg->x._set || !tg->x._set || + !sg->y._set || !tg->y._set || + (sg->x.computed != tg->x.computed) || + (sg->y.computed != tg->y.computed) + ) { break; } + } else { + break; + } status = TRUE; break; } return status; } - /* * Gradient */ -- cgit v1.2.3 From 32ef25632164e5af8766a5364400b579edde4ebf Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 13 Mar 2014 23:37:07 +0100 Subject: Reimplement global aliasing toggle as a 'shape-rendering' property on the root element. (bzr r13146) --- src/attributes.cpp | 1 - src/attributes.h | 1 - src/desktop.cpp | 2 -- src/display/drawing-group.cpp | 17 ----------------- src/display/drawing-group.h | 2 -- src/display/drawing-item.cpp | 30 ++++++++++++++++++++++++++---- src/display/drawing-item.h | 2 ++ src/sp-item.cpp | 1 + src/sp-namedview.cpp | 6 ------ src/sp-namedview.h | 1 - src/sp-root.cpp | 10 ---------- src/sp-root.h | 2 -- src/style.cpp | 10 +++++++++- src/ui/dialog/document-properties.cpp | 8 ++++++-- src/ui/widget/registered-widget.cpp | 6 ++++-- src/ui/widget/registered-widget.h | 8 +++++++- 16 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/attributes.cpp b/src/attributes.cpp index 1c62ea841..ee2a80fd3 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -117,7 +117,6 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"}, {SP_ATTR_UNITS, "units"}, {SP_ATTR_INKSCAPE_CONNECTOR_SPACING, "inkscape:connector-spacing"}, - {SP_ATTR_INKSCAPE_ANTIALIASING, "inkscape:antialiasing"}, /* SPColorProfile */ {SP_ATTR_LOCAL, "local"}, {SP_ATTR_NAME, "name"}, diff --git a/src/attributes.h b/src/attributes.h index 530c9d11a..b8843fcb7 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -118,7 +118,6 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_DOCUMENT_UNITS, SP_ATTR_UNITS, SP_ATTR_INKSCAPE_CONNECTOR_SPACING, - SP_ATTR_INKSCAPE_ANTIALIASING, /* SPColorProfile */ SP_ATTR_LOCAL, SP_ATTR_NAME, diff --git a/src/desktop.cpp b/src/desktop.cpp index 234831e69..a02baeac8 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1736,8 +1736,6 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) if (flags & SP_OBJECT_MODIFIED_FLAG) { - desktop->getDocument()->getRoot()->setAntialiasing(nv->antialiasing); - /* Show/hide page background */ if (nv->pagecolor | (0xff != 0xffffffff)) { sp_canvas_item_show (desktop->table); diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index c03e0f3ba..38ace001f 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -22,7 +22,6 @@ DrawingGroup::DrawingGroup(Drawing &drawing) : DrawingItem(drawing) , _style(NULL) , _child_transform(NULL) - , _uses_antialiasing(true) {} DrawingGroup::~DrawingGroup() @@ -48,15 +47,6 @@ DrawingGroup::setStyle(SPStyle *style) _setStyleCommon(_style, style); } -void -DrawingGroup::setAntialiasing(bool a) -{ - if (_uses_antialiasing != a) { - _uses_antialiasing = a; - _markForUpdate(STATE_ALL, true); - } -} - /** * Set additional transform for the group. * This is applied after the normal transform and mainly useful for @@ -110,13 +100,6 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { - DrawingContext::Save aa_save; - - if (!_uses_antialiasing) { - aa_save.save(dc); - cairo_set_antialias(dc.raw(), CAIRO_ANTIALIAS_NONE); - } - if (stop_at == NULL) { // normal rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index c7f1c70ce..651e9d8af 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -30,7 +30,6 @@ public: void setStyle(SPStyle *style); void setChildTransform(Geom::Affine const &new_trans); - void setAntialiasing(bool a); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -43,7 +42,6 @@ protected: SPStyle *_style; Geom::Affine *_child_transform; - bool _uses_antialiasing; }; bool is_drawing_group(DrawingItem *item); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 13e7b61eb..ccf905e81 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -127,6 +127,7 @@ DrawingItem::DrawingItem(Drawing &drawing) , _propagate(0) // , _renders_opacity(0) , _pick_children(0) + , _antialias(1) , _isolation(SP_CSS_ISOLATION_AUTO) , _blend_mode(SP_CSS_BLEND_NORMAL) {} @@ -229,6 +230,8 @@ DrawingItem::prependChild(DrawingItem *item) void DrawingItem::clearChildren() { + if (_children.empty()) return; + _markForRendering(); // prevent children from referencing the parent during deletion // this way, children won't try to remove themselves from a list @@ -266,8 +269,19 @@ DrawingItem::setTransform(Geom::Affine const &new_trans) void DrawingItem::setOpacity(float opacity) { - _opacity = opacity; - _markForRendering(); + if (_opacity != opacity) { + _opacity = opacity; + _markForRendering(); + } +} + +void +DrawingItem::setAntialiasing(bool a) +{ + if (_antialias != a) { + _antialias = a; + _markForRendering(); + } } void @@ -289,8 +303,10 @@ DrawingItem::setBlendMode(unsigned blend_mode) void DrawingItem::setVisible(bool v) { - _visible = v; - _markForRendering(); + if (_visible != v) { + _visible = v; + _markForRendering(); + } } /// This is currently unused @@ -568,6 +584,12 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag Geom::OptIntRect carea = Geom::intersect(area, _drawbox); if (!carea) return RENDER_OK; + if (_antialias) { + cairo_set_antialias(dc.raw(), CAIRO_ANTIALIAS_DEFAULT); + } else { + cairo_set_antialias(dc.raw(), CAIRO_ANTIALIAS_NONE); + } + // render from cache if possible if (_cached) { if (_cache) { diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 913706021..db803cf60 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -108,6 +108,7 @@ public: void setCached(bool c, bool persistent = false); void setOpacity(float opacity); + void setAntialiasing(bool a); void setIsolation(unsigned isolation); // CSS Compositing and Blending void setBlendMode(unsigned blend_mode); void setTransform(Geom::Affine const &trans); @@ -205,6 +206,7 @@ protected: //unsigned _renders_opacity : 1; ///< Whether object needs temporary surface for opacity unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), /// otherwise the group is returned + unsigned _antialias : 1; ///< Whether to use antialiasing unsigned _isolation : 1; unsigned _blend_mode : 4; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9c8b28559..b10aae1c6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -599,6 +599,7 @@ 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->setAntialiasing(object->style->shape_rendering.computed != SP_CSS_SHAPE_RENDERING_CRISPEDGES); v->arenaitem->setIsolation( object->style->isolation.value ); v->arenaitem->setBlendMode( object->style->blend_mode.value ); v->arenaitem->setVisible(!item->isHidden()); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 03c124117..a01ba891e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -90,7 +90,6 @@ SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->grids_visible = false; this->showborder = TRUE; this->showpageshadow = TRUE; - this->antialiasing = TRUE; this->guides = NULL; this->viewcount = 0; @@ -249,7 +248,6 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:snap-page" ); this->readAttr( "inkscape:current-layer" ); this->readAttr( "inkscape:connector-spacing" ); - this->readAttr( "inkscape:antialiasing" ); /* Construct guideline list */ for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { @@ -605,10 +603,6 @@ void SPNamedView::set(unsigned int key, const gchar* value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } - case SP_ATTR_INKSCAPE_ANTIALIASING: - this->antialiasing = value ? sp_str_to_bool(value) : TRUE; - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; default: SPObjectGroup::set(key, value); break; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index b6e32206e..05cbcc398 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -44,7 +44,6 @@ public: unsigned int showborder : 1; unsigned int showpageshadow : 1; unsigned int borderlayer : 2; - unsigned int antialiasing : 1; double zoom; double cx; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 12ac1bad4..12570e03e 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -25,7 +25,6 @@ #include "document.h" #include "inkscape-version.h" #include "sp-defs.h" -#include "sp-namedview.h" #include "sp-root.h" #include "display/drawing-group.h" #include "svg/stringstream.h" @@ -308,7 +307,6 @@ void SPRoot::update(SPCtx *ctx, guint flags) for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setChildTransform(this->c2p); - g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } } @@ -375,7 +373,6 @@ Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key if (ai) { Inkscape::DrawingGroup *g = dynamic_cast(ai); g->setChildTransform(this->c2p); - g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } return ai; @@ -394,13 +391,6 @@ const char *SPRoot::displayName() const { return "SVG"; // Do not translate } -void SPRoot::setAntialiasing(bool s) { - for (SPItemView *v = this->display; v != NULL; v = v->next) { - Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - g->setAntialiasing(s); - } -} - /* Local Variables: mode:c++ diff --git a/src/sp-root.h b/src/sp-root.h index a1954c42f..a25e8030c 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -50,8 +50,6 @@ public: */ SPDefs *defs; - void setAntialiasing(bool a); - virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, gchar const* value); diff --git a/src/style.cpp b/src/style.cpp index de5b23854..132972164 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1936,7 +1936,15 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) if (!style->color_rendering.set || style->color_rendering.inherit) { style->color_rendering.computed = parent->color_rendering.computed; } - + if (!style->image_rendering.set || style->image_rendering.inherit) { + style->image_rendering.computed = parent->image_rendering.computed; + } + if (!style->shape_rendering.set || style->shape_rendering.inherit) { + style->shape_rendering.computed = parent->shape_rendering.computed; + } + if (!style->text_rendering.set || style->text_rendering.inherit) { + style->text_rendering.computed = parent->text_rendering.computed; + } } template diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index ef7c9ee1d..a31ab1a09 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -35,6 +35,7 @@ #include "sp-namedview.h" #include "sp-root.h" #include "sp-script.h" +#include "style.h" #include "svg/stringstream.h" #include "tools-switch.h" #include "ui/widget/color-picker.h" @@ -106,7 +107,7 @@ DocumentProperties::DocumentProperties() _page_metadata1(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), _page_metadata2(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), //--------------------------------------------------------------- - _rcb_antialias(_("Use antialiasing"), _("If unset, no antialiasing will be done on the drawing"), "inkscape:antialiasing", _wr, false), + _rcb_antialias(_("Use antialiasing"), _("If unset, no antialiasing will be done on the drawing"), "shape-rendering", _wr, false, NULL, NULL, NULL, "crispEdges"), _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), _rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false), @@ -1474,7 +1475,10 @@ void DocumentProperties::update() _rcb_bord.setActive (nv->borderlayer == SP_BORDER_LAYER_TOP); _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - _rcb_antialias.setActive(nv->antialiasing); + + SPRoot *root = dt->getDocument()->getRoot(); + _rcb_antialias.set_xml_target(root->getRepr(), dt->getDocument()); + _rcb_antialias.setActive(root->style->shape_rendering.computed != SP_CSS_SHAPE_RENDERING_CRISPEDGES); if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index ae6a7d1e0..175f6471c 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -49,8 +49,10 @@ RegisteredCheckButton::~RegisteredCheckButton() _toggled_connection.disconnect(); } -RegisteredCheckButton::RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in) +RegisteredCheckButton::RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in, char const *active_str, char const *inactive_str) : RegisteredWidget() + , _active_str(active_str) + , _inactive_str(inactive_str) { init_parent(key, wr, repr_in, doc_in); @@ -88,7 +90,7 @@ RegisteredCheckButton::on_toggled() return; _wr->setUpdating (true); - write_to_xml(get_active() ? "true" : "false"); + write_to_xml(get_active() ? _active_str : _inactive_str); //The slave button is greyed out if the master button is unchecked for (std::list::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { (*i)->set_sensitive(get_active()); diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 883a9e1a2..d64c09c16 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -55,6 +55,11 @@ public: event_description = _event_description; write_undo = true; } + void set_xml_target(Inkscape::XML::Node *xml_node, SPDocument *document) + { + repr = xml_node; + doc = document; + } bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;} @@ -136,7 +141,7 @@ private: class RegisteredCheckButton : public RegisteredWidget { public: virtual ~RegisteredCheckButton(); - RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL); + RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL, char const *active_str = "true", char const *inactive_str = "false"); void setActive (bool); @@ -153,6 +158,7 @@ public: // if a callback checks it, it must reset it back to false protected: + char const *_active_str, *_inactive_str; sigc::connection _toggled_connection; void on_toggled(); }; -- cgit v1.2.3 From 4e6fc1ff7c165111d188d107551c112cadb4c04a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 14 Mar 2014 01:25:12 +0100 Subject: Remove obsolete Whiteboard cruft from the default preferences file (bzr r13147) --- src/preferences-skeleton.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index ebc5386e3..2211baddb 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -475,10 +475,6 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" -" \n" -" \n" -" \n" -" \n" " \n" " \n" " \n" -- cgit v1.2.3 From a9658ea64a9a78d67468f1e3ebd018de5b963461 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 14 Mar 2014 10:54:27 +0100 Subject: Return correct values for SPColor::operator== (bzr r13148) --- src/color.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/color.cpp b/src/color.cpp index 5eb0d91ef..dccd603b0 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -84,9 +84,10 @@ SPColor& SPColor::operator= (SPColor const& other) */ bool SPColor::operator == (SPColor const& other) const { - bool match = (v.c[0] != other.v.c[0]) - && (v.c[1] != other.v.c[1]) - && (v.c[2] != other.v.c[2]); + bool match = + (v.c[0] == other.v.c[0]) && + (v.c[1] == other.v.c[1]) && + (v.c[2] == other.v.c[2]); match &= profileMatches( icc, other.icc ); -- cgit v1.2.3 From a33097273737ef495de5036894444ef7b6b44349 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 14 Mar 2014 10:55:39 +0100 Subject: Add a few font related tests. (bzr r13149) --- src/style-test.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/style-test.h b/src/style-test.h index 90654ce83..c88c1c30a 100644 --- a/src/style-test.h +++ b/src/style-test.h @@ -87,13 +87,25 @@ public: // TestCase("fill:url(#painter) inherit", 0, "#painter"), TestCase("fill:inherit"), -// General tests (in order of appearance in sp_style_read), SPIPaint tested above +// General tests (in general order of appearance in sp_style_read), SPIPaint tested above TestCase("visibility:hidden"), // SPIEnum TestCase("visibility:collapse"), TestCase("visibility:visible"), TestCase("display:none"), // SPIEnum TestCase("overflow:visible"), // SPIEnum TestCase("overflow:auto"), // SPIEnum + + // Not directly read + TestCase("font:bold 12px Arial", + "font-size:12px;font-style:normal;font-variant:normal;font-weight:bold;font-family:Arial"), + // line-height not read in + //TestCase("font:bold 12px/24px 'Times New Roman'", + // "font-size:12px;font-style:normal;font-variant:normal;font-weight:bold;line-height:24px;font-family:Times New Roman"), + TestCase("font-family:sans-serif"), // SPIString, text_private + TestCase("font-family:Arial"), + TestCase("font-variant:normal;font-stretch:normal;-inkscape-font-specification:Nimbus Roman No9 L Bold Italic"), + // Needs to be fixed (quotes should be around each font-family): + TestCase("font-family:Georgia, 'Minion Web'","font-family:'Georgia, \"Minion Web\"'"), TestCase("font-size:12", "font-size:12px"), // SPIFontSize TestCase("font-size:12px"), TestCase("font-size:12pt", "font-size:15px"), @@ -105,11 +117,15 @@ public: TestCase("font-weight:normal"), TestCase("font-weight:bolder"), TestCase("font-stretch:condensed"), // SPIEnum + + // Should be moved down TestCase("text-indent:12em"), // SPILength? TestCase("text-align:center"), // SPIEnum TestCase("text-decoration: underline"), // SPITextDecoration TestCase("text-decoration: underline wavy #0000ff"), // SPITextDecoration CSS3 TestCase("text-decoration: overline double #ff0000"), + + // Should be moved up TestCase("line-height:24px"), // SPILengthOrNormal TestCase("line-height:1.5"), TestCase("letter-spacing:2px"), // SPILengthOrNormal @@ -121,6 +137,7 @@ public: TestCase("baseline-shift:sub"), TestCase("baseline-shift:12.5%"), TestCase("baseline-shift:2px"), + TestCase("opacity:0.1"), // SPIScale24 // ... TestCase("stroke-width:2px"), // SPILength @@ -138,7 +155,6 @@ public: TestCase("stroke-dashoffset:13"), // SPILength TestCase("stroke-dashoffset:10px"), // ... - TestCase("font-family:sans-serif"), // SPIString, text_private //TestCase("filter:url(#myfilter)"), // SPIFilter segfault in read TestCase("filter:inherit"), -- cgit v1.2.3 From 827547374b8a0a7e0ab10a9ecec19930fa875f58 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 14 Mar 2014 22:05:27 +0100 Subject: string class usage (bzr r13150) --- src/file.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 35039fed3..55892fffe 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1385,8 +1385,6 @@ sp_file_export_dialog(Gtk::Window &parentWindow) if (doc->uri == NULL) { - char formatBuf[256]; - Glib::ustring filename_extension = ".svg"; extension = dynamic_cast (Inkscape::Extension::db.get(default_extension.c_str())); @@ -1400,15 +1398,14 @@ sp_file_export_dialog(Gtk::Window &parentWindow) if (!Inkscape::IO::file_test(export_path.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - export_path = ""; + export_path = Glib::ustring(""); - if (export_path.size()<1) + if (export_path.empty()) export_path = g_get_home_dir(); export_loc = export_path; export_loc.append(G_DIR_SEPARATOR_S); - snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str()); - export_loc.append(formatBuf); + export_loc += Glib::ustring(_("drawing")) + filename_extension; } else @@ -1420,7 +1417,7 @@ sp_file_export_dialog(Gtk::Window &parentWindow) // is this needed any more, now that everything is handled in // Inkscape::IO? Glib::ustring export_path_local = Glib::filename_from_utf8(export_path); - if ( export_path_local.size() > 0) + if (!export_path_local.empty()) export_path = export_path_local; //# Show the Export dialog -- cgit v1.2.3 From d36d9c10ba8f58ec152d9cefa3fa0b1c31333be0 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 14 Mar 2014 22:20:04 +0100 Subject: fix build warning (bzr r13151) --- src/style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style.cpp b/src/style.cpp index 132972164..c57cf6349 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -4373,7 +4373,7 @@ sp_style_write_ilengthornormal(gchar *p, gint const len, gchar const *const key, * Write SPIDashArray object into string. */ static gint -sp_style_write_idasharray(gchar *p, gint const len, gchar const *const key, +sp_style_write_idasharray(gchar *p, gint const len, gchar const *const /*key*/, SPIDashArray const *const val, SPIDashArray const *const base, guint const flags) { if ((flags & SP_STYLE_FLAG_ALWAYS) -- cgit v1.2.3 From a7f3b04eb179d15d005e4352f30216d1db5af3be Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 14 Mar 2014 22:20:44 +0100 Subject: drop wrong g_free call (bzr r13152) --- src/helper/pixbuf-ops.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 1ba6628c5..d44b2207b 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -75,8 +75,7 @@ bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, gchar c[32]; g_snprintf(c, 32, "%f", quality); gboolean saved = gdk_pixbuf_save(pixbuf->getPixbufRaw(), filename, "jpeg", NULL, "quality", c, NULL); - g_free(c); - + return saved; } -- cgit v1.2.3 From 32457e67afc4fbf99da57dcb32ec9a730a5b7901 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 15 Mar 2014 05:07:04 +0100 Subject: Make the Object Properties dialog code adhere to the coding style. (bzr r13153) --- src/ui/dialog/object-properties.cpp | 544 ++++++++++++++++++------------------ src/ui/dialog/object-properties.h | 126 +++------ 2 files changed, 320 insertions(+), 350 deletions(-) diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 82b2cf6b1..c07f39819 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -28,9 +28,9 @@ #include "object-properties.h" #include "widgets/sp-attribute-widget.h" -#include "../../desktop-handles.h" -#include "../../document.h" -#include "../../document-undo.h" +#include "desktop-handles.h" +#include "document.h" +#include "document-undo.h" #include "verbs.h" #include "inkscape.h" #include "selection.h" @@ -51,481 +51,482 @@ namespace Inkscape { namespace UI { namespace Dialog { -ObjectProperties::ObjectProperties (void) : - UI::Widget::Panel ("", "/dialogs/object/", SP_VERB_DIALOG_ITEM), - blocked (false), - CurrentItem(NULL), -#if WITH_GTKMM_3_0 - TopTable(Gtk::manage(new Gtk::Grid())), -#else - TopTable(Gtk::manage(new Gtk::Table(4, 4))), -#endif - LabelID(_("_ID:"), 1), - LabelLabel(_("_Label:"), 1), - LabelTitle(_("_Title:"),1), - LabelImageRendering(_("_Image Rendering:"),1), - LabelDescription(_("_Description:"),1), - FrameDescription("", FALSE), - HBoxCheck(FALSE, 0), -#if WITH_GTKMM_3_0 - CheckTable(Gtk::manage(new Gtk::Grid())), -#else - CheckTable(Gtk::manage(new Gtk::Table(1, 2, true))), -#endif - CBHide(_("_Hide"), 1), - CBLock(_("L_ock"), 1), - BSet (_("_Set"), 1), - LabelInteractivity(_("_Interactivity"), 1), - attrTable(Gtk::manage(new SPAttributeTable())), - desktop(NULL), - deskTrack(), - selectChangedConn(), - subselChangedConn() +ObjectProperties::ObjectProperties() + : UI::Widget::Panel ("", "/dialogs/object/", SP_VERB_DIALOG_ITEM) + , _blocked (false) + , _current_item(NULL) + , _label_id(_("_ID:"), 1) + , _label_label(_("_Label:"), 1) + , _label_title(_("_Title:"), 1) + , _label_image_rendering(_("_Image Rendering:"), 1) + , _cb_hide(_("_Hide"), 1) + , _cb_lock(_("L_ock"), 1) + , _attr_table(Gtk::manage(new SPAttributeTable())) + , _desktop(NULL) { //initialize labels for the table at the bottom of the dialog - int_attrs.push_back("onclick"); - int_attrs.push_back("onmouseover"); - int_attrs.push_back("onmouseout"); - int_attrs.push_back("onmousedown"); - int_attrs.push_back("onmouseup"); - int_attrs.push_back("onmousemove"); - int_attrs.push_back("onfocusin"); - int_attrs.push_back("onfocusout"); - int_attrs.push_back("onload"); - - int_labels.push_back("onclick:"); - int_labels.push_back("onmouseover:"); - int_labels.push_back("onmouseout:"); - int_labels.push_back("onmousedown:"); - int_labels.push_back("onmouseup:"); - int_labels.push_back("onmousemove:"); - int_labels.push_back("onfocusin:"); - int_labels.push_back("onfocusout:"); - int_labels.push_back("onload:"); - - desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) ); - deskTrack.connect(GTK_WIDGET(gobj())); + _int_attrs.push_back("onclick"); + _int_attrs.push_back("onmouseover"); + _int_attrs.push_back("onmouseout"); + _int_attrs.push_back("onmousedown"); + _int_attrs.push_back("onmouseup"); + _int_attrs.push_back("onmousemove"); + _int_attrs.push_back("onfocusin"); + _int_attrs.push_back("onfocusout"); + _int_attrs.push_back("onload"); + + _int_labels.push_back("onclick:"); + _int_labels.push_back("onmouseover:"); + _int_labels.push_back("onmouseout:"); + _int_labels.push_back("onmousedown:"); + _int_labels.push_back("onmouseup:"); + _int_labels.push_back("onmousemove:"); + _int_labels.push_back("onfocusin:"); + _int_labels.push_back("onfocusout:"); + _int_labels.push_back("onload:"); + + _desktop_changed_connection = _desktop_tracker.connectDesktopChanged( + sigc::mem_fun(*this, &ObjectProperties::_setTargetDesktop) + ); + _desktop_tracker.connect(GTK_WIDGET(gobj())); #if WITH_GTKMM_3_0 CheckTable->set_row_homogeneous(); CheckTable->set_column_homogeneous(true); #endif - MakeWidget(); + _init(); } -ObjectProperties::~ObjectProperties (void) +ObjectProperties::~ObjectProperties() { - subselChangedConn.disconnect(); - selectChangedConn.disconnect(); - desktopChangeConn.disconnect(); - deskTrack.disconnect(); + _subselection_changed_connection.disconnect(); + _selection_changed_connection.disconnect(); + _desktop_changed_connection.disconnect(); + _desktop_tracker.disconnect(); } -void ObjectProperties::MakeWidget(void) +void ObjectProperties::_init() { Gtk::Box *contents = _getContents(); contents->set_spacing(0); - - TopTable->set_border_width(4); #if WITH_GTKMM_3_0 - TopTable->set_row_spacing(4); - TopTable->set_column_spacing(0); + Gtk::Grid *grid_top = Gtk::manage(new Gtk::Grid()); + grid_top->set_row_spacing(4); + grid_top->set_column_spacing(0); #else - TopTable->set_row_spacings(4); - TopTable->set_col_spacings(0); + Gtk::Table *grid_top = Gtk::manage(new Gtk::Table(4, 4)); + grid_top->set_row_spacings(4); + grid_top->set_col_spacings(0); #endif - contents->pack_start (*TopTable, false, false, 0); + grid_top->set_border_width(4); + + contents->pack_start(*grid_top, false, false, 0); + /* Create the label for the object id */ - LabelID.set_label (LabelID.get_label() + " "); - LabelID.set_alignment (1, 0.5); + _label_id.set_label(_label_id.get_label() + " "); + _label_id.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelID.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelID, 0, 0, 1, 1); + _label_id.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_id, 0, 0, 1, 1); #else - TopTable->attach(LabelID, 0, 1, 0, 1, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_top->attach(_label_id, 0, 1, 0, 1, + Gtk::SHRINK | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif + /* Create the entry box for the object id */ - EntryID.set_tooltip_text (_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); - EntryID.set_max_length (64); + _entry_id.set_tooltip_text(_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); + _entry_id.set_max_length(64); #if WITH_GTKMM_3_0 - EntryID.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryID, 1, 0, 1, 1); + _entry_id.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_id, 1, 0, 1, 1); #else - TopTable->attach(EntryID, 1, 2, 0, 1, + grid_top->attach(_entry_id, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelID.set_mnemonic_widget (EntryID); + _label_id.set_mnemonic_widget(_entry_id); // pressing enter in the id field is the same as clicking Set: - EntryID.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_id.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); // focus is in the id field initially: - EntryID.grab_focus(); + _entry_id.grab_focus(); + /* Create the label for the object label */ - LabelLabel.set_label (LabelLabel.get_label() + " "); - LabelLabel.set_alignment (1, 0.5); + _label_label.set_label(_label_label.get_label() + " "); + _label_label.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelLabel.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelLabel, 0, 1, 1, 1); + _label_label.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_label, 0, 1, 1, 1); #else - TopTable->attach(LabelLabel, 0, 1, 1, 2, + grid_top->attach(_label_label, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif + /* Create the entry box for the object label */ - EntryLabel.set_tooltip_text (_("A freeform label for the object")); - EntryLabel.set_max_length (256); + _entry_label.set_tooltip_text(_("A freeform label for the object")); + _entry_label.set_max_length(256); #if WITH_GTKMM_3_0 - EntryLabel.set_hexpand(); - EntryLabel.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryLabel, 1, 1, 1, 1); + _entry_label.set_hexpand(); + _entry_label.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_label, 1, 1, 1, 1); #else - TopTable->attach(EntryLabel, 1, 2, 1, 2, + grid_top->attach(_entry_label, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelLabel.set_mnemonic_widget (EntryLabel); + _label_label.set_mnemonic_widget(_entry_label); // pressing enter in the label field is the same as clicking Set: - EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_label.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); + /* Create the label for the object title */ - LabelTitle.set_label (LabelTitle.get_label() + " "); - LabelTitle.set_alignment (1, 0.5); + _label_title.set_label(_label_title.get_label() + " "); + _label_title.set_alignment (1, 0.5); #if WITH_GTKMM_3_0 - LabelTitle.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelTitle, 0, 2, 1, 1); + _label_title.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_title, 0, 2, 1, 1); #else - TopTable->attach(LabelTitle, 0, 1, 2, 3, + grid_top->attach(_label_title, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif /* Create the entry box for the object title */ - EntryTitle.set_sensitive (FALSE); - EntryTitle.set_max_length (256); + _entry_title.set_sensitive (FALSE); + _entry_title.set_max_length (256); #if WITH_GTKMM_3_0 - EntryTitle.set_hexpand(); - EntryTitle.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryTitle, 1, 2, 1, 1); + _entry_title.set_hexpand(); + _entry_title.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_title, 1, 2, 1, 1); #else - TopTable->attach(EntryTitle, 1, 2, 2, 3, + grid_top->attach(_entry_title, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelTitle.set_mnemonic_widget (EntryTitle); + _label_title.set_mnemonic_widget(_entry_title); // pressing enter in the label field is the same as clicking Set: - EntryTitle.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_title.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); /* Create the frame for the object description */ - FrameDescription.set_label_widget (LabelDescription); - FrameDescription.set_padding (0,0,0,0); - contents->pack_start (FrameDescription, true, true, 0); + Gtk::Label *label_desc = Gtk::manage(new Gtk::Label(_("_Description:"), 1)); + UI::Widget::Frame *frame_desc = Gtk::manage(new UI::Widget::Frame("", FALSE)); + frame_desc->set_label_widget(*label_desc); + frame_desc->set_padding (0,0,0,0); + contents->pack_start(*frame_desc, true, true, 0); /* Create the text view box for the object description */ - FrameTextDescription.set_border_width(4); - FrameTextDescription.set_sensitive (FALSE); - FrameDescription.add (FrameTextDescription); - FrameTextDescription.set_shadow_type (Gtk::SHADOW_IN); + _ft_description.set_border_width(4); + _ft_description.set_sensitive(FALSE); + frame_desc->add(_ft_description); + _ft_description.set_shadow_type(Gtk::SHADOW_IN); - TextViewDescription.set_wrap_mode(Gtk::WRAP_WORD); - TextViewDescription.get_buffer()->set_text(""); - FrameTextDescription.add (TextViewDescription); - TextViewDescription.add_mnemonic_label(LabelDescription); + _tv_description.set_wrap_mode(Gtk::WRAP_WORD); + _tv_description.get_buffer()->set_text(""); + _ft_description.add(_tv_description); + _tv_description.add_mnemonic_label(*label_desc); /* Image rendering */ /* Create the label for the object ImageRendering */ - LabelImageRendering.set_label (LabelImageRendering.get_label() + " "); - LabelImageRendering.set_alignment (1, 0.5); + _label_image_rendering.set_label(_label_image_rendering.get_label() + " "); + _label_image_rendering.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelImageRendering.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelImageRendering, 0, 3, 1, 1); + _label_image_rendering.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_image_rendering, 0, 3, 1, 1); #else - TopTable->attach(LabelImageRendering, 0, 1, 3, 4, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_top->attach(_label_image_rendering, 0, 1, 3, 4, + Gtk::SHRINK | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif /* Create the combo box text for the 'image-rendering' property */ - ComboBoxTextImageRendering.append( "auto" ); - ComboBoxTextImageRendering.append( "optimizeQuality" ); - ComboBoxTextImageRendering.append( "optimizeSpeed" ); - ComboBoxTextImageRendering.set_tooltip_text (_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation.")); + _combo_image_rendering.append( "auto" ); + _combo_image_rendering.append( "optimizeQuality" ); + _combo_image_rendering.append( "optimizeSpeed" ); + _combo_image_rendering.set_tooltip_text(_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation.")); #if WITH_GTKMM_3_0 - ComboBoxTextImageRendering.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(ComboBoxTextImageRendering, 1, 3, 1, 1); + _combo_image_rendering.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_combo_image_rendering, 1, 3, 1, 1); #else - TopTable->attach(ComboBoxTextImageRendering, 1, 2, 3, 4, + grid_top->attach(_combo_image_rendering, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelImageRendering.set_mnemonic_widget (ComboBoxTextImageRendering); + _label_image_rendering.set_mnemonic_widget(_combo_image_rendering); - ComboBoxTextImageRendering.signal_changed().connect(sigc::mem_fun(this, &ObjectProperties::image_rendering_changed)); + _combo_image_rendering.signal_changed().connect( + sigc::mem_fun(this, &ObjectProperties::_imageRenderingChanged) + ); /* Check boxes */ - contents->pack_start (HBoxCheck, FALSE, FALSE, 0); - CheckTable->set_border_width(4); - HBoxCheck.pack_start(*CheckTable, true, true, 0); + Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox()); + contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0); + +#if WITH_GTKMM_3_0 + Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid()); +#else + Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true)); +#endif + + grid_cb->set_border_width(4); + hb_checkboxes->pack_start(*grid_cb, true, true, 0); /* Hide */ - CBHide.set_tooltip_text (_("Check to make the object invisible")); + _cb_hide.set_tooltip_text (_("Check to make the object invisible")); #if WITH_GTKMM_3_0 - CBHide.set_hexpand(); - CBHide.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(CBHide, 0, 0, 1, 1); + _cb_hide.set_hexpand(); + _cb_hide.set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(_cb_hide, 0, 0, 1, 1); #else - CheckTable->attach(CBHide, 0, 1, 0, 1, + grid_cb->attach(_cb_hide, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - CBHide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::hidden_toggled)); + _cb_hide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_hiddenToggled)); /* Lock */ // TRANSLATORS: "Lock" is a verb here - CBLock.set_tooltip_text (_("Check to make the object insensitive (not selectable by mouse)")); + _cb_lock.set_tooltip_text(_("Check to make the object insensitive (not selectable by mouse)")); #if WITH_GTKMM_3_0 - CBLock.set_hexpand(); - CBLock.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(CBLock, 1, 0, 1, 1); + _cb_lock.set_hexpand(); + _cb_lock.set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(_cb_lock, 1, 0, 1, 1); #else - CheckTable->attach(CBLock, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_cb->attach(_cb_lock, 1, 2, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif - CBLock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::sensitivity_toggled)); + _cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled)); /* Button for setting the object's id, label, title and description. */ + Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), 1)); #if WITH_GTKMM_3_0 - BSet.set_hexpand(); - BSet.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(BSet, 2, 0, 1, 1); + btn_set->set_hexpand(); + btn_set->set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(*btn_set, 2, 0, 1, 1); #else - CheckTable->attach(BSet, 2, 3, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_cb->attach(*btn_set, 2, 3, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif - BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); /* Create the frame for interactivity options */ - EInteractivity.set_label_widget (LabelInteractivity); - contents->pack_start (EInteractivity, FALSE, FALSE, 0); - show_all (); - widget_setup(); + Gtk::Label *label_interactivity = Gtk::manage(new Gtk::Label(_("_Interactivity"), 1)); + _exp_interactivity.set_label_widget(*label_interactivity); + contents->pack_start(_exp_interactivity, FALSE, FALSE, 0); + + show_all(); + update(); } -void ObjectProperties::widget_setup(void) +void ObjectProperties::update() { - if (blocked || !desktop) - { + if (_blocked || !_desktop) { return; } - if (SP_ACTIVE_DESKTOP != desktop) - { + if (SP_ACTIVE_DESKTOP != _desktop) { return; } - Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP); + Inkscape::Selection *selection = sp_desktop_selection(SP_ACTIVE_DESKTOP); Gtk::Box *contents = _getContents(); if (!selection->singleItem()) { contents->set_sensitive (false); - CurrentItem = NULL; + _current_item = NULL; //no selection anymore or multiple objects selected, means that we need //to close the connections to the previously selected object - attrTable->clear(); + _attr_table->clear(); return; } else { contents->set_sensitive (true); } SPItem *item = selection->singleItem(); - if (CurrentItem == item) + if (_current_item == item) { //otherwise we would end up wasting resources through the modify selection - //callback when moving an object (endlessly setting the labels and recreating attrTable) + //callback when moving an object (endlessly setting the labels and recreating _attr_table) return; } - blocked = true; + _blocked = true; - CBLock.set_active (item->isLocked()); /* Sensitive */ - CBHide.set_active (item->isExplicitlyHidden()); /* Hidden */ + _cb_lock.set_active(item->isLocked()); /* Sensitive */ + _cb_hide.set_active(item->isExplicitlyHidden()); /* Hidden */ if (item->cloned) { /* ID */ - EntryID.set_text (""); - EntryID.set_sensitive (FALSE); - LabelID.set_text (_("Ref")); + _entry_id.set_text(""); + _entry_id.set_sensitive(FALSE); + _label_id.set_text(_("Ref")); /* Label */ - EntryLabel.set_text (""); - EntryLabel.set_sensitive (FALSE); - LabelLabel.set_text (_("Ref")); + _entry_label.set_text(""); + _entry_label.set_sensitive(FALSE); + _label_label.set_text(_("Ref")); } else { SPObject *obj = static_cast(item); /* ID */ - EntryID.set_text (obj->getId()); - EntryID.set_sensitive (TRUE); - LabelID.set_markup_with_mnemonic (_("_ID:")); + _entry_id.set_text(obj->getId()); + _entry_id.set_sensitive(TRUE); + _label_id.set_markup_with_mnemonic(_("_ID:") + Glib::ustring(" ")); /* Label */ - EntryLabel.set_text(obj->defaultLabel()); - EntryLabel.set_sensitive (TRUE); + _entry_label.set_text(obj->defaultLabel()); + _entry_label.set_sensitive(TRUE); /* Title */ gchar *title = obj->title(); if (title) { - EntryTitle.set_text(title); + _entry_title.set_text(title); g_free(title); } else { - EntryTitle.set_text(""); + _entry_title.set_text(""); } - EntryTitle.set_sensitive(TRUE); + _entry_title.set_sensitive(TRUE); /* Image Rendering */ - if( SP_IS_IMAGE( item ) ) { - ComboBoxTextImageRendering.show(); - LabelImageRendering.show(); + if (SP_IS_IMAGE(item)) { + _combo_image_rendering.show(); + _label_image_rendering.show(); char const *str = obj->getStyleProperty( "image-rendering", "auto" ); - if( strcmp( str, "auto" ) == 0 ) { - ComboBoxTextImageRendering.set_active(0); - } else if( strcmp( str, "optimizeQuality" ) == 0 ) { - ComboBoxTextImageRendering.set_active(1); - } else { - ComboBoxTextImageRendering.set_active(2); + if (strcmp( str, "auto" ) == 0) { + _combo_image_rendering.set_active(0); + } else if (strcmp(str, "optimizeQuality") == 0) { + _combo_image_rendering.set_active(1); + } else { + _combo_image_rendering.set_active(2); } } else { - ComboBoxTextImageRendering.hide(); - ComboBoxTextImageRendering.unset_active(); - LabelImageRendering.hide(); + _combo_image_rendering.hide(); + _combo_image_rendering.unset_active(); + _label_image_rendering.hide(); } /* Description */ gchar *desc = obj->desc(); if (desc) { - TextViewDescription.get_buffer()->set_text(desc); + _tv_description.get_buffer()->set_text(desc); g_free(desc); } else { - TextViewDescription.get_buffer()->set_text(""); + _tv_description.get_buffer()->set_text(""); } - FrameTextDescription.set_sensitive(TRUE); + _ft_description.set_sensitive(TRUE); - if (CurrentItem == NULL) - { - attrTable->set_object(obj, int_labels, int_attrs, (GtkWidget*)EInteractivity.gobj()); - } - else - { - attrTable->change_object(obj); + if (_current_item == NULL) { + _attr_table->set_object(obj, _int_labels, _int_attrs, (GtkWidget*) _exp_interactivity.gobj()); + } else { + _attr_table->change_object(obj); } - attrTable->show_all(); + _attr_table->show_all(); } - CurrentItem = item; - blocked = false; + _current_item = item; + _blocked = false; } -void ObjectProperties::label_changed(void) +void ObjectProperties::_labelChanged() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - blocked = true; + _blocked = true; /* Retrieve the label widget for the object's id */ - gchar *id = g_strdup(EntryID.get_text().c_str()); - g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); - if (!strcmp (id, item->getId())) { - LabelID.set_markup_with_mnemonic(_("_ID:")); + gchar *id = g_strdup(_entry_id.get_text().c_str()); + g_strcanon(id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); + if (strcmp(id, item->getId()) == 0) { + _label_id.set_markup_with_mnemonic(_("_ID:")); } else if (!*id || !isalnum (*id)) { - LabelID.set_text (_("Id invalid! ")); + _label_id.set_text(_("Id invalid! ")); } else if (SP_ACTIVE_DOCUMENT->getObjectById(id) != NULL) { - LabelID.set_text (_("Id exists! ")); + _label_id.set_text(_("Id exists! ")); } else { SPException ex; - LabelID.set_markup_with_mnemonic(_("_ID:")); - SP_EXCEPTION_INIT (&ex); + _label_id.set_markup_with_mnemonic(_("_ID:")); + SP_EXCEPTION_INIT(&ex); item->setAttribute("id", id, &ex); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object ID")); } - g_free (id); + g_free(id); /* Retrieve the label widget for the object's label */ - Glib::ustring label = EntryLabel.get_text(); + Glib::ustring label = _entry_label.get_text(); /* Give feedback on success of setting the drawing object's label * using the widget's label text */ SPObject *obj = static_cast(item); - if (label.compare (obj->defaultLabel())) { + if (label.compare(obj->defaultLabel())) { obj->setLabel(label.c_str()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object label")); } /* Retrieve the title */ - if (obj->setTitle(EntryTitle.get_text().c_str())) + if (obj->setTitle(_entry_title.get_text().c_str())) { DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object title")); + } /* Retrieve the description */ Gtk::TextBuffer::iterator start, end; - TextViewDescription.get_buffer()->get_bounds(start, end); - Glib::ustring desc = TextViewDescription.get_buffer()->get_text(start, end, TRUE); - if (obj->setDesc(desc.c_str())) + _tv_description.get_buffer()->get_bounds(start, end); + Glib::ustring desc = _tv_description.get_buffer()->get_text(start, end, TRUE); + if (obj->setDesc(desc.c_str())) { DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object description")); + } - blocked = false; + _blocked = false; } -void ObjectProperties::image_rendering_changed(void) +void ObjectProperties::_imageRenderingChanged() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - blocked = true; + _blocked = true; - Glib::ustring scale = ComboBoxTextImageRendering.get_active_text(); + Glib::ustring scale = _combo_image_rendering.get_active_text(); // We should unset if the parent computed value is auto and the desired value is auto. SPCSSAttr *css = sp_repr_css_attr_new(); @@ -536,64 +537,67 @@ void ObjectProperties::image_rendering_changed(void) } sp_repr_css_attr_unref( css ); - blocked = false; + _blocked = false; } -void ObjectProperties::sensitivity_toggled (void) +void ObjectProperties::_sensitivityToggled() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); - g_return_if_fail (item != NULL); + g_return_if_fail(item != NULL); - blocked = true; - item->setLocked(CBLock.get_active()); + _blocked = true; + item->setLocked(_cb_lock.get_active()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - CBLock.get_active()? _("Lock object") : _("Unlock object")); - blocked = false; + _cb_lock.get_active() ? _("Lock object") : _("Unlock object")); + _blocked = false; } -void ObjectProperties::hidden_toggled(void) +void ObjectProperties::_hiddenToggled() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); - g_return_if_fail (item != NULL); + g_return_if_fail(item != NULL); - blocked = true; - item->setExplicitlyHidden(CBHide.get_active()); + _blocked = true; + item->setExplicitlyHidden(_cb_hide.get_active()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - CBHide.get_active()? _("Hide object") : _("Unhide object")); - blocked = false; + _cb_hide.get_active() ? _("Hide object") : _("Unhide object")); + _blocked = false; } -void ObjectProperties::setDesktop(SPDesktop *desktop) +void ObjectProperties::_setDesktop(SPDesktop *desktop) { Panel::setDesktop(desktop); - deskTrack.setBase(desktop); + _desktop_tracker.setBase(desktop); } -void ObjectProperties::setTargetDesktop(SPDesktop *desktop) +void ObjectProperties::_setTargetDesktop(SPDesktop *desktop) { - if (this->desktop != desktop) { - if (this->desktop) { - subselChangedConn.disconnect(); - selectChangedConn.disconnect(); + if (this->_desktop != desktop) { + if (this->_desktop) { + _subselection_changed_connection.disconnect(); + _selection_changed_connection.disconnect(); } - this->desktop = desktop; + this->_desktop = desktop; if (desktop && desktop->selection) { - selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &ObjectProperties::widget_setup))); - subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &ObjectProperties::widget_setup))); + _selection_changed_connection = desktop->selection->connectChanged( + sigc::hide(sigc::mem_fun(*this, &ObjectProperties::update)) + ); + _subselection_changed_connection = desktop->connectToolSubselectionChanged( + sigc::hide(sigc::mem_fun(*this, &ObjectProperties::update)) + ); } - widget_setup(); + update(); } } + } } } diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index 721c12c56..093f273f6 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -69,98 +69,64 @@ namespace Dialog { */ class ObjectProperties : public Widget::Panel { public: - ObjectProperties (); - ~ObjectProperties (); + ObjectProperties(); + ~ObjectProperties(); static ObjectProperties &getInstance() { return *new ObjectProperties(); } - /** - * Updates entries and other child widgets on selection change, object modification, etc. - */ - void widget_setup(void); + /// Updates entries and other child widgets on selection change, object modification, etc. + void update(); private: - bool blocked; - SPItem *CurrentItem; //to store the current item, for not wasting resources - std::vector int_attrs; - std::vector int_labels; + bool _blocked; + SPItem *_current_item; //to store the current item, for not wasting resources + std::vector _int_attrs; + std::vector _int_labels; + + Gtk::Label _label_id; //the label for the object ID + Gtk::Entry _entry_id; //the entry for the object ID + Gtk::Label _label_label; //the label for the object label + Gtk::Entry _entry_label; //the entry for the object label + Gtk::Label _label_title; //the label for the object title + Gtk::Entry _entry_title; //the entry for the object title + Gtk::Label _label_image_rendering; // the label for 'image-rendering' + Gtk::ComboBoxText _combo_image_rendering; // the combo box text for 'image-rendering' -#if WITH_GTKMM_3_0 - Gtk::Grid *TopTable; //the table with the object properties -#else - Gtk::Table *TopTable; //the table with the object properties -#endif + Gtk::Frame _ft_description; //the frame for the text of the object description + Gtk::TextView _tv_description; //the text view object showing the object description - Gtk::Label LabelID; //the label for the object ID - Gtk::Entry EntryID; //the entry for the object ID - Gtk::Label LabelLabel; //the label for the object label - Gtk::Entry EntryLabel; //the entry for the object label - Gtk::Label LabelTitle; //the label for the object title - Gtk::Entry EntryTitle; //the entry for the object title - Gtk::Label LabelImageRendering; // the label for 'image-rendering' - Gtk::ComboBoxText ComboBoxTextImageRendering; // the combo box text for 'image-rendering' + Gtk::CheckButton _cb_hide; //the check button hide + Gtk::CheckButton _cb_lock; //the check button lock + + Gtk::Expander _exp_interactivity; //the expander for interactivity + SPAttributeTable *_attr_table; //the widget for showing the on... names at the bottom - Gtk::Label LabelDescription; //the label for the object description - UI::Widget::Frame FrameDescription; //the frame for the object description - Gtk::Frame FrameTextDescription; //the frame for the text of the object description - Gtk::TextView TextViewDescription; //the text view object showing the object description + SPDesktop *_desktop; + DesktopTracker _desktop_tracker; + sigc::connection _desktop_changed_connection; + sigc::connection _selection_changed_connection; + sigc::connection _subselection_changed_connection; - Gtk::HBox HBoxCheck; // the HBox for the check boxes + /// Constructor auxiliary function creating the child widgets. + void _init(); -#if WITH_GTKMM_3_0 - Gtk::Grid *CheckTable; //the table for the check boxes -#else - Gtk::Table *CheckTable; //the table for the check boxes -#endif + /// Sets object properties (ID, label, title, description) on user input. + void _labelChanged(); - Gtk::CheckButton CBHide; //the check button hide - Gtk::CheckButton CBLock; //the check button lock - Gtk::Button BSet; //the button set - - Gtk::Label LabelInteractivity; //the label for interactivity - Gtk::Expander EInteractivity; //the label for interactivity - SPAttributeTable *attrTable; //the widget for showing the on... names at the bottom - - SPDesktop *desktop; - DesktopTracker deskTrack; - sigc::connection desktopChangeConn; - sigc::connection selectChangedConn; - sigc::connection subselChangedConn; - - /** - * Constructor auxiliary function creating the child widgets. - */ - void MakeWidget(void); - - /** - * Sets object properties (ID, label, title, description) on user input. - */ - void label_changed(void); - - /** - * Callback for 'image-rendering'. - */ - void image_rendering_changed(void); - - /** - * Callback for checkbox Lock. - */ - void sensitivity_toggled (void); - - /** - * Callback for checkbox Hide. - */ - void hidden_toggled(void); - - /** - * Can be invoked for setting the desktop. Currently not used. - */ - void setDesktop(SPDesktop *desktop); + /// Callback for 'image-rendering'. + void _imageRenderingChanged(); + + /// Callback for checkbox Lock. + void _sensitivityToggled(); + + /// Callback for checkbox Hide. + void _hiddenToggled(); + + /// Can be invoked for setting the desktop. Currently not used. + void _setDesktop(SPDesktop *desktop); - /** - * Is invoked by the desktop tracker when the desktop changes. - */ - void setTargetDesktop(SPDesktop *desktop); + /// Is invoked by the desktop tracker when the desktop changes. + void _setTargetDesktop(SPDesktop *desktop); }; } -- cgit v1.2.3 From 550eaa7214327d19dcdb0aefdce367e25490021e Mon Sep 17 00:00:00 2001 From: penginsbacon <> Date: Sat, 15 Mar 2014 08:24:37 +0100 Subject: Saving. Fix for Bug #529843 (save a copy reverts to save as) by Tomasz Boczkowski. Fixed bugs: - https://launchpad.net/bugs/529843 (bzr r13154) --- src/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file.cpp b/src/file.cpp index 55892fffe..6c8c5ff85 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -690,7 +690,7 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); return FALSE; } catch (Inkscape::Extension::Output::no_overwrite &e) { - return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS); + return sp_file_save_dialog(parentWindow, doc, save_method); } catch (...) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); return FALSE; -- cgit v1.2.3 From 0f447656fa20753681f2f88713a08df3bfabcb7f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 15 Mar 2014 09:16:21 +0100 Subject: UI. Fix for Bug #1016889 (GTK3: status bar of XML Editor triggers resize of dialog window. Fixed bugs: - https://launchpad.net/bugs/1016889 (bzr r13155) --- src/ui/dialog/xml-tree.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 0e1e9f7a6..55d0aff09 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -100,6 +100,9 @@ XmlTree::XmlTree (void) : status.set_alignment( 0.0, 0.5); status.set_size_request(1, -1); status.set_markup(""); +#if WITH_GTKMM_3_0 + status.set_line_wrap(true); +#endif status_box.pack_start( status, TRUE, TRUE, 0); contents->pack_end(status_box, false, false, 2); -- cgit v1.2.3 From eca101b9f434da89b05ee70531546ae95541d47a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 16 Mar 2014 00:10:01 +0100 Subject: Fix build failure with GTK 3.0 (bzr r13156) --- src/ui/dialog/object-properties.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index c07f39819..28e9b360b 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -90,11 +90,6 @@ ObjectProperties::ObjectProperties() ); _desktop_tracker.connect(GTK_WIDGET(gobj())); -#if WITH_GTKMM_3_0 - CheckTable->set_row_homogeneous(); - CheckTable->set_column_homogeneous(true); -#endif - _init(); } @@ -285,6 +280,8 @@ void ObjectProperties::_init() #if WITH_GTKMM_3_0 Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid()); + grid_cb->set_row_homogeneous(); + grid_cb->set_column_homogeneous(true); #else Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true)); #endif -- cgit v1.2.3 From d952905a04ce27d521e7ae42a3c167259913553f Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 16 Mar 2014 13:03:34 +0100 Subject: string class usage (bzr r13157) --- src/file.cpp | 12 +++++------- src/preferences.cpp | 25 +++++++++---------------- src/preferences.h | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 6c8c5ff85..51e629c7d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -855,7 +855,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens int i = 1; if ( !doc->getURI() ) { // We are saving for the first time; create a unique default filename - save_loc = save_loc + Glib::ustring(_("drawing")) + filename_extension; + save_loc = save_loc + _("drawing") + filename_extension; while (Inkscape::IO::file_test(save_loc.c_str(), G_FILE_TEST_EXISTS)) { save_loc = save_path; @@ -922,9 +922,9 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens Inkscape::Extension::Output *omod = dynamic_cast(selectionType); if (omod) { - Glib::ustring save_extension = (std::string)omod->get_extension(); - if ( !hasEnding(fileName, save_extension.c_str()) ) { - fileName += save_extension.c_str(); + Glib::ustring save_extension = (omod->get_extension()) ? (omod->get_extension()) : ""; + if ( !hasEnding(fileName, save_extension) ) { + fileName += save_extension; } } @@ -1403,9 +1403,7 @@ sp_file_export_dialog(Gtk::Window &parentWindow) if (export_path.empty()) export_path = g_get_home_dir(); - export_loc = export_path; - export_loc.append(G_DIR_SEPARATOR_S); - export_loc += Glib::ustring(_("drawing")) + filename_extension; + export_loc = export_path + G_DIR_SEPARATOR_S + _("drawing") + filename_extension; } else diff --git a/src/preferences.cpp b/src/preferences.cpp index b4b873dc8..2fec3b307 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -438,9 +438,7 @@ void Preferences::setBool(Glib::ustring const &pref_path, bool value) */ void Preferences::setInt(Glib::ustring const &pref_path, int value) { - gchar intstr[32]; - g_snprintf(intstr, 32, "%d", value); - _setRawValue(pref_path, intstr); + _setRawValue(pref_path, Glib::ustring::compose("%1",value)); } /** @@ -451,9 +449,7 @@ void Preferences::setInt(Glib::ustring const &pref_path, int value) */ void Preferences::setDouble(Glib::ustring const &pref_path, double value) { - gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); - _setRawValue(pref_path, buf); + _setRawValue(pref_path, Glib::ustring::compose("%1",value)); } /** @@ -465,11 +461,8 @@ void Preferences::setDouble(Glib::ustring const &pref_path, double value) */ void Preferences::setDoubleUnit(Glib::ustring const &pref_path, double value, Glib::ustring const &unit_abbr) { - gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); - Glib::ustring str(buf); - str += unit_abbr; - _setRawValue(pref_path, str.c_str()); + Glib::ustring str = Glib::ustring::compose("%1%2",value,unit_abbr); + _setRawValue(pref_path, str); } void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) @@ -487,14 +480,14 @@ void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) */ void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value) { - _setRawValue(pref_path, value.c_str()); + _setRawValue(pref_path, value); } void Preferences::setStyle(Glib::ustring const &pref_path, SPCSSAttr *style) { Glib::ustring css_str; sp_repr_css_write_string(style, css_str); - _setRawValue(pref_path, css_str.c_str()); + _setRawValue(pref_path, css_str); } void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) @@ -503,7 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) sp_repr_css_merge(current, style); Glib::ustring css_str; sp_repr_css_write_string(current, css_str); - _setRawValue(pref_path, css_str.c_str()); + _setRawValue(pref_path, css_str); sp_repr_css_attr_unref(current); } @@ -738,7 +731,7 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result) } } -void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value) +void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &value) { // create node and attribute keys Glib::ustring node_key, attr_key; @@ -746,7 +739,7 @@ void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value) // set the attribute Inkscape::XML::Node *node = _getNode(node_key, true); - node->setAttribute(attr_key.c_str(), value); + node->setAttribute(attr_key.c_str(), value.c_str()); } // The _extract* methods are where the actual wrok is done - they define how preferences are stored diff --git a/src/preferences.h b/src/preferences.h index 66fa11542..d5429815e 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -532,7 +532,7 @@ private: void _loadDefaults(); void _load(); void _getRawValue(Glib::ustring const &path, gchar const *&result); - void _setRawValue(Glib::ustring const &path, gchar const *value); + void _setRawValue(Glib::ustring const &path, Glib::ustring const &value); void _reportError(Glib::ustring const &, Glib::ustring const &); void _keySplit(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key); XML::Node *_getNode(Glib::ustring const &pref_path, bool create=false); -- cgit v1.2.3 From 545af877b6b6ce003801e6a19de3f68a1c0fbc4a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 16 Mar 2014 19:41:51 -0400 Subject: Fix header and copyright licence (bzr r13158) --- share/extensions/render_barcode.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py index 7d4c671c0..c3b809c9e 100755 --- a/share/extensions/render_barcode.py +++ b/share/extensions/render_barcode.py @@ -1,21 +1,25 @@ #!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Inkscape's general barcode extension. Run from within inkscape or use the +Barcode module provided for outside or scripting. +""" import inkex import sys -- cgit v1.2.3 From 177d4b53062fa9093c2e37d15fe4c101fef7e17d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 17 Mar 2014 15:05:12 +0100 Subject: Fix for Bug #1293073 (Dragging a symbol crashes the application when the symbol has no title). Fixed bugs: - https://launchpad.net/bugs/1293073 (bzr r13159) --- src/sp-use.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 14f51159b..e8fe3687f 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -220,7 +220,11 @@ const char* SPUse::displayName() const { gchar* SPUse::description() const { if (this->child) { if( SP_IS_SYMBOL( this->child ) ) { - return g_strdup_printf(_("called %s"), Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", this->child->title()))).c_str()); + if (this->child->title()) { + return g_strdup_printf(_("called %s"), Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", this->child->title()))).c_str()); + } else { + return g_strdup_printf(_("called %s"), _("Unnamed Symbol")); + } } static unsigned recursion_depth = 0; -- cgit v1.2.3 From c39ff7ba3dc2c7042f6d316d1df0ee047da82b26 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 17 Mar 2014 15:07:28 +0100 Subject: Fix for Bug #1158506 (Batch export DPI always at 90). Fixed bugs: - https://launchpad.net/bugs/1158506 (bzr r13160) --- src/ui/dialog/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index f0a5f1bf5..913713e5c 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1049,7 +1049,7 @@ void Export::onExport () dpi = atof(dpi_hint); } if (dpi == 0.0) { - dpi = DPI_BASE; + dpi = getValue(xdpi_adj); } Geom::OptRect area = item->desktopVisualBounds(); -- cgit v1.2.3 From 8c06bb6d291a85f89ee0f09953211e07c4aeaf60 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 17 Mar 2014 10:30:46 -0400 Subject: New extension: Merge styles, take the common styles of the selected elements and create a css style from them. (bzr r13161) --- share/extensions/merge_styles.inx | 21 ++++++ share/extensions/merge_styles.py | 134 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 share/extensions/merge_styles.inx create mode 100755 share/extensions/merge_styles.py diff --git a/share/extensions/merge_styles.inx b/share/extensions/merge_styles.inx new file mode 100644 index 000000000..02da12221 --- /dev/null +++ b/share/extensions/merge_styles.inx @@ -0,0 +1,21 @@ + + + <_name>Merge Styles into CSS + org.inkscape.stylesheet.merge + inkex.py + merge_styles.py + + <_param name="introduction" type="description">All selected nodes will be grouped together and their common style attributes will create a new class, this class will replace the existing inline style attributes. Please use a name which best describes the kinds of objects and their common context for best effect. + + class1 + + + all + + + + + + diff --git a/share/extensions/merge_styles.py b/share/extensions/merge_styles.py new file mode 100755 index 000000000..1872e7f3b --- /dev/null +++ b/share/extensions/merge_styles.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# Copyright (C) 2014 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Merges styles into class based styles and removes. +""" + +import inkex +import sys + +from collections import defaultdict + +class Style(dict): + """Controls the style/css mechanics for this effect""" + def __init__(self, attr=None): + self.weights = defaultdict(int) + self.total = [] + if attr: + self.parse(attr) + + def parse(self, attr): + for name,value in [ a.split(':',1) for a in attr.split(';') if ':' in a ]: + self[name.strip()] = value.strip() + + def entries(self): + return [ "%s:%s;" % (n,v) for (n,v) in self.iteritems() ] + + def to_str(self, sep="\n "): + return " " + "\n ".join(self.entries()) + + def __str__(self): + return self.to_str() + + def css(self, cls): + return ".%s {\n%s\n}" % (cls, str(self)) + + def remove(self, keys): + for key in keys: + self.pop(key, None) + + def add(self, c, el): + self.total.append( (c, el) ) + for name,value in c.iteritems(): + if not self.has_key(name): + self[name] = value + if self[name] == value: + self.weights[name] += 1 + + def clean(self, threshold): + """Removes any elements that aren't the same using a weighted threshold""" + for attr in self.keys(): + if self.weights[attr] < len(self.total) - threshold: + common.pop(attr) + + def all_matches(self): + """Returns an iter for each added element who's style matches this style""" + for (c, el) in self.total: + if self == c: + yield (c, el) + + def __eq__(self, o): + """Not equals, prefer to overload 'in' but that doesn't seem possible""" + for arg in self.keys(): + if o.has_key(arg) and self[arg] != o[arg]: + return False + return True + + +def get_styles(document): + nodes = [] + for node in document.getroot().iterchildren(): + if node.tag == inkex.addNS('style', 'svg'): + return node + nodes.append(node) + ret = inkex.etree.SubElement(document.getroot(), 'style', {}) + # Reorder to make the style element FIRST + for node in nodes: + document.getroot().append(node) + return ret + + +class MergeStyles(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-n", "--name", + action="store", type="string", + dest="name", default='', + help="Name of selected element's common class") + + def effect(self): + newclass = self.options.name + elements = self.selected.values() + common = Style() + threshold = 1 + + for el in elements: + common.add(Style(el.attrib['style']), el) + common.clean(threshold) + + if not common: + raise KeyError("There are no common styles between these elements.") + + styles = get_styles(self.document) + styles.text = (styles.text or "") + "\n" + common.css( newclass ) + + for (st, el) in common.all_matches(): + st.remove(common.keys()) + el.attrib['style'] = st.to_str("") + + olds = el.attrib.has_key('class') and el.attrib['class'].split() or [] + if newclass not in olds: + olds.append(newclass) + el.attrib['class'] = ' '.join(olds) + + +if __name__ == '__main__': + e = MergeStyles() + e.affect() + -- cgit v1.2.3 From b74a8597149d17529201fb8c9d9a92e29cc821ad Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 17 Mar 2014 18:52:59 -0700 Subject: Warning cleanups. (bzr r13162) --- src/extension/internal/emf-print.cpp | 2 +- src/extension/internal/wmf-print.cpp | 2 +- src/trace/siox.cpp | 2 +- src/ui/dialog/filter-effects-dialog.cpp | 2 +- src/ui/dialog/undo-history.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 9cc662a27..4bb892821 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1562,7 +1562,7 @@ unsigned int PrintEmf::image( unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ - SPStyle const *style) /** provides indirect link to image object */ + SPStyle const * /*style*/) /** provides indirect link to image object */ { double x1, y1, dw, dh; char *rec = NULL; diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 232891c9c..5a552ad83 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -1103,7 +1103,7 @@ unsigned int PrintWmf::image( unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ - SPStyle const *style) /** provides indirect link to image object */ + SPStyle const * /*style*/) /** provides indirect link to image object */ { double x1, y1, dw, dh; char *rec = NULL; diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 0706cfed1..065e891ed 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -889,7 +889,7 @@ SioxImage Siox::extractForeground(const SioxImage &originalImage, return workImage; } - trace("knownBg:%u knownFg:%u", knownBg.size(), knownFg.size()); + trace("knownBg:%u knownFg:%u", static_cast(knownBg.size()), static_cast(knownFg.size())); std::vector bgSignature ; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 65bebbd14..c2367c2a2 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1515,7 +1515,7 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } } -bool FilterEffectsDialog::FilterModifier::on_filter_move(const Glib::RefPtr& /*context*/, int x, int y, guint /*time*/) { +bool FilterEffectsDialog::FilterModifier::on_filter_move(const Glib::RefPtr& /*context*/, int /*x*/, int /*y*/, guint /*time*/) { //const Gtk::TreeModel::Path& /*path*/) { /* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous! diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 2412c3ec9..53691cd37 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -235,7 +235,7 @@ void UndoHistory::setDesktop(SPDesktop* desktop) } } -void UndoHistory::_connectDocument(SPDesktop* desktop, SPDocument *document) +void UndoHistory::_connectDocument(SPDesktop* desktop, SPDocument * /*document*/) { // disconnect from prior if (_event_log) { -- cgit v1.2.3 From 165e7e7006b009a79ec27a68c513727905ef3442 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 17 Mar 2014 19:30:17 -0700 Subject: Cleanup datatypes for detailed checking of C++11. Fixes Bug #1293295. Fixed bugs: - https://launchpad.net/bugs/1293295 (bzr r13163) --- src/extension/internal/grid.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index c120df719..0059bbec2 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -59,31 +59,31 @@ Grid::load (Inkscape::Extension::Extension */*module*/) namespace { Glib::ustring build_lines(Geom::Rect bounding_area, - float offset[], float spacing[]) + Geom::Point const &offset, Geom::Point const &spacing) { Geom::Point point_offset(0.0, 0.0); SVG::PathString path_data; - for ( int axis = 0 ; axis < 2 ; ++axis ) { + for ( int axis = Geom::X ; axis <= Geom::Y ; ++axis ) { point_offset[axis] = offset[axis]; for (Geom::Point start_point = bounding_area.min(); - start_point[axis] + offset[axis] <= (bounding_area.max())[axis]; - start_point[axis] += spacing[axis]) { + start_point[axis] + offset[axis] <= (bounding_area.max())[axis]; + start_point[axis] += spacing[axis]) { Geom::Point end_point = start_point; end_point[1-axis] = (bounding_area.max())[1-axis]; path_data.moveTo(start_point + point_offset) - .lineTo(end_point + point_offset); + .lineTo(end_point + point_offset); } } - // std::cout << "Path data:" << path_data.c_str() << std::endl; - return path_data; - } - + // std::cout << "Path data:" << path_data.c_str() << std::endl; + return path_data; } +} // namespace + /** \brief This actually draws the grid. \param module The effect that was called (unused) @@ -115,16 +115,15 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc gdouble scale = Inkscape::Util::Quantity::convert(1, "px", (document->doc())->getDefaultUnit()); bounding_area *= Geom::Scale(scale); - float spacings[2] = { scale*module->get_param_float("xspacing"), - scale*module->get_param_float("yspacing") }; - float line_width = scale*module->get_param_float("lineWidth"); - float offsets[2] = { scale*module->get_param_float("xoffset"), - scale*module->get_param_float("yoffset") }; + Geom::Point spacings( scale * module->get_param_float("xspacing"), + scale * module->get_param_float("yspacing") ); + gdouble line_width = scale * module->get_param_float("lineWidth"); + Geom::Point offsets( scale * module->get_param_float("xoffset"), + scale * module->get_param_float("yoffset") ); Glib::ustring path_data(""); - path_data = build_lines(bounding_area, - offsets, spacings); + path_data = build_lines(bounding_area, offsets, spacings); Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc(); //XML Tree being used directly here while it shouldn't be. @@ -144,9 +143,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc path->setAttribute("style", style.c_str()); current_layer->appendChild(path); - Inkscape::GC::release(path); - - return; + Inkscape::GC::release(path); } /** \brief A class to make an adjustment that uses Extension params */ -- cgit v1.2.3 From d19b75151578aaedd4350a819b61f96bbe225753 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 18 Mar 2014 08:51:31 -0400 Subject: Fix weighted removal of attributes from style in merge extension. (bzr r13164) --- share/extensions/merge_styles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/extensions/merge_styles.py b/share/extensions/merge_styles.py index 1872e7f3b..f028bf4ce 100755 --- a/share/extensions/merge_styles.py +++ b/share/extensions/merge_styles.py @@ -65,7 +65,7 @@ class Style(dict): """Removes any elements that aren't the same using a weighted threshold""" for attr in self.keys(): if self.weights[attr] < len(self.total) - threshold: - common.pop(attr) + self.pop(attr) def all_matches(self): """Returns an iter for each added element who's style matches this style""" -- cgit v1.2.3 From bb21b145819e999294e711058b26d97e0527a646 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 18 Mar 2014 19:30:41 +0100 Subject: Fix for Bug #1291546 (Linking color profile from Document properties dialog crashes Inkscape). Fixed bugs: - https://launchpad.net/bugs/1291546 (bzr r13165) --- src/color-profile.cpp | 2 +- src/uri.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 09eaa36e5..ed4b9029e 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -339,7 +339,7 @@ void ColorProfile::set(unsigned key, gchar const *value) { Inkscape::URI hrefUri(escaped); //# 3. Resolve the href according the docBase. This follows // the w3c specs. All absolute and relative issues are considered - std::string fullpath = docUri.getFullPath(hrefUri.getFullPath("")); + std::string fullpath = hrefUri.getFullPath(docUri.getFullPath("")); gchar* fullname = g_uri_unescape_string(fullpath.c_str(), ""); this->impl->_clearProfile(); diff --git a/src/uri.cpp b/src/uri.cpp index e81d108c9..2eaf4ecc1 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -149,6 +149,9 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) * and thus redundent. Caller is expected to check against the document's path. */ const std::string URI::getFullPath(std::string const base) const { + if (!_impl->getPath()) { + return ""; + } std::string path = std::string(_impl->getPath()); // Calculate the absolute path from an available base if(!base.empty() && !path.empty() && path[0] != '/') { -- cgit v1.2.3