summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-06-11 15:34:03 +0000
committerjabiertxof <info@marker.es>2016-06-11 15:34:03 +0000
commitd6b2e2cdeb563026cc9f4633e687a607b095da87 (patch)
treeb25e3e95e5e96782232e65d0d9889fcb12c2f285 /src/extension
parentFixing satellites bug on erase (diff)
parentA little cleaning up of attributes. (diff)
downloadinkscape-d6b2e2cdeb563026cc9f4633e687a607b095da87.tar.gz
inkscape-d6b2e2cdeb563026cc9f4633e687a607b095da87.zip
update to trunk
(bzr r13645.1.147)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/implementation/script.cpp51
-rw-r--r--src/extension/internal/emf-print.cpp2
-rw-r--r--src/extension/internal/grid.cpp13
-rw-r--r--src/extension/param/bool.cpp2
-rw-r--r--src/extension/param/enum.cpp2
-rw-r--r--src/extension/param/float.cpp4
-rw-r--r--src/extension/param/int.cpp4
-rw-r--r--src/extension/param/parameter.cpp11
-rw-r--r--src/extension/param/radiobutton.cpp2
-rw-r--r--src/extension/param/string.cpp2
-rw-r--r--src/extension/plugins/grid2/grid.cpp13
11 files changed, 55 insertions, 51 deletions
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<gchar const *> 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<AttributeRecord const> 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<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); ++it) {
+ oldroot->setAttribute(*it, NULL);
+ }
+
+ // Set the new attributes.
+ for (List<AttributeRecord const> 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<gchar const *> attribs;
-
- // Must explicitly copy root attributes.
-
- // Make a list of all attributes of the old root node.
- for (List<AttributeRecord const> 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<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); ++it) {
- oldroot->setAttribute(*it, NULL);
- }
-
- // Set the new attributes.
- for (List<AttributeRecord const> 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<AttributeRecord const> iter = oldroot_namedview->attributeList(); iter; ++iter) {
attribs.push_back(g_quark_to_string(iter->key));
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;
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/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 <cstring>
+#include <glibmm/i18n.h>
#include "ui/widget/color-notebook.h"
#include <xml/node.h>
@@ -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);
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);