From 26a6dbef5b24cbe25ac162eabffdfc98d035d1fc Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Tue, 1 Sep 2015 23:27:40 +0200 Subject: [PATCH] Add mmHg to the pressure units, fixes #68 ; cosmetic source fix --- ...hell.extensions.openweather.gschema.xml.in | 1 + data/weather-settings.ui | 1 + src/extension.js | 42 +++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/data/org.gnome.shell.extensions.openweather.gschema.xml.in b/data/org.gnome.shell.extensions.openweather.gschema.xml.in index be51e90..c740f27 100644 --- a/data/org.gnome.shell.extensions.openweather.gschema.xml.in +++ b/data/org.gnome.shell.extensions.openweather.gschema.xml.in @@ -23,6 +23,7 @@ + diff --git a/data/weather-settings.ui b/data/weather-settings.ui index b326e75..ed57bdd 100644 --- a/data/weather-settings.ui +++ b/data/weather-settings.ui @@ -639,6 +639,7 @@ at Torr psi + mmHg diff --git a/src/extension.js b/src/extension.js index 5616c0d..10dc631 100644 --- a/src/extension.js +++ b/src/extension.js @@ -109,15 +109,16 @@ const WeatherWindSpeedUnits = { }; const WeatherPressureUnits = { - hPa: 0, - inHg: 1, - bar: 2, - Pa: 3, - kPa: 4, - atm: 5, - at: 6, - Torr: 7, - psi: 8 + HPA: 0, + INHG: 1, + BAR: 2, + PA: 3, + KPA: 4, + ATM: 5, + AT: 6, + TORR: 7, + PSI: 8, + MMHG: 9 }; const WeatherPosition = { @@ -980,50 +981,55 @@ const OpenweatherMenuButton = new Lang.Class({ formatPressure: function(pressure) { let pressure_unit = 'hPa'; switch (this._pressure_units) { - case WeatherPressureUnits.inHg: + case WeatherPressureUnits.INHG: pressure = this.toInHg(pressure); pressure_unit = "inHg"; break; - case WeatherPressureUnits.hPa: + case WeatherPressureUnits.HPA: pressure = pressure.toFixed(this._decimal_places); pressure_unit = "hPa"; break; - case WeatherPressureUnits.bar: + case WeatherPressureUnits.BAR: pressure = (pressure / 1000).toFixed(this._decimal_places); pressure_unit = "bar"; break; - case WeatherPressureUnits.Pa: + case WeatherPressureUnits.PA: pressure = (pressure * 100).toFixed(this._decimal_places); pressure_unit = "Pa"; break; - case WeatherPressureUnits.kPa: + case WeatherPressureUnits.KPA: pressure = (pressure / 10).toFixed(this._decimal_places); pressure_unit = "kPa"; break; - case WeatherPressureUnits.atm: + case WeatherPressureUnits.ATM: pressure = (pressure * 0.000986923267).toFixed(this._decimal_places); pressure_unit = "atm"; break; - case WeatherPressureUnits.at: + case WeatherPressureUnits.AT: pressure = (pressure * 0.00101971621298).toFixed(this._decimal_places); pressure_unit = "at"; break; - case WeatherPressureUnits.Torr: + case WeatherPressureUnits.TORR: pressure = (pressure * 0.750061683).toFixed(this._decimal_places); pressure_unit = "Torr"; break; - case WeatherPressureUnits.psi: + case WeatherPressureUnits.PSI: pressure = (pressure * 0.0145037738).toFixed(this._decimal_places); pressure_unit = "psi"; break; + + case WeatherPressureUnits.MMHG: + pressure = (pressure * 0.750061683).toFixed(this._decimal_places); + pressure_unit = "mmHg"; + break; } return parseFloat(pressure).toLocaleString() + ' ' + pressure_unit; },