diff options
| author | Jan Lingscheid <jan.linscheid@auticon.de> | 2017-09-11 12:40:00 +0000 |
|---|---|---|
| committer | Jan Lingscheid <jan.lingscheid@auticon.de> | 2017-09-21 05:46:21 +0000 |
| commit | 9bedc7179f307d9ee937c527f7e879a08e6ce98d (patch) | |
| tree | c4e15fb85b471be5966ef37446a66dcfcc533b2b /src | |
| parent | Update expected renderings. (diff) | |
| download | inkscape-9bedc7179f307d9ee937c527f7e879a08e6ce98d.tar.gz inkscape-9bedc7179f307d9ee937c527f7e879a08e6ce98d.zip | |
Refactor Box3d::string_from_axes to use Glib::ustring
Diffstat (limited to 'src')
| -rw-r--r-- | src/axis-manip.cpp | 12 | ||||
| -rw-r--r-- | src/axis-manip.h | 2 | ||||
| -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/ui/tools/box3d-tool.cpp | 5 |
6 files changed, 19 insertions, 21 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..2231acc38 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -238,7 +238,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..d9145d17b 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/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 276385335..410fc3010 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -530,8 +530,9 @@ void Box3dTool::drag(guint /*state*/) { } 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 |
