[libgweather/wip/forecasts] Fix day/night icons for forecast infos



commit 231d7adb0831bc838e1b5fc86529457e8920ce22
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Dec 1 18:55:49 2012 +0100

    Fix day/night icons for forecast infos
    
    We need to do the sun calculations for all GWeatherInfos, not just the
    master one, as those values are used in get_icon_name().
    Also, fix get_icon_name() to use the time the info refers to, not current
    time.

 libgweather/weather-iwin.c  |    1 +
 libgweather/weather-yahoo.c |    3 +++
 libgweather/weather.c       |    4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/libgweather/weather-iwin.c b/libgweather/weather-iwin.c
index 0a446e0..20add27 100644
--- a/libgweather/weather-iwin.c
+++ b/libgweather/weather-iwin.c
@@ -177,6 +177,7 @@ parseForecastXml (const char *buff, GWeatherInfo *master_info)
                         for (i = 0; i < 7;  i++) {
                             GWeatherInfo *nfo = _gweather_info_new_clone (master_info);
 			    nfo->priv->update = update_times[i];
+			    calc_sun_time (nfo, nfo->priv->update);
 
                             if (nfo)
                                 res = g_slist_append (res, nfo);
diff --git a/libgweather/weather-yahoo.c b/libgweather/weather-yahoo.c
index 0e8be62..5bb864b 100644
--- a/libgweather/weather-yahoo.c
+++ b/libgweather/weather-yahoo.c
@@ -201,6 +201,9 @@ make_info_from_node (GWeatherInfo *master_info,
 	priv->valid = FALSE;
     xmlFree (val);
 
+    /* Calculate sun to get the right icon */
+    calc_sun_time (info, info->priv->update);
+
     return info;
 }
 
diff --git a/libgweather/weather.c b/libgweather/weather.c
index ae8d89a..4952106 100644
--- a/libgweather/weather.c
+++ b/libgweather/weather.c
@@ -327,7 +327,7 @@ requests_init (GWeatherInfo *info)
 void request_done (GWeatherInfo *info, gboolean ok)
 {
     if (ok) {
-	(void) calc_sun (info);
+	calc_sun_time (info, info->priv->update);
 	info->priv->moonValid = info->priv->valid && calc_moon (info);
     }
     if (!--info->priv->requests_pending)
@@ -1187,7 +1187,7 @@ gweather_info_get_icon_name (GWeatherInfo *info)
     else if (priv->polarNight)
 	daytime = FALSE;
     else {
-	current_time = time (NULL);
+	current_time = priv->update;
 	daytime =
 	    ( !priv->sunriseValid || (current_time >= priv->sunrise) ) &&
 	    ( !priv->sunsetValid || (current_time < priv->sunset) );



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