[Xfce4-commits] <xfce4-weather-plugin:master> Fix sunrise/sunset icon update.

Harald Judt noreply at xfce.org
Sat Jan 26 12:20:03 CET 2013


Updating branch refs/heads/master
         to 0d49e2ca9e41722b347c58d5f5cb5938e0e3c0cc (commit)
       from d2b818c4bfb83ba1b3a41dfd0daf3c80e1509cc4 (commit)

commit 0d49e2ca9e41722b347c58d5f5cb5938e0e3c0cc
Author: Harald Judt <h.judt at gmx.at>
Date:   Sat Jan 26 09:40:22 2013 +0100

    Fix sunrise/sunset icon update.
    
    Also print current time and date for more useful debugging info.

 panel-plugin/weather.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 53f18f2..92f3123 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -648,6 +648,7 @@ schedule_next_wakeup(plugin_data *data)
     time_t now_t = time(NULL), future_t;
     struct tm now_tm;
     gdouble diff;
+    gchar *date;
 
     if (data->update_timer) {
         g_source_remove(data->update_timer);
@@ -663,13 +664,16 @@ schedule_next_wakeup(plugin_data *data)
                             "weather data download");
     SCHEDULE_WAKEUP_COMPARE(data->conditions_update->next,
                             "current conditions update");
+
     /* If astronomical data is unavailable, current conditions update
        will usually handle night/day. */
     if (data->astrodata) {
-        if (difftime(data->astrodata->sunrise, now_t) > 0)
+        if (data->night_time &&
+            difftime(data->astrodata->sunrise, now_t) >= 0)
             SCHEDULE_WAKEUP_COMPARE(data->astrodata->sunrise,
                                     "sunrise icon change");
-        if (difftime(data->astrodata->sunset, now_t) > 0)
+        if (!data->night_time &&
+            difftime(data->astrodata->sunset, now_t) >= 0)
             SCHEDULE_WAKEUP_COMPARE(data->astrodata->sunset,
                                     "sunset icon change");
     }
@@ -686,14 +690,19 @@ schedule_next_wakeup(plugin_data *data)
         data->next_wakeup_reason = "forced";
     }
 
+    date = format_date(now_t, "%Y-%m-%d %H:%M:%S", TRUE);
     data->update_timer =
         g_timeout_add_seconds((guint) diff,
                               (GSourceFunc) update_handler, data);
     if (!strcmp(data->next_wakeup_reason, "regular check"))
-        weather_debug("Running regular check for updates, interval %d secs.",
-                      UPDATE_INTERVAL);
-    else
+        weather_debug("[%s]: Running regular check for updates, "
+                      "interval %d secs.", date, UPDATE_INTERVAL);
+    else {
         weather_dump(weather_dump_plugindata, data);
+        weather_debug("[%s]: Next wakeup in %.0f seconds, reason: %s",
+                      date, diff, data->next_wakeup_reason);
+    }
+    g_free(date);
 }
 
 


More information about the Xfce4-commits mailing list