diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-07-31 22:47:38 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-07-31 22:47:38 +0000 |
| commit | 28d25258de5d2274382dbb592f62e21ca8f91729 (patch) | |
| tree | 591dd55aaf5b5a5da03ed826c4c2c8240b636d08 /src | |
| parent | Fix label positioning (diff) | |
| download | inkscape-28d25258de5d2274382dbb592f62e21ca8f91729.tar.gz inkscape-28d25258de5d2274382dbb592f62e21ca8f91729.zip | |
Fix text param and alow run from commandline
(bzr r15017.1.21)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-measure-line.cpp | 32 | ||||
| -rw-r--r-- | src/live_effects/parameter/text.cpp | 20 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 13 | ||||
| -rw-r--r-- | src/ui/widget/text.cpp | 6 | ||||
| -rw-r--r-- | src/ui/widget/text.h | 4 |
5 files changed, 45 insertions, 30 deletions
diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 97da89fd1..fc2ff0f8b 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -57,7 +57,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"), - format(_("Format*"), _("Format the number ex:measure+ +unit"), "format", &wr, this, "measure+unit"), + format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"measure unit"), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false), scale_insensitive(_("Scale insensitive*"), _("Scale insensitive to transforms in element, parents..."), "scale_insensitive", &wr, this, true), @@ -83,15 +83,27 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&line_group_05); registerParameter(&rotate_anotation); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - fontbutton.param_update_default(prefs->getString("/live_effects/measure-line/fontbutton")); + Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); + if(fontbutton_value.empty()){ + fontbutton_value = "Sans 10"; + } + fontbutton.param_update_default(fontbutton_value); scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0)); precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0)); text_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/text_distance", 5.0)); helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0)); helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0)); - unit.param_update_default(prefs->getString("/live_effects/measure-line/unit")); - format.param_update_default(prefs->getString("/live_effects/measure-line/format")); + Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit"); + if(unit_value.empty()){ + unit_value = "px"; + } + unit.param_update_default(unit_value); + Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format"); + if(format_value.empty()){ + format_value = "{measure}{unit}"; + } + format.param_update_default(format_value); flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side")); scale_insensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_insensitive")); local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale")); @@ -391,6 +403,10 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) createArrowMarker((Glib::ustring)"ArrowDIN-end"); } if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { + if (((Glib::ustring)format.param_getSVGValue()).empty()) { + format.param_setValue((Glib::ustring)"{measure}{unit}"); + this->upd_params = true; + } size_t ncurves = pathvector.curveCount(); curve_linked.param_set_range(0, ncurves); Geom::Point start = pathvector.initialPoint(); @@ -491,26 +507,26 @@ void LPEMeasureLine::doOnRemove (SPLPEItem const* lpeitem) { if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem); - Inkscape::URI SVGElem_uri(( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); SVGElemRef->attach(SVGElem_uri); SPObject *elemref = NULL; if (elemref = SVGElemRef->getObject()) { elemref->deleteObject(); } - Inkscape::URI SVGElem_uri2(( (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); + Inkscape::URI SVGElem_uri2(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); SVGElemRef->attach(SVGElem_uri2); elemref = NULL; if (elemref = SVGElemRef->getObject()) { elemref->deleteObject(); } - Inkscape::URI SVGElem_uri3(( (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); + Inkscape::URI SVGElem_uri3(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); SVGElemRef->attach(SVGElem_uri3); elemref = NULL; if (elemref = SVGElemRef->getObject()) { elemref->deleteObject(); } - Inkscape::URI SVGElem_uri4(( (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); + Inkscape::URI SVGElem_uri4(((Glib::ustring)"#" + (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str()); SVGElemRef->attach(SVGElem_uri4); elemref = NULL; if (elemref = SVGElemRef->getObject()) { diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index e51cf93ab..0650b7e66 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -34,10 +34,13 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, defvalue(default_value), _hide_canvas_text(false) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! - canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, default_value.c_str()); - sp_canvastext_set_coords (canvas_text, 0, 0); + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this! + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); + sp_canvastext_set_text (canvas_text, default_value.c_str()); + sp_canvastext_set_coords (canvas_text, 0, 0); + } else { + _hide_canvas_text = true; + } } void @@ -55,8 +58,10 @@ TextParam::param_update_default(Glib::ustring default_value) void TextParam::param_hide_canvas_text() { - _hide_canvas_text = true; - sp_canvastext_set_text (canvas_text,""); + if (!_hide_canvas_text) { + sp_canvastext_set_text(canvas_text, " "); + _hide_canvas_text = true; + } } void @@ -113,8 +118,7 @@ TextParam::param_newWidget() { Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); - - rsu->setText(value.c_str()); + rsu->setText(value); rsu->setProgrammatically = false; rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 923949b72..8b8bdc8e4 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -331,8 +331,6 @@ RegisteredText::RegisteredText ( const Glib::ustring& label, const Glib::ustring init_parent(key, wr, repr_in, doc_in); setProgrammatically = false; - - setText(""); _activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate)); } @@ -348,16 +346,13 @@ RegisteredText::on_activate() return; } _wr->setUpdating (true); - - Inkscape::SVGOStringStream os; - os << getText(); - + Glib::ustring str(getText()); set_sensitive(false); + Inkscape::SVGOStringStream os; + os << str; write_to_xml(os.str().c_str()); - set_sensitive(true); - setText(os.str().c_str()); - + set_sensitive(true); _wr->setUpdating (false); } diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index ec58d5bb4..e6795b138 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -28,13 +28,13 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, { } -const char *Text::getText() const +Glib::ustring const Text::getText() const { g_assert(_widget != NULL); - return static_cast<Gtk::Entry*>(_widget)->get_text().c_str(); + return static_cast<Gtk::Entry*>(_widget)->get_text(); } -void Text::setText(const char* text) +void Text::setText(Glib::ustring const text) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index b90788940..593875b23 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -44,12 +44,12 @@ public: /** * Get the text in the entry. */ - const char* getText() const; + Glib::ustring const getText() const; /** * Sets the text of the text entry. */ - void setText(const char* text); + void setText(Glib::ustring const text); void update(); |
