[Xfce4-commits] <xfce4-weather-plugin:master> Only clear weather data on location changes, not on all downloads.

Harald Judt noreply at xfce.org
Sun Dec 9 23:44:18 CET 2012


Updating branch refs/heads/master
         to 3105a3adee74c89f40e27e89b8a55c8509e441de (commit)
       from 9a6b1f82ebe0152ba6d56222a595d3331269c102 (commit)

commit 3105a3adee74c89f40e27e89b8a55c8509e441de
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Dec 9 19:24:30 2012 +0100

    Only clear weather data on location changes, not on all downloads.
    
    Clearing weather data is only required when the location changes, otherwise
    the downloaded data can be merged.

 panel-plugin/weather-config.c |    3 ++-
 panel-plugin/weather.c        |   13 ++++++++++---
 panel-plugin/weather.h        |    3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 1669572..dd70bae 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -149,7 +149,8 @@ schedule_data_update(gpointer user_data)
 
     /* force update of downloaded data */
     weather_debug("Delayed update timer expired, now scheduling data update.");
-    update_weatherdata_with_reset(dialog->wd);
+    update_weatherdata_with_reset(dialog->wd, TRUE);
+
     gtk_spinner_stop(GTK_SPINNER(dialog->update_spinner));
     gtk_widget_hide(GTK_WIDGET(dialog->update_spinner));
     return FALSE;
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 5eb0c88..2c3ceed 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -682,7 +682,7 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
 
 
 void
-update_weatherdata_with_reset(xfceweather_data *data)
+update_weatherdata_with_reset(xfceweather_data *data, gboolean clear)
 {
     if (data->updatetimeout)
         g_source_remove(data->updatetimeout);
@@ -691,6 +691,13 @@ update_weatherdata_with_reset(xfceweather_data *data)
     memset(&data->last_astro_update, 0, sizeof(data->last_astro_update));
     memset(&data->last_conditions_update, 0,
            sizeof(data->last_conditions_update));
+
+    /* clear existing weather data, needed for location changes */
+    if (clear && data->weatherdata) {
+        xml_weather_free(data->weatherdata);
+        data->weatherdata = g_slice_new0(xml_weather);
+    }
+
     update_weatherdata(data);
 
     data->updatetimeout =
@@ -740,7 +747,7 @@ cb_click(GtkWidget *widget,
     if (event->button == 1)
         forecast_click(widget, user_data);
     else if (event->button == 2)
-        update_weatherdata_with_reset(data);
+        update_weatherdata_with_reset(data, FALSE);
 
     return FALSE;
 }
@@ -767,7 +774,7 @@ mi_click(GtkWidget *widget,
 {
     xfceweather_data *data = (xfceweather_data *) user_data;
 
-    update_weatherdata_with_reset(data);
+    update_weatherdata_with_reset(data, FALSE);
 }
 
 
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 042ec54..46da1f4 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -117,7 +117,8 @@ void update_icon(xfceweather_data *data);
 
 void update_scrollbox(xfceweather_data *data);
 
-void update_weatherdata_with_reset(xfceweather_data *data);
+void update_weatherdata_with_reset(xfceweather_data *data,
+                                   gboolean clear);
 
 GArray *labels_clear(GArray *array);
 


More information about the Xfce4-commits mailing list