[Xfce4-commits] <xfce4-weather-plugin:master> Add hidden option for cache file max age.

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


Updating branch refs/heads/master
         to 2081c67d3c8fe5290b4ef2365cb573f00d69223d (commit)
       from 05a906619fb3393e718b037f987d0cab9f1fd06d (commit)

commit 2081c67d3c8fe5290b4ef2365cb573f00d69223d
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Dec 9 19:24:49 2012 +0100

    Add hidden option for cache file max age.
    
    Some users might not want to use cached data at all, others might want
    to increase the expiration date. However, most users won't change this
    or won't even want to know about it, so make it a hidden option instead
    of putting it somewhere in the configuration dialog.

 panel-plugin/weather.c |    9 ++++++++-
 panel-plugin/weather.h |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 721efe8..5bd9217 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -549,6 +549,9 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
 
     data->timezone = xfce_rc_read_int_entry(rc, "timezone", 0);
 
+    data->cache_file_max_age =
+        xfce_rc_read_int_entry(rc, "cache_file_max_age", CACHE_FILE_MAX_AGE);
+
     if (data->units)
         g_slice_free(units_config, data->units);
     data->units = g_slice_new0(units_config);
@@ -657,6 +660,9 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
 
     xfce_rc_write_int_entry(rc, "timezone", data->timezone);
 
+    xfce_rc_write_int_entry(rc, "cache_file_max_age",
+                            data->cache_file_max_age);
+
     xfce_rc_write_int_entry(rc, "units_temperature", data->units->temperature);
     xfce_rc_write_int_entry(rc, "units_pressure", data->units->pressure);
     xfce_rc_write_int_entry(rc, "units_windspeed", data->units->windspeed);
@@ -881,7 +887,7 @@ read_cache_file(plugin_data *data)
     CACHE_READ_STRING(timestring, "cache_date");
     cache_date_t = parse_timestring(timestring, NULL);
     g_free(timestring);
-    if (difftime(now_t, cache_date_t) > CACHE_FILE_MAX_AGE) {
+    if (difftime(now_t, cache_date_t) > data->cache_file_max_age) {
         weather_debug("Cache file is too old and will not be used.");
         CACHE_FREE_VARS();
         return;
@@ -1313,6 +1319,7 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
     data->plugin = plugin;
     data->units = g_slice_new0(units_config);
     data->weatherdata = g_slice_new0(xml_weather);
+    data->cache_file_max_age = CACHE_FILE_MAX_AGE;
     data->show_scrollbox = TRUE;
     data->scrollbox_lines = 1;
     data->scrollbox_animate = TRUE;
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 3bb82c3..a27c18a 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -87,6 +87,7 @@ typedef struct {
     gchar *lon;
     gint msl;
     gint timezone;
+    gint cache_file_max_age;
     gboolean night_time;
 
     units_config *units;


More information about the Xfce4-commits mailing list