summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-09-27 08:15:49 +0000
committerTavmjong Bah <tavmjong@free.fr>2017-09-27 08:15:49 +0000
commit40d24d185b7e050deac650960464630f9af4b073 (patch)
treeec019942c30f0ae0ee010a86c2fdc6f04af713c2 /src/ui
parentFix error when vertical text has 'text-orientation' value 'sideways'. (diff)
parentRemove usage of GString in sp-object.cpp (diff)
downloadinkscape-40d24d185b7e050deac650960464630f9af4b073.tar.gz
inkscape-40d24d185b7e050deac650960464630f9af4b073.zip
Merge branch 'jali/inkscape-ustring_refactor'
Removes usage of GString.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/tool/node.cpp19
-rw-r--r--src/ui/tools/arc-tool.cpp11
-rw-r--r--src/ui/tools/box3d-tool.cpp6
-rw-r--r--src/ui/tools/pen-tool.cpp5
-rw-r--r--src/ui/tools/rect-tool.cpp23
-rw-r--r--src/ui/tools/spiral-tool.cpp5
-rw-r--r--src/ui/tools/star-tool.cpp6
-rw-r--r--src/ui/tools/text-tool.cpp10
8 files changed, 37 insertions, 48 deletions
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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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 &#215; %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&#176;; 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&#176;; with <b>Ctrl</b> to snap angle")
: _("<b>Star</b>: radius %s, angle %5g&#176;; 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 &#215; %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 &#215; %s"), xs.c_str(), ys.c_str());
} else if (!this->sp_event_context_knot_mouseover()) {
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);