Re: [evolution-patches] city names in weather calendar events



Well, in my testing the cities showed up in both, but it does seem a
little racey. Here's the simplified version.

-David

On Sun, 2005-01-09 at 13:46 +0100, Rodrigo Moya wrote:
> On Sun, 2005-01-09 at 04:25 -0700, David Trowbridge wrote:
> > 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.
> > 
> is there really need to keep track of the number of calendars? I would
> add the city name always, even when there's only 1 weather calendar.
> Also, doing it the way you have done it, the first calendar will never
> have the city name, but the 2nd and next ones will have it.
> 
> Apart from that, it looks ok, so could you please just change that?
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 21:53:06 -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
+
 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 21:53:06 -0000
@@ -57,6 +57,9 @@
 	/* Flags */
 	gboolean opened;
 
+	/* City (for summary) */
+	gchar *city;
+
 	/* Weather source */
 	EWeatherSource *source;
 };
@@ -266,21 +269,24 @@
 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 @@
 	/* 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 @@
 {
 	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 @@
 
 	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 @@
 	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);
 }


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