diff options
author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2013-11-23 18:50:51 +0800 |
---|---|---|
committer | Fabiano FidĂȘncio <fidencio@redhat.com> | 2013-12-01 11:23:25 +0800 |
commit | ea219ed51b6728b2e8fd5927a2496bc36defee0f (patch) | |
tree | 4a27c9e785d9a48abaa63e680b5e6f268e5179d6 /modules/cal-config-weather/evolution-cal-config-weather.c | |
parent | 912785cb60d322c3e29825111261cbb3b0ffc62f (diff) | |
download | gsoc2013-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/cal-config-weather/evolution-cal-config-weather.c')
-rw-r--r-- | modules/cal-config-weather/evolution-cal-config-weather.c | 42 |
1 files changed, 39 insertions, 3 deletions
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", |