diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2017-09-27 08:15:49 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2017-09-27 08:15:49 +0000 |
| commit | 40d24d185b7e050deac650960464630f9af4b073 (patch) | |
| tree | ec019942c30f0ae0ee010a86c2fdc6f04af713c2 | |
| parent | Fix error when vertical text has 'text-orientation' value 'sideways'. (diff) | |
| parent | Remove usage of GString in sp-object.cpp (diff) | |
| download | inkscape-40d24d185b7e050deac650960464630f9af4b073.tar.gz inkscape-40d24d185b7e050deac650960464630f9af4b073.zip | |
Merge branch 'jali/inkscape-ustring_refactor'
Removes usage of GString.
| -rw-r--r-- | src/axis-manip.cpp | 12 | ||||
| -rw-r--r-- | src/axis-manip.h | 3 | ||||
| -rw-r--r-- | src/box3d-side.cpp | 13 | ||||
| -rw-r--r-- | src/box3d-side.h | 2 | ||||
| -rw-r--r-- | src/desktop-style.cpp | 6 | ||||
| -rw-r--r-- | src/seltrans.cpp | 20 | ||||
| -rw-r--r-- | src/sp-guide.cpp | 15 | ||||
| -rw-r--r-- | src/sp-object.cpp | 17 | ||||
| -rw-r--r-- | src/sp-object.h | 2 | ||||
| -rw-r--r-- | src/sp-style-elem.cpp | 12 | ||||
| -rw-r--r-- | src/sp-text.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tool/node.cpp | 19 | ||||
| -rw-r--r-- | src/ui/tools/arc-tool.cpp | 11 | ||||
| -rw-r--r-- | src/ui/tools/box3d-tool.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tools/pen-tool.cpp | 5 | ||||
| -rw-r--r-- | src/ui/tools/rect-tool.cpp | 23 | ||||
| -rw-r--r-- | src/ui/tools/spiral-tool.cpp | 5 | ||||
| -rw-r--r-- | src/ui/tools/star-tool.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tools/text-tool.cpp | 10 |
19 files changed, 88 insertions, 105 deletions
diff --git a/src/axis-manip.cpp b/src/axis-manip.cpp index 8955202c8..2332bc0a3 100644 --- a/src/axis-manip.cpp +++ b/src/axis-manip.cpp @@ -32,12 +32,12 @@ get_remaining_axes (Axis axis) { return std::make_pair (extract_first_axis_direction (plane), extract_second_axis_direction (plane)); } -char * string_from_axes (Box3D::Axis axis) { - GString *pstring = g_string_new(""); - if (axis & Box3D::X) g_string_append_printf (pstring, "X"); - if (axis & Box3D::Y) g_string_append_printf (pstring, "Y"); - if (axis & Box3D::Z) g_string_append_printf (pstring, "Z"); - return pstring->str; +Glib::ustring string_from_axes (Box3D::Axis axis) { + Glib::ustring result; + if (axis & Box3D::X) result += "X"; + if (axis & Box3D::Y) result += "Y"; + if (axis & Box3D::Z) result += "Z"; + return result; } } // namespace Box3D diff --git a/src/axis-manip.h b/src/axis-manip.h index 5e245939e..28875b2f5 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -15,6 +15,7 @@ #include <cassert> #include <string> #include <utility> +#include <glibmm/ustring.h> namespace Proj { @@ -238,7 +239,7 @@ inline Box3D::Axis get_perpendicular_axis_direction (Box3D::Axis dirs) { return Box3D::NONE; } -char * string_from_axes (Box3D::Axis axis); +Glib::ustring string_from_axes (Box3D::Axis axis); std::pair <Axis, Axis> get_remaining_axes (Axis axis); } // namespace Box3D diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 14b457ea6..3eea8855c 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -210,29 +210,28 @@ void Box3DSide::set_shape() { c->unref(); } -gchar *box3d_side_axes_string(Box3DSide *side) +Glib::ustring box3d_side_axes_string(Box3DSide *side) { - GString *pstring = g_string_new(""); - g_string_printf (pstring, "%s", Box3D::string_from_axes ((Box3D::Axis) (side->dir1 ^ side->dir2))); + Glib::ustring result(Box3D::string_from_axes((Box3D::Axis) (side->dir1 ^ side->dir2))); switch ((Box3D::Axis) (side->dir1 ^ side->dir2)) { case Box3D::XY: - g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "front" : "rear"); + result += ((side->front_or_rear == Box3D::FRONT) ? "front" : "rear"); break; case Box3D::XZ: - g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "top" : "bottom"); + result += ((side->front_or_rear == Box3D::FRONT) ? "top" : "bottom"); break; case Box3D::YZ: - g_string_append_printf (pstring, (side->front_or_rear == Box3D::FRONT) ? "right" : "left"); + result += ((side->front_or_rear == Box3D::FRONT) ? "right" : "left"); break; default: break; } - return pstring->str; + return result; } static void diff --git a/src/box3d-side.h b/src/box3d-side.h index 4783a5f24..29f17b8f3 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -43,7 +43,7 @@ public: void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape?? -char *box3d_side_axes_string(Box3DSide *side); +Glib::ustring box3d_side_axes_string(Box3DSide *side); Persp3D *box3d_side_perspective(Box3DSide *side); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 19582c9ee..23f803d6a 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -197,10 +197,8 @@ sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *cs SPObject *obj = *i; Box3DSide *side = dynamic_cast<Box3DSide *>(obj); if (side) { - const char * descr = box3d_side_axes_string(side); - if (descr != NULL) { - prefs->mergeStyle(Glib::ustring("/desktop/") + descr + "/style", css_write); - } + prefs->mergeStyle( + Glib::ustring("/desktop/") + box3d_side_axes_string(side) + "/style", css_write); } } sp_repr_css_attr_unref(css_write); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 68d946712..7355f6a07 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1309,12 +1309,10 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // status text Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(pt[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(pt[Geom::Y], "px"); - GString *xs = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); - GString *ys = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); - _message_context.setF(Inkscape::NORMAL_MESSAGE, _("Move <b>center</b> to %s, %s"), xs->str, ys->str); - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); - + Glib::ustring xs(x_q.string(_desktop->namedview->display_units)); + Glib::ustring ys(y_q.string(_desktop->namedview->display_units)); + _message_context.setF(Inkscape::NORMAL_MESSAGE, _("Move <b>center</b> to %s, %s"), + xs.c_str(), ys.c_str()); return TRUE; } @@ -1455,11 +1453,11 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) // status text Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dxy[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dxy[Geom::Y], "px"); - GString *xs = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); - GString *ys = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); - _message_context.setF(Inkscape::NORMAL_MESSAGE, _("<b>Move</b> by %s, %s; with <b>Ctrl</b> to restrict to horizontal/vertical; with <b>Shift</b> to disable snapping"), xs->str, ys->str); - g_string_free(xs, TRUE); - g_string_free(ys, TRUE); + Glib::ustring xs(x_q.string(_desktop->namedview->display_units)); + Glib::ustring ys(y_q.string(_desktop->namedview->display_units)); + _message_context.setF(Inkscape::NORMAL_MESSAGE, + _("<b>Move</b> by %s, %s; with <b>Ctrl</b> to restrict to horizontal/vertical; with <b>Shift</b> to disable snapping"), + xs.c_str(), ys.c_str()); } // Given a location of a handle at the visual bounding box, find the corresponding location at the diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index ff0f6cadb..8b4bf121d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -485,28 +485,25 @@ char* SPGuide::description(bool const verbose) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(this->point_on_line[X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(this->point_on_line[Y], "px"); - GString *position_string_x = g_string_new(x_q.string(namedview->display_units).c_str()); - GString *position_string_y = g_string_new(y_q.string(namedview->display_units).c_str()); + Glib::ustring position_string_x = x_q.string(namedview->display_units); + Glib::ustring position_string_y = y_q.string(namedview->display_units); gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete")); if ( are_near(this->normal_to_line, Geom::Point(1., 0.)) || are_near(this->normal_to_line, -Geom::Point(1., 0.)) ) { - descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); + descr = g_strdup_printf(_("vertical, at %s"), position_string_x.c_str()); } else if ( are_near(this->normal_to_line, Geom::Point(0., 1.)) || are_near(this->normal_to_line, -Geom::Point(0., 1.)) ) { - descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); + descr = g_strdup_printf(_("horizontal, at %s"), position_string_y.c_str()); } else { double const radians = this->angle(); double const degrees = Geom::deg_from_rad(radians); int const degrees_int = (int) round(degrees); descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"), - degrees_int, position_string_x->str, position_string_y->str); + degrees_int, position_string_x.c_str(), position_string_y.c_str()); } - - g_string_free(position_string_x, TRUE); - g_string_free(position_string_y, TRUE); - + if (verbose) { gchar *oldDescr = descr; descr = g_strconcat(oldDescr, shortcuts, NULL); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 9f15935ac..fc222f701 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1540,7 +1540,10 @@ char * SPObject::getTitleOrDesc(gchar const *svg_tagname) const char *result = NULL; SPObject *elem = findFirstChild(svg_tagname); if ( elem ) { - result = elem->textualContent(); + //This string copy could be avoided by changing + //the return type of SPObject::getTitleOrDesc + //to std::unique_ptr<Glib::ustring> + result = g_strdup(elem->textualContent().c_str()); } return result; } @@ -1625,24 +1628,22 @@ SPObject* SPObject::findFirstChild(gchar const *tagname) const return nullptr; } -char* SPObject::textualContent() const +Glib::ustring SPObject::textualContent() const { - GString* text = g_string_new(""); + Glib::ustring text; for (auto& child: children) { Inkscape::XML::NodeType child_type = child.repr->type(); if (child_type == Inkscape::XML::ELEMENT_NODE) { - char* new_string = child.textualContent(); - g_string_append(text, new_string); - g_free(new_string); + text += child.textualContent(); } else if (child_type == Inkscape::XML::TEXT_NODE) { - g_string_append(text, child.repr->content()); + text += child.repr->content(); } } - return g_string_free(text, FALSE); + return text; } // For debugging: Print SP tree structure. diff --git a/src/sp-object.h b/src/sp-object.h index d145e966b..08e69f771 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -803,7 +803,7 @@ private: * content except the tags). * Must not be used on anything except elements. */ - char * textualContent() const; + Glib::ustring textualContent() const; /* Real handlers of repr signals */ diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 694334d23..1a3c194b9 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -106,14 +106,14 @@ Inkscape::XML::Node* SPStyleElem::write(Inkscape::XML::Document* xml_doc, Inksca /** Returns the concatenation of the content of the text children of the specified object. */ -static GString * +static Glib::ustring concat_children(Inkscape::XML::Node const &repr) { - GString *ret = g_string_sized_new(0); - // effic: 0 is just to catch bugs. Increase to something reasonable. + Glib::ustring ret; + // effic: Initialising ret to a reasonable starting size could speed things up. for (Inkscape::XML::Node const *rch = repr.firstChild(); rch != NULL; rch = rch->next()) { if ( rch->type() == TEXT_NODE ) { - ret = g_string_append(ret, rch->content()); + ret += rch->content(); } } return ret; @@ -376,9 +376,9 @@ void SPStyleElem::read_content() { ParseTmp *parse_tmp = reinterpret_cast<ParseTmp *>(sac_handler->app_data); //XML Tree being used directly here while it shouldn't be. - GString *const text = concat_children(*getRepr()); + Glib::ustring const text = concat_children(*getRepr()); CRStatus const parse_status = - cr_parser_parse_buf (parser, reinterpret_cast<guchar *>(text->str), text->len, CR_UTF_8); + cr_parser_parse_buf (parser, reinterpret_cast<const guchar *>(text.c_str()), text.bytes(), CR_UTF_8); // std::cout << "SPStyeElem::read_content: result:" << std::endl; // const gchar* string = cr_stylesheet_to_string (document->style_sheet); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 2a88c5009..a13adbf0b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -359,7 +359,7 @@ gchar* SPText::description() const { int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); Inkscape::Util::Quantity q = Inkscape::Util::Quantity(style->font_size.computed, "px"); q.quantity *= this->i2doc_affine().descrim(); - GString *xs = g_string_new(q.string(sp_style_get_css_unit_string(unit)).c_str()); + Glib::ustring xs = q.string(sp_style_get_css_unit_string(unit)); char const *trunc = ""; Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) this); @@ -369,8 +369,8 @@ gchar* SPText::description() const { } char *ret = ( SP_IS_TEXT_TEXTPATH(this) - ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs->str) - : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs->str) ); + ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs.c_str()) + : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs.c_str()) ); return ret; } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index d6e491ac3..4f42400d4 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -559,14 +559,11 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); - GString *x = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); - GString *y = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); - GString *len = g_string_new(len_q.string(_desktop->namedview->display_units).c_str()); + Glib::ustring x = x_q.string(_desktop->namedview->display_units); + Glib::ustring y = y_q.string(_desktop->namedview->display_units); + Glib::ustring len = len_q.string(_desktop->namedview->display_units); Glib::ustring ret = format_tip(C_("Path handle tip", - "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); - g_string_free(x, TRUE); - g_string_free(y, TRUE); - g_string_free(len, TRUE); + "Move handle by %s, %s; angle %.2f°, length %s"), x.c_str(), y.c_str(), angle, len.c_str()); return ret; } @@ -1458,11 +1455,9 @@ Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); - GString *x = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); - GString *y = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); - Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); - g_string_free(x, TRUE); - g_string_free(y, TRUE); + Glib::ustring x = x_q.string(_desktop->namedview->display_units); + Glib::ustring y = y_q.string(_desktop->namedview->display_units); + Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x.c_str(), y.c_str()); return ret; } diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 712561b85..a670f577e 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -385,8 +385,8 @@ void ArcTool::drag(Geom::Point pt, guint state) { Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); - GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); + Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units); + Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; @@ -399,13 +399,10 @@ void ArcTool::drag(Geom::Point pt, guint state) { ratio_y = (int) rint (rdimy / rdimx); } - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs.c_str(), ys.c_str(), ratio_x, ratio_y); } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs.c_str(), ys.c_str()); } - - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); } void ArcTool::finishItem() { diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 276385335..69555d6c9 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -529,9 +529,9 @@ void Box3dTool::drag(guint /*state*/) { side->setAttribute("style", cur_style.data()); } else { // use default style - GString *pstring = g_string_new(""); - g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); - desktop->applyCurrentOrToolStyle (side, pstring->str, false); + Glib::ustring tool_path = Glib::ustring::compose("/tools/shapes/3dbox/%1", + box3d_side_axes_string(side)); + desktop->applyCurrentOrToolStyle (side, tool_path, false); } side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 77cb5b6f8..0db5c3954 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1291,7 +1291,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t Geom::Point rel = p - this->p[pc_point_to_compare]; Inkscape::Util::Quantity q = Inkscape::Util::Quantity(Geom::L2(rel), "px"); - GString *dist = g_string_new(q.string(desktop->namedview->display_units).c_str()); + Glib::ustring dist = q.string(desktop->namedview->display_units); double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) { @@ -1301,8 +1301,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t } } - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); - g_string_free(dist, false); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist.c_str()); } // this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used. diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 0a116e8cd..91725a00b 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -397,8 +397,8 @@ void RectTool::drag(Geom::Point const pt, guint state) { Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); - GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); + Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units); + Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; @@ -421,20 +421,25 @@ void RectTool::drag(Geom::Point const pt, guint state) { } if (!is_golden_ratio) { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("<b>Rectangle</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), + xs.c_str(), ys.c_str(), ratio_x, ratio_y); } else { if (ratio_y == 1) { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), + xs.c_str(), ys.c_str()); } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), + xs.c_str(), ys.c_str()); } } } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("<b>Rectangle</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), + xs.c_str(), ys.c_str()); } - - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); } void RectTool::finishItem() { diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 8e10935e8..9240df760 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -372,11 +372,10 @@ void SpiralTool::drag(Geom::Point const &p, guint state) { /* status text */ Inkscape::Util::Quantity q = Inkscape::Util::Quantity(rad, "px"); - GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str()); + Glib::ustring rads = q.string(desktop->namedview->display_units); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Spiral</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle"), - rads->str, sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001)); - g_string_free(rads, FALSE); + rads.c_str(), sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001)); } void SpiralTool::finishItem() { diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index d5e782f68..cda3389f9 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -389,14 +389,12 @@ void StarTool::drag(Geom::Point p, guint state) /* status text */ Inkscape::Util::Quantity q = Inkscape::Util::Quantity(r1, "px"); - GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str()); + Glib::ustring rads = q.string(desktop->namedview->display_units); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, ( this->isflatsided? _("<b>Polygon</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle") : _("<b>Star</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle") ), - rads->str, sp_round((arg1) * 180 / M_PI, 0.0001)); - - g_string_free(rads, FALSE); + rads.c_str(), sp_round((arg1) * 180 / M_PI, 0.0001)); } void StarTool::finishItem() { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index bab4ebb59..91d94cc22 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -575,13 +575,9 @@ bool TextTool::root_handler(GdkEvent* event) { // status text Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::X]), "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::Y]), "px"); - GString *xs = g_string_new(x_q.string(desktop->namedview->display_units).c_str()); - GString *ys = g_string_new(y_q.string(desktop->namedview->display_units).c_str()); - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs->str, ys->str); - - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); - + Glib::ustring xs = x_q.string(desktop->namedview->display_units); + Glib::ustring ys = y_q.string(desktop->namedview->display_units); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs.c_str(), ys.c_str()); } else if (!this->sp_event_context_knot_mouseover()) { SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); |
