aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2013-11-23 18:50:51 +0800
committerFabiano FidĂȘncio <fidencio@redhat.com>2013-12-01 11:23:25 +0800
commitea219ed51b6728b2e8fd5927a2496bc36defee0f (patch)
tree4a27c9e785d9a48abaa63e680b5e6f268e5179d6 /modules
parent912785cb60d322c3e29825111261cbb3b0ffc62f (diff)
downloadgsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar.gz
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar.bz2
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar.lz
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar.xz
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.tar.zst
gsoc2013-evolution-ea219ed51b6728b2e8fd5927a2496bc36defee0f.zip
Bug #715057 - Weather calendar is using Fahrenheit units as default
Diffstat (limited to 'modules')
-rw-r--r--modules/cal-config-weather/e-source-weather.c4
-rw-r--r--modules/cal-config-weather/evolution-cal-config-weather.c42
2 files changed, 41 insertions, 5 deletions
diff --git a/modules/cal-config-weather/e-source-weather.c b/modules/cal-config-weather/e-source-weather.c
index 0bdf8f304e..13344361ef 100644
--- a/modules/cal-config-weather/e-source-weather.c
+++ b/modules/cal-config-weather/e-source-weather.c
@@ -138,9 +138,9 @@ e_source_weather_class_init (ESourceWeatherClass *class)
g_param_spec_enum (
"units",
"Units",
- "Metric or imperial units",
+ "Fahrenheit, Centigrade or Kelvin units",
E_TYPE_SOURCE_WEATHER_UNITS,
- E_SOURCE_WEATHER_UNITS_FAHRENHEIT,
+ E_SOURCE_WEATHER_UNITS_CENTIGRADE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
E_SOURCE_PARAM_SETTING));
diff --git a/modules/cal-config-weather/evolution-cal-config-weather.c b/modules/cal-config-weather/evolution-cal-config-weather.c
index 3d01669e8b..25b3c2bda0 100644
--- a/modules/cal-config-weather/evolution-cal-config-weather.c
+++ b/modules/cal-config-weather/evolution-cal-config-weather.c
@@ -29,6 +29,10 @@
#include "e-source-weather.h"
+#if HAVE_NL_LANGINFO
+#include <langinfo.h>
+#endif
+
typedef ESourceConfigBackend ECalConfigWeather;
typedef ESourceConfigBackendClass ECalConfigWeatherClass;
@@ -159,6 +163,28 @@ cal_config_weather_string_to_location (GBinding *binding,
return match != NULL;
}
+#if HAVE_NL_LANGINFO
+static gboolean
+is_locale_metric (void)
+{
+ const char *fmt;
+ fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
+
+ if (fmt && *fmt == 2)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+static ESourceWeatherUnits
+cal_config_weather_get_units_from_locale (void)
+{
+ return is_locale_metric() ?
+ E_SOURCE_WEATHER_UNITS_CENTIGRADE :
+ E_SOURCE_WEATHER_UNITS_FAHRENHEIT;
+}
+#endif
+
static gboolean
cal_config_weather_allow_creation (ESourceConfigBackend *backend)
{
@@ -185,8 +211,12 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
GWeatherLocation *world;
GtkWidget *widget;
Context *context;
- const gchar *extension_name;
const gchar *uid;
+#if HAVE_NL_LANGINFO
+ gboolean is_new_source;
+
+ is_new_source = !e_source_has_extension (scratch_source, E_SOURCE_EXTENSION_WEATHER_BACKEND);
+#endif
context = g_slice_new (Context);
uid = e_source_get_uid (scratch_source);
@@ -227,8 +257,14 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
e_source_config_add_refresh_interval (config, scratch_source);
- extension_name = E_SOURCE_EXTENSION_WEATHER_BACKEND;
- extension = e_source_get_extension (scratch_source, extension_name);
+ extension = e_source_get_extension (scratch_source, E_SOURCE_EXTENSION_WEATHER_BACKEND);
+
+#if HAVE_NL_LANGINFO
+ if (is_new_source)
+ e_source_weather_set_units (
+ E_SOURCE_WEATHER (extension),
+ cal_config_weather_get_units_from_locale ());
+#endif
g_object_bind_property_full (
extension, "location",