[Xfce4-commits] <xfce4-weather-plugin:master> Immediately start download after timeout has expired.

Harald Judt noreply at xfce.org
Wed Nov 28 00:00:03 CET 2012


Updating branch refs/heads/master
         to 03891ad18638a78604f4d1dd380655db85157b99 (commit)
       from 4d939ceb37948fac34503d9dee3016aa14df8b4f (commit)

commit 03891ad18638a78604f4d1dd380655db85157b99
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Nov 27 23:20:47 2012 +0100

    Immediately start download after timeout has expired.
    
    After the update delay timer has stopped, start the download and
    do not wait for the usual update interval.

 panel-plugin/weather-config.c |   17 ++++++++---------
 panel-plugin/weather.c        |    8 +++++---
 panel-plugin/weather.h        |    2 ++
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 8d53d1c..46aa068 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -32,7 +32,7 @@
 #include "weather-scrollbox.h"
 
 #define GEONAMES_USERNAME "xfce4weatherplugin"
-#define UPDATE_TIMER_DELAY 3
+#define UPDATE_TIMER_DELAY 7
 #define OPTIONS_N 13
 #define BORDER 4
 #define LOC_NAME_MAX_LEN 50
@@ -114,18 +114,13 @@ static gboolean
 schedule_data_update(gpointer user_data)
 {
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
-    xfceweather_data *data;
 
     if (dialog == NULL)
         return FALSE;
 
+    /* force update of downloaded data */
     weather_debug("Delayed update timer expired, now scheduling data update.");
-
-    /* force update of downloaded data, download will be performed by
-     * main routine */
-    data = dialog->wd;
-    memset(&data->last_data_update, 0, sizeof(data->last_data_update));
-    memset(&data->last_astro_update, 0, sizeof(data->last_astro_update));
+    update_weatherdata_with_reset(dialog->wd);
     gtk_spinner_stop(GTK_SPINNER(dialog->update_spinner));
     return FALSE;
 }
@@ -135,9 +130,14 @@ static void
 schedule_delayed_data_update(xfceweather_dialog *dialog)
 {
     weather_debug("Starting delayed data update.");
+    /* cancel any update that was scheduled before */
     if (dialog->timer_id)
         g_source_remove(dialog->timer_id);
 
+    /* stop any updates that could be performed by weather.c */
+    if (dialog->wd->updatetimeout)
+        g_source_remove(dialog->wd->updatetimeout);
+
     gtk_spinner_start(GTK_SPINNER(dialog->update_spinner));
     dialog->timer_id =
         g_timeout_add_seconds(UPDATE_TIMER_DELAY,
@@ -456,7 +456,6 @@ create_location_page(xfceweather_dialog *dialog)
         gtk_entry_set_text(GTK_ENTRY(dialog->text_loc_name), _("Unset"));
     /* update spinner */
     dialog->update_spinner = gtk_spinner_new();
-    gtk_misc_set_alignment(GTK_MISC(dialog->update_spinner), 1, 0.5);
     gtk_box_pack_start(GTK_BOX(hbox), dialog->update_spinner, TRUE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, BORDER);
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index f31163d..a8ab999 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -661,14 +661,16 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
 }
 
 
-static void
+void
 update_weatherdata_with_reset(xfceweather_data *data)
 {
     if (data->updatetimeout)
         g_source_remove(data->updatetimeout);
 
-    data->last_data_update = 0;
-    data->last_conditions_update = 0;
+    memset(&data->last_data_update, 0, sizeof(data->last_data_update));
+    memset(&data->last_astro_update, 0, sizeof(data->last_astro_update));
+    memset(&data->last_conditions_update, 0,
+           sizeof(data->last_conditions_update));
     update_weatherdata(data);
 
     data->updatetimeout =
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index d7e45bf..782f2c7 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -103,6 +103,8 @@ void update_icon(xfceweather_data *data);
 
 void update_scrollbox(xfceweather_data *data);
 
+void update_weatherdata_with_reset(xfceweather_data *data);
+
 GArray* labels_clear(GArray *array);
 
 G_END_DECLS


More information about the Xfce4-commits mailing list