[evolution] Weather calendar: Be able to change temperature unit



commit 84c50d3e3f69f6d4fa9d107acff4a4d8b069b117
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 22 19:18:23 2013 +0100

    Weather calendar: Be able to change temperature unit
    
    The ESourceExtension had a 'unit' property, but it was not used
    anywhere, thus I changed it to reflect possible values of current
    libgweather and made it used in the background.

 modules/cal-config-weather/e-source-weather.c      |   17 ++++++++-----
 modules/cal-config-weather/e-source-weather.h      |    5 ++-
 .../evolution-cal-config-weather.c                 |   24 ++++++++++++++++++++
 3 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/modules/cal-config-weather/e-source-weather.c b/modules/cal-config-weather/e-source-weather.c
index fb0ede7..0bdf8f3 100644
--- a/modules/cal-config-weather/e-source-weather.c
+++ b/modules/cal-config-weather/e-source-weather.c
@@ -140,7 +140,7 @@ e_source_weather_class_init (ESourceWeatherClass *class)
                        "Units",
                        "Metric or imperial units",
                        E_TYPE_SOURCE_WEATHER_UNITS,
-                       E_SOURCE_WEATHER_UNITS_METRIC,
+                       E_SOURCE_WEATHER_UNITS_FAHRENHEIT,
                        G_PARAM_READWRITE |
                        G_PARAM_CONSTRUCT |
                        E_SOURCE_PARAM_SETTING));
@@ -162,12 +162,15 @@ void
 e_source_weather_type_register (GTypeModule *type_module)
 {
        static const GEnumValue e_source_weather_units_values[] = {
-               { E_SOURCE_WEATHER_UNITS_METRIC,
-                 "E_SOURCE_WEATHER_UNITS_METRIC",
-                 "metric" },
-               { E_SOURCE_WEATHER_UNITS_IMPERIAL,
-                 "E_SOURCE_WEATHER_UNITS_IMPERIAL",
-                 "imperial" },
+               { E_SOURCE_WEATHER_UNITS_FAHRENHEIT,
+                 "E_SOURCE_WEATHER_UNITS_FAHRENHEIT",
+                 "fahrenheit" },
+               { E_SOURCE_WEATHER_UNITS_CENTIGRADE,
+                 "E_SOURCE_WEATHER_UNITS_CENTIGRADE",
+                 "centigrade" },
+               { E_SOURCE_WEATHER_UNITS_KELVIN,
+                 "E_SOURCE_WEATHER_UNITS_KELVIN",
+                 "kelvin" },
                { 0, NULL, NULL }
        };
 
diff --git a/modules/cal-config-weather/e-source-weather.h b/modules/cal-config-weather/e-source-weather.h
index fd191cf..765edd7 100644
--- a/modules/cal-config-weather/e-source-weather.h
+++ b/modules/cal-config-weather/e-source-weather.h
@@ -61,8 +61,9 @@ struct _ESourceWeatherClass {
 };
 
 typedef enum {
-       E_SOURCE_WEATHER_UNITS_METRIC,
-       E_SOURCE_WEATHER_UNITS_IMPERIAL
+       E_SOURCE_WEATHER_UNITS_FAHRENHEIT = 0,
+       E_SOURCE_WEATHER_UNITS_CENTIGRADE,
+       E_SOURCE_WEATHER_UNITS_KELVIN
 } ESourceWeatherUnits;
 
 GType          e_source_weather_get_type       (void);
diff --git a/modules/cal-config-weather/evolution-cal-config-weather.c 
b/modules/cal-config-weather/evolution-cal-config-weather.c
index 5bdd6f9..3d01669 100644
--- a/modules/cal-config-weather/evolution-cal-config-weather.c
+++ b/modules/cal-config-weather/evolution-cal-config-weather.c
@@ -207,6 +207,24 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
        context->location_entry = g_object_ref (widget);
        gtk_widget_show (widget);
 
+       widget = gtk_combo_box_text_new ();
+       /* keep the same order as in the ESourceWeatherUnits */
+       gtk_combo_box_text_append_text (
+               GTK_COMBO_BOX_TEXT (widget),
+               /* TRANSLATOR: This is the temperature in degrees Fahrenheit (\302\260 is U+00B0 DEGREE SIGN) 
*/
+               _("Fahrenheit (\302\260F)"));
+       gtk_combo_box_text_append_text (
+               GTK_COMBO_BOX_TEXT (widget),
+               /* TRANSLATOR: This is the temperature in degrees Celsius (\302\260 is U+00B0 DEGREE SIGN) */
+               _("Centigrade (\302\260C)"));
+       gtk_combo_box_text_append_text (
+               GTK_COMBO_BOX_TEXT (widget),
+               /* TRANSLATOR: This is the temperature in kelvin */
+               _("Kelvin (K)"));
+       e_source_config_insert_widget (
+               config, scratch_source, _("Units:"), widget);
+       gtk_widget_show (widget);
+
        e_source_config_add_refresh_interval (config, scratch_source);
 
        extension_name = E_SOURCE_EXTENSION_WEATHER_BACKEND;
@@ -222,6 +240,12 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
                gweather_location_ref (world),
                (GDestroyNotify) gweather_location_unref);
 
+       g_object_bind_property (
+               extension, "units",
+               widget, "active",
+               G_BINDING_BIDIRECTIONAL |
+               G_BINDING_SYNC_CREATE);
+
        gweather_location_unref (world);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]