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 | |
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
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | m4/evo_check_langinfo.m4 | 25 | ||||
-rw-r--r-- | modules/cal-config-weather/e-source-weather.c | 4 | ||||
-rw-r--r-- | modules/cal-config-weather/evolution-cal-config-weather.c | 42 |
4 files changed, 76 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index ae7fb24b2e..36e7e5d5d2 100644 --- a/configure.ac +++ b/configure.ac @@ -276,6 +276,16 @@ AM_CONDITIONAL(HAVE_WINDRES, test "x$WINDRES" != "x:") AC_SUBST(WINDRES) dnl ********************************** +dnl Check for functions +dnl ********************************** +AC_CHECK_FUNCS(nl_langinfo) + +dnl ********************************** +dnl Check for nl_langinfo features +dnl ********************************** +EVO_CHECK_LANGINFO([_NL_MEASUREMENT_MEASUREMENT]) + +dnl ********************************** dnl Check for base dependencies early. dnl ********************************** PKG_CHECK_MODULES([GNOME_PLATFORM], diff --git a/m4/evo_check_langinfo.m4 b/m4/evo_check_langinfo.m4 new file mode 100644 index 0000000000..a59ab29d4f --- /dev/null +++ b/m4/evo_check_langinfo.m4 @@ -0,0 +1,25 @@ +dnl EVO_CHECK_LANGINFO(detail) +dnl Checks if the given langinfo detail is supported +AC_DEFUN([EVO_CHECK_LANGINFO],[ + AS_VAR_PUSHDEF([ac_cv_langinfo_detail], + [ac_cv_langinfo_]m4_tolower($1)) + + AC_MSG_CHECKING([for nl_langinfo ($1)]) + + AC_LANG_PUSH(C) + + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <langinfo.h>]], + [[char *detail = nl_langinfo ($1);]])], + [ac_cv_langinfo_detail=yes], + [ac_cv_langinfo_detail=no]) + + AC_LANG_POP(C) + + AS_VAR_IF([ac_cv_langinfo_detail], [yes], + [AC_DEFINE([HAVE_]m4_toupper($1), 1, [Have nl_langinfo ($1)])]) + + AC_MSG_RESULT([$ac_cv_langinfo_detail]) + AS_VAR_POPDEF([ac_cv_langinfo_detail]) +]) 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", |