diff options
| author | David Trowbridge <trowbrds@cs.colorado.edu> | 2005-01-10 12:35:37 +0000 |
|---|---|---|
| committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2005-01-10 12:35:37 +0000 |
| commit | 3f1443328b55c21b7037716fb223d4a1043c4080 (patch) | |
| tree | 7a11311654f2cf65ff08f04d2a11896b49644b42 /calendar/backends/weather | |
| parent | ae25ac13632c3b98cdee9ee3cd1a66cf6a18b62d (diff) | |
| download | evolution-data-server-3f1443328b55c21b7037716fb223d4a1043c4080.tar.gz | |
add the city name to the summary field
2005-01-10 David Trowbridge <trowbrds@cs.colorado.edu>
* backends/weather/e-cal-backend-weather.c: add the city name to the
summary field
Diffstat (limited to 'calendar/backends/weather')
| -rw-r--r-- | calendar/backends/weather/e-cal-backend-weather.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c index 90b1c158e..2b8a976ce 100644 --- a/calendar/backends/weather/e-cal-backend-weather.c +++ b/calendar/backends/weather/e-cal-backend-weather.c @@ -57,6 +57,9 @@ struct _ECalBackendWeatherPrivate { /* Flags */ gboolean opened; + /* City (for summary) */ + gchar *city; + /* Weather source */ EWeatherSource *source; }; @@ -266,21 +269,24 @@ cmtoin (float cm) static ECalComponent* create_weather (ECalBackendWeather *cbw, WeatherForecast *report) { - ECalComponent *cal_comp; - ECalComponentText comp_summary; - icalcomponent *ical_comp; - struct icaltimetype itt; - ECalComponentDateTime dt; - const char *uid; - GSList *text_list = NULL; - ECalComponentText *description; - char *pop, *snow; - ESource *source; - gboolean fahrenheit, inches; - const char *format; + ECalBackendWeatherPrivate *priv; + ECalComponent *cal_comp; + ECalComponentText comp_summary; + icalcomponent *ical_comp; + struct icaltimetype itt; + ECalComponentDateTime dt; + const char *uid; + GSList *text_list = NULL; + ECalComponentText *description; + char *pop, *snow; + ESource *source; + gboolean fahrenheit, inches; + const char *format; g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL); + priv = cbw->priv; + source = e_cal_backend_get_source (E_CAL_BACKEND (cbw)); format = e_source_get_property (source, "temperature"); if (format == NULL) @@ -318,14 +324,14 @@ create_weather (ECalBackendWeather *cbw, WeatherForecast *report) /* The summary is the high or high/low temperatures */ if (report->high == report->low) { if (fahrenheit) - comp_summary.value = g_strdup_printf (_("%.1f°F"), ctof (report->high)); + comp_summary.value = g_strdup_printf (_("%.1f°F - %s"), ctof (report->high), priv->city); else - comp_summary.value = g_strdup_printf (_("%.1f°C"), report->high); + comp_summary.value = g_strdup_printf (_("%.1f°C - %s"), report->high, priv->city); } else { if (fahrenheit) - comp_summary.value = g_strdup_printf (_("%.1f/%.1f°F"), ctof (report->high), ctof (report->low)); + comp_summary.value = g_strdup_printf (_("%.1f/%.1f°F - %s"), ctof (report->high), ctof (report->low), priv->city); else - comp_summary.value = g_strdup_printf (_("%.1f/%.1f°C"), report->high, report->low); + comp_summary.value = g_strdup_printf (_("%.1f/%.1f°C - %s"), report->high, report->low, priv->city); } comp_summary.altrep = NULL; e_cal_component_set_summary (cal_comp, &comp_summary); @@ -426,12 +432,18 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on { ECalBackendWeather *cbw; ECalBackendWeatherPrivate *priv; + char *uri; cbw = E_CAL_BACKEND_WEATHER (backend); priv = cbw->priv; + uri = e_cal_backend_get_uri (E_CAL_BACKEND (backend)); + if (priv->city) + g_free (priv->city); + priv->city = g_strdup (strrchr (uri, '/') + 1); + if (!priv->cache) { - priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (backend))); + priv->cache = e_cal_backend_cache_new (uri); if (!priv->cache) { e_cal_backend_notify_error (E_CAL_BACKEND (cbw), _("Could not create cache file")); @@ -787,6 +799,11 @@ e_cal_backend_weather_finalize (GObject *object) g_hash_table_destroy (priv->zones); + if (priv->city) { + g_free (priv->city); + priv->city = NULL; + } + g_free (priv); cbw->priv = NULL; @@ -809,6 +826,7 @@ e_cal_backend_weather_init (ECalBackendWeather *cbw, ECalBackendWeatherClass *cl priv->opened = FALSE; priv->source = NULL; priv->cache = NULL; + priv->city = NULL; priv->zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_zone); } |
