summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/unit.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/live_effects/parameter/unit.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/live_effects/parameter/unit.cpp')
-rw-r--r--src/live_effects/parameter/unit.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp
index 2f2d71679..0ee553e2c 100644
--- a/src/live_effects/parameter/unit.cpp
+++ b/src/live_effects/parameter/unit.cpp
@@ -1,15 +1,18 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_UNIT_CPP
-
/*
* Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "ui/widget/registered-widget.h"
+#include <glibmm/i18n.h>
+
#include "live_effects/parameter/unit.h"
#include "live_effects/effect.h"
-#include "ui/widget/registered-widget.h"
#include "verbs.h"
+#include "util/units.h"
+
+using Inkscape::Util::unit_table;
namespace Inkscape {
@@ -18,10 +21,10 @@ namespace LivePathEffect {
UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, SPUnitId default_value)
+ Effect* effect, Glib::ustring default_unit)
: Parameter(label, tip, key, wr, effect)
{
- defunit = &sp_unit_get_by_id(default_value);;
+ defunit = unit_table.getUnit(default_unit);
unit = defunit;
}
@@ -32,9 +35,8 @@ UnitParam::~UnitParam()
bool
UnitParam::param_readSVGValue(const gchar * strvalue)
{
- SPUnit const *newval = sp_unit_get_by_abbreviation(strvalue);
- if (newval) {
- param_set_value(newval);
+ if (strvalue) {
+ param_set_value(*unit_table.getUnit(strvalue));
return true;
}
return false;
@@ -43,25 +45,25 @@ UnitParam::param_readSVGValue(const gchar * strvalue)
gchar *
UnitParam::param_getSVGValue() const
{
- return g_strdup(sp_unit_get_abbreviation(unit));
+ return g_strdup(unit->abbr.c_str());
}
void
UnitParam::param_set_default()
{
- param_set_value(defunit);
+ param_set_value(*defunit);
}
void
-UnitParam::param_set_value(SPUnit const *val)
+UnitParam::param_set_value(Inkscape::Util::Unit const &val)
{
- unit = val;
+ unit = new Inkscape::Util::Unit(val);
}
const gchar *
-UnitParam::get_abbreviation()
+UnitParam::get_abbreviation() const
{
- return sp_unit_get_abbreviation(unit);
+ return unit->abbr.c_str();
}
Gtk::Widget *
@@ -74,7 +76,7 @@ UnitParam::param_newWidget()
param_effect->getRepr(),
param_effect->getSPDoc()));
- unit_menu->setUnit(unit);
+ unit_menu->setUnit(unit->abbr);
unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter"));
return dynamic_cast<Gtk::Widget *> (unit_menu);