[evolution-patches] city names in weather calendar events
- From: David Trowbridge <David Trowbridge Colorado edu>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] city names in weather calendar events
- Date: Sun, 09 Jan 2005 04:25:35 -0700
Nat pointed out to me today that it's pretty hard to distinguish which
calendar is which just based on color if there are multiple weather
calendars. This adds the name of the city to the summary if there's more
than one calendar.
-David
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.371
diff -u -r1.371 ChangeLog
--- calendar/ChangeLog 8 Jan 2005 09:36:32 -0000 1.371
+++ calendar/ChangeLog 9 Jan 2005 11:12:13 -0000
@@ -1,3 +1,8 @@
+2005-01-09 David Trowbridge <trowbrds cs colorado edu>
+
+ * backends/weather/e-cal-backend-weather.c: add the city name to the
+ summary field if more than one weather calendar exists
+
2005-01-08 JP Rosevear <jpr novell com>
* backends/weather/e-cal-backend-weather.c (create_weather): make
Index: calendar/backends/weather/e-cal-backend-weather.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/weather/e-cal-backend-weather.c,v
retrieving revision 1.2
diff -u -r1.2 e-cal-backend-weather.c
--- calendar/backends/weather/e-cal-backend-weather.c 8 Jan 2005 09:36:33 -0000 1.2
+++ calendar/backends/weather/e-cal-backend-weather.c 9 Jan 2005 11:12:13 -0000
@@ -33,6 +33,8 @@
static gboolean begin_retrieval_cb (ECalBackendWeather *cbw);
static ECalComponent* create_weather (ECalBackendWeather *cbw, WeatherForecast *report);
+static gint ncalendars;
+
/* Private part of the ECalBackendWeather structure */
struct _ECalBackendWeatherPrivate {
/* URI to get remote weather data from */
@@ -57,6 +59,9 @@
/* Flags */
gboolean opened;
+ /* City (for summary) */
+ gchar *city;
+
/* Weather source */
EWeatherSource *source;
};
@@ -266,21 +271,25 @@
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;
+ char *city;
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)
@@ -293,6 +302,11 @@
else
inches = (strcmp (format, "inches") == 0);
+ if (ncalendars >= 2)
+ city = g_strdup_printf (" - %s", priv->city);
+ else
+ city = g_strdup ("");
+
/* create the component and event object */
ical_comp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
cal_comp = e_cal_component_new ();
@@ -318,18 +332,20 @@
/* 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), city);
else
- comp_summary.value = g_strdup_printf (_("%.1f°C"), report->high);
+ comp_summary.value = g_strdup_printf (_("%.1f°C%s"), report->high, 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), 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, city);
}
comp_summary.altrep = NULL;
e_cal_component_set_summary (cal_comp, &comp_summary);
+ g_free (city);
+
if (report->pop != 0)
pop = g_strdup_printf (_("%d%% chance of precipitation\n"), report->pop);
else
@@ -426,12 +442,18 @@
{
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,9 +809,16 @@
g_hash_table_destroy (priv->zones);
+ if (priv->city) {
+ g_free (priv->city);
+ priv->city = NULL;
+ }
+
g_free (priv);
cbw->priv = NULL;
+ ncalendars--;
+
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
@@ -809,8 +838,11 @@
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);
+
+ ncalendars++;
}
/* Class initialization function for the weather backend */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]