[gnome-calculator] Use official unit from format instead of internal name (fixes #207)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Use official unit from format instead of internal name (fixes #207)
- Date: Tue, 23 Feb 2021 22:58:49 +0000 (UTC)
commit d18e57a514baa03946a08751c418ed28866fe04f
Author: Robert Roth <robert roth off gmail com>
Date: Wed Feb 24 00:58:32 2021 +0200
Use official unit from format instead of internal name (fixes #207)
lib/unit.vala | 5 +++++
src/math-converter.vala | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/lib/unit.vala b/lib/unit.vala
index b214d0c4..c59b58dc 100644
--- a/lib/unit.vala
+++ b/lib/unit.vala
@@ -379,6 +379,11 @@ public class Unit : Object
_symbols.append (symbol_name);
}
+ public string get_symbol_from_format ()
+ {
+ return _format.replace ("%s", "").replace (" ", "");
+ }
+
public bool matches_symbol (string symbol, bool case_sensitive = true)
{
foreach (var s in _symbols)
diff --git a/src/math-converter.vala b/src/math-converter.vala
index 9e4f8ed5..d0ae583d 100644
--- a/src/math-converter.vala
+++ b/src/math-converter.vala
@@ -248,7 +248,7 @@ public class MathConverter : Gtk.Grid
var z = convert_equation (x, out from_unit, out to_unit);
if (z != null && from_unit != null && to_unit != null)
{
- equation.set ("%s %s %s %s".printf(equation.serializer.to_string (x), from_unit.name,
_("in"), to_unit.name));
+ equation.set ("%s %s %s %s".printf(equation.serializer.to_string (x),
from_unit.get_symbol_from_format (), _("in"), to_unit.get_symbol_from_format ()));
equation.solve ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]