[Xfce4-commits] <xfce4-weather-plugin:master> Debug: Implement full astrodata dump.
Harald Judt
noreply at xfce.org
Sun Jan 12 01:08:06 CET 2014
Updating branch refs/heads/master
to 53b28e24869d9cbf11e7da97696ffd1119621f83 (commit)
from d525f6648f8556a23da40def8b24d662b799b314 (commit)
commit 53b28e24869d9cbf11e7da97696ffd1119621f83
Author: Harald Judt <h.judt at gmx.at>
Date: Sat May 11 12:25:08 2013 +0200
Debug: Implement full astrodata dump.
panel-plugin/weather-data.c | 2 +-
panel-plugin/weather-debug.c | 50 +++++++++++++++++++++++++++---------------
panel-plugin/weather-debug.h | 4 +++-
panel-plugin/weather.c | 4 +++-
4 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index 5f626e1..4a6946a 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -914,7 +914,7 @@ astrodata_clean(GArray *astrodata)
continue;
if (difftime(now_t, astro->day) >= 24 * 3600) {
weather_debug("Removing expired astrodata:");
- weather_dump(weather_dump_astrodata, astro);
+ weather_dump(weather_dump_astro, astro);
xml_astro_free(astro);
g_array_remove_index(astrodata, i--);
weather_debug("Remaining astrodata entries: %d", astrodata->len);
diff --git a/panel-plugin/weather-debug.c b/panel-plugin/weather-debug.c
index 2d30e0c..f15b239 100644
--- a/panel-plugin/weather-debug.c
+++ b/panel-plugin/weather-debug.c
@@ -202,34 +202,47 @@ weather_dump_icon_theme(const icon_theme *theme)
gchar *
-weather_dump_astrodata(const xml_astro *astro)
+weather_dump_astrodata(const GArray *astrodata)
+{
+ GString *out;
+ gchar *result, *line;
+ xml_astro *astro;
+ gint i;
+
+ if (!astrodata || astrodata->len <= 0)
+ return g_strdup("No astronomical data available.");
+
+ out = g_string_sized_new(1024);
+ g_string_assign(out, "Astronomical data:\n");
+ for (i = 0; i < astrodata->len; i++) {
+ astro = g_array_index(astrodata, xml_astro *, i);
+ line = weather_dump_astro(astro);
+ g_string_append(out, line);
+ g_free(line);
+ }
+ /* Free GString only and return its character data */
+ result = out->str;
+ g_string_free(out, FALSE);
+ return result;
+}
+
+
+gchar *
+weather_dump_astro(const xml_astro *astro)
{
gchar *out, *day, *sunrise, *sunset, *moonrise, *moonset;
if (!astro)
- return g_strdup("No astronomical data.");
+ return g_strdup("Astrodata: NULL.");
- day = format_date(astro->day, "%Y-%m-%d", TRUE);
+ day = format_date(astro->day, "%c", TRUE);
sunrise = format_date(astro->sunrise, "%c", TRUE);
sunset = format_date(astro->sunset, "%c", TRUE);
moonrise = format_date(astro->moonrise, "%c", TRUE);
moonset = format_date(astro->moonset, "%c", TRUE);
- out = g_strdup_printf("Astronomical data:\n"
- " --------------------------------------------\n"
- " day: %s\n"
- " --------------------------------------------\n"
- " sunrise: %s\n"
- " sunset: %s\n"
- " sun never rises: %s\n"
- " sun never sets: %s\n"
- " --------------------------------------------\n"
- " moonrise: %s\n"
- " moonset: %s\n"
- " moon never rises: %s\n"
- " moon never sets: %s\n"
- " moon phase: %s\n"
- " --------------------------------------------",
+ out = g_strdup_printf("day=%s, sun={%s, %s, %s, %s}, "
+ "moon={%s, %s, %s, %s, %s}\n",
day,
sunrise,
sunset,
@@ -240,6 +253,7 @@ weather_dump_astrodata(const xml_astro *astro)
YESNO(astro->moon_never_rises),
YESNO(astro->moon_never_sets),
astro->moon_phase);
+
g_free(day);
g_free(sunrise);
g_free(sunset);
diff --git a/panel-plugin/weather-debug.h b/panel-plugin/weather-debug.h
index b5aa53c..ef65b0c 100644
--- a/panel-plugin/weather-debug.h
+++ b/panel-plugin/weather-debug.h
@@ -66,7 +66,9 @@ gchar *weather_dump_timezone(const xml_timezone *timezone);
gchar *weather_dump_icon_theme(const icon_theme *theme);
-gchar *weather_dump_astrodata(const xml_astro *astrodata);
+gchar *weather_dump_astrodata(const GArray *astrodata);
+
+gchar *weather_dump_astro(const xml_astro *astro);
gchar *weather_dump_units_config(const units_config *units);
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index b7ea9ac..4d2dd11 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -387,7 +387,7 @@ update_current_astrodata(plugin_data *data)
difftime(data->current_astro->day, now_t) >= 24 * 3600)) {
data->current_astro = get_astro_data_for_day(data->astrodata, 0);
weather_debug("Updated astrodata for the present day.");
- weather_dump(weather_dump_astrodata, data->current_astro);
+ weather_dump(weather_dump_astro, data->current_astro);
}
}
@@ -518,6 +518,8 @@ cb_astro_update(SoupSession *session,
astrodata_clean(data->astrodata);
g_array_sort(data->astrodata, (GCompareFunc) xml_astro_compare);
update_current_astrodata(data);
+ if (! parsing_error)
+ weather_dump(weather_dump_astrodata, data->astrodata);
/* update icon */
data->night_time = is_night_time(data->current_astro);
More information about the Xfce4-commits
mailing list