From 61e419a992a054c4417444f6f190a8efbba4bfba Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 1 Jun 2016 20:39:05 +0200 Subject: Replace two instances of getSVGUnit() by getDocumentScale(). Simplify writing of style string. Switch 'pt' to 'px'. (bzr r14938) --- src/extension/internal/grid.cpp | 13 ++++--------- src/extension/plugins/grid2/grid.cpp | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 8a9c7a72f..e6938b9e2 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -108,7 +108,8 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc bounding_area = temprec; } - gdouble scale = Inkscape::Util::Quantity::convert(1, "px", &document->doc()->getSVGUnit()); + double scale = document->doc()->getDocumentScale().inverse()[Geom::X]; + bounding_area *= Geom::Scale(scale); Geom::Point spacings( scale * module->get_param_float("xspacing"), scale * module->get_param_float("yspacing") ); @@ -127,15 +128,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc path->setAttribute("d", path_data.c_str()); - Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"); - style += ";stroke-width:"; - gchar floatstring[64]; std::ostringstream stringstream; - stringstream << line_width; - sprintf(floatstring, "%s", stringstream.str().c_str()); - style += floatstring; - style += "pt"; - path->setAttribute("style", style.c_str()); + stringstream << "fill:none;stroke:#000000;stroke-width:" << line_width << "px"; + path->setAttribute("style", stringstream.str().c_str()); current_layer->appendChild(path); Inkscape::GC::release(path); diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index 3a2ed7867..6880c574d 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -114,7 +114,8 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc bounding_area = temprec; } - gdouble scale = Inkscape::Util::Quantity::convert(1, "px", &document->doc()->getSVGUnit()); + double scale = document->doc()->getDocumentScale().inverse()[Geom::X]; + bounding_area *= Geom::Scale(scale); Geom::Point spacings( scale * module->get_param_float("xspacing"), scale * module->get_param_float("yspacing") ); @@ -133,15 +134,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc path->setAttribute("d", path_data.c_str()); - Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"); - style += ";stroke-width:"; - gchar floatstring[64]; std::ostringstream stringstream; - stringstream << line_width; - sprintf(floatstring, "%s", stringstream.str().c_str()); - style += floatstring; - style += "pt"; - path->setAttribute("style", style.c_str()); + stringstream << "fill:none;stroke:#000000;stroke-width:" << line_width << "px"; + path->setAttribute("style", stringstream.str().c_str()); current_layer->appendChild(path); Inkscape::GC::release(path); -- cgit v1.2.3 From de91fb305ef9afbead53d70421db60f3fb7d8a4c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 1 Jun 2016 21:13:32 +0200 Subject: Remove last use of getSVGUnit() and remove all remnants of this abomination. (bzr r14939) --- src/extension/internal/emf-print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 1c85182ae..9f3b5475f 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -144,7 +144,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // width and height in px _width = doc->getWidth().value("px"); _height = doc->getHeight().value("px"); - _doc_unit_scale = Inkscape::Util::Quantity::convert(1, &doc->getSVGUnit(), "px"); + _doc_unit_scale = doc->getDocumentScale()[Geom::X]; // initialize a few global variables hbrush = hbrushOld = hpen = 0; -- cgit v1.2.3 From fc4b076593df6f406974dd502ca09c1b865e6f72 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 3 Jun 2016 09:50:21 +0200 Subject: Fix guide placement when guides are generated by a template with width/height/viewBox different from default SVG file. (bzr r14947) --- src/extension/implementation/script.cpp | 51 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/extension') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 9aaf4b952..01323bee2 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -808,15 +808,17 @@ void Script::effect(Inkscape::Extension::Effect *module, \param oldroot The root node of the old (destination) document. \param newroot The root node of the new (source) document. - This function first deletes all the elements in the old document by + This function first deletes all the root attributes in the old document followed + by copying all the root attributes from the new document to the old document. + + It then deletes all the elements in the old document by making two pass, the first to create a list of the old elements and the second to actually delete them. This two pass approach removes issues with the list being change while parsing through it... lots of nasty bugs. Then, it copies all the element in the new document into the old document. - Finally, it replaces the attributes in the root element of the old document - by the attributes in root of the new document. + Finally, it copies the attributes in namedview. */ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) { @@ -829,6 +831,28 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr // For copying attributes in root and in namedview using Inkscape::Util::List; using Inkscape::XML::AttributeRecord; + std::vector attribs; + + // Must explicitly copy root attributes. This must be done first since + // copying grid lines calls "SPGuide::set()" which needs to know the + // width, height, and viewBox of the root element. + + // Make a list of all attributes of the old root node. + for (List iter = oldroot->attributeList(); iter; ++iter) { + attribs.push_back(g_quark_to_string(iter->key)); + } + + // Delete the attributes of the old root node. + for (std::vector::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { + oldroot->setAttribute(*it, NULL); + } + + // Set the new attributes. + for (List iter = newroot->attributeList(); iter; ++iter) { + gchar const *name = g_quark_to_string(iter->key); + oldroot->setAttribute(name, newroot->attribute(name)); + } + // Question: Why is the "sodipodi:namedview" special? Treating it as a normal // elmement results in crashes. @@ -882,30 +906,9 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } } - std::vector attribs; - - // Must explicitly copy root attributes. - - // Make a list of all attributes of the old root node. - for (List iter = oldroot->attributeList(); iter; ++iter) { - attribs.push_back(g_quark_to_string(iter->key)); - } - - // Delete the attributes of the old root node. - for (std::vector::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { - oldroot->setAttribute(*it, NULL); - } - - // Set the new attributes. - for (List iter = newroot->attributeList(); iter; ++iter) { - gchar const *name = g_quark_to_string(iter->key); - oldroot->setAttribute(name, newroot->attribute(name)); - } - attribs.clear(); // Must explicitly copy namedview attributes. - // Make a list of all attributes of the old namedview node. for (List iter = oldroot_namedview->attributeList(); iter; ++iter) { attribs.push_back(g_quark_to_string(iter->key)); -- cgit v1.2.3 From 6f15692726681034391d42c58aa870e9dbba642f Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 5 Jun 2016 19:35:39 +0200 Subject: Extensions: Fixes and improvements for "gui-text" parameter attribute - "gui-text" was always translated (as opposed to only "_gui-text") - This made it impossible to have parameters without label (since the empty string returns the whole .po file header when translated), which caused an issue in restack extension - Added possibility to specify "msgctxt" for "gui-text" (bzr r14955) --- src/extension/param/bool.cpp | 2 +- src/extension/param/enum.cpp | 2 +- src/extension/param/float.cpp | 4 ++-- src/extension/param/int.cpp | 4 ++-- src/extension/param/parameter.cpp | 11 +++++++++++ src/extension/param/radiobutton.cpp | 2 +- src/extension/param/string.cpp | 2 +- 7 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src/extension') diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index de9b1c586..87364d80f 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -137,7 +137,7 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); #endif - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_end(*label, true, true); diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 8bc0fbda7..4e7420807 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -251,7 +251,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 81508f6c0..4e3cbfedc 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -186,7 +186,7 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod if (_mode == FULL) { - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision); + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, _precision); scale->set_size_request(400, -1); scale->show(); hbox->pack_start(*scale, false, false); @@ -194,7 +194,7 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod } else if (_mode == MINIMAL) { - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, true, true, _indent); diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index c286018fd..605aab5ad 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -168,14 +168,14 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal if (_mode == FULL) { - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0); + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, 0); scale->set_size_request(400, -1); scale->show(); hbox->pack_start(*scale, false, false); } else if (_mode == MINIMAL) { - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, true, true, _indent); diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 10029893f..27d9bdf9b 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -20,6 +20,7 @@ #endif #include +#include #include "ui/widget/color-notebook.h" #include @@ -56,6 +57,16 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *guitext = in_repr->attribute("gui-text"); if (guitext == NULL) { guitext = in_repr->attribute("_gui-text"); + if (guitext == NULL) { + // guitext = ""; // propably better to require devs to explicitly set an empty gui-text if this is what they want + } else { + const char *context = in_repr->attribute("msgctxt"); + if (context != NULL) { + guitext = g_dpgettext2(NULL, context, guitext); + } else { + guitext = _(guitext); + } + } } const char *gui_tip = in_repr->attribute("gui-tip"); if (gui_tip == NULL) { diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 8181c6f51..1d1b860c6 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -313,7 +313,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0)); #endif - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START, Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 1d9205502..6b082b133 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -166,7 +166,7 @@ Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * no } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); -- cgit v1.2.3