diff --git a/panel-plugin/weather-debug.c b/panel-plugin/weather-debug.c index c168b8e..6455c9d 100644 --- a/panel-plugin/weather-debug.c +++ b/panel-plugin/weather-debug.c @@ -230,7 +230,7 @@ weather_dump_astrodata(const GArray *astrodata) gchar * weather_dump_astro(const xml_astro *astro) { - gchar *out, *day, *sunrise, *sunset, *moonrise, *moonset; + gchar *out, *day, *sunrise, *sunset, *moonrise, *moonset, *moonrisenext, *moonsetnext; if (!astro) return g_strdup("Astrodata: NULL."); @@ -240,6 +240,8 @@ weather_dump_astro(const xml_astro *astro) sunset = format_date(astro->sunset, "%c", TRUE); moonrise = format_date(astro->moonrise, "%c", TRUE); moonset = format_date(astro->moonset, "%c", TRUE); + moonrisenext = format_date(astro->moonrisenext, "%c", TRUE); + moonsetnext = format_date(astro->moonsetnext, "%c", TRUE); out = g_strdup_printf("day=%s, sun={%s, %s, %s, %s}, " "moon={%s, %s, %s, %s, %s}\n", @@ -250,6 +252,8 @@ weather_dump_astro(const xml_astro *astro) YESNO(astro->sun_never_sets), moonrise, moonset, + moonrisenext, + moonsetnext, YESNO(astro->moon_never_rises), YESNO(astro->moon_never_sets), astro->moon_phase); @@ -259,6 +263,8 @@ weather_dump_astro(const xml_astro *astro) g_free(sunset); g_free(moonrise); g_free(moonset); + g_free(moonrisenext); + g_free(moonsetnext); return out; } diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c index acd7cf9..77a6c9a 100644 --- a/panel-plugin/weather-parsers.c +++ b/panel-plugin/weather-parsers.c @@ -368,7 +368,7 @@ parse_astro_location(xmlNode *cur_node, xml_astro *astro) { xmlNode *child_node; - gchar *sunrise, *sunset, *moonrise, *moonset; + gchar *sunrise, *sunset, *moonrise, *moonset, *moonrisenext, *moonsetnext; gchar *never_rises, *never_sets; for (child_node = cur_node->children; child_node; @@ -427,6 +427,14 @@ parse_astro_location(xmlNode *cur_node, moonset = PROP(child_node, "set"); astro->moonset = parse_timestring(moonset, NULL, FALSE); xmlFree(moonset); + + moonrisenext = PROP(child_node, "rise_next"); + astro->moonrisenext = parse_timestring(moonrisenext, NULL, FALSE); + xmlFree(moonrisenext); + + moonsetnext = PROP(child_node, "set_next"); + astro->moonsetnext = parse_timestring(moonsetnext, NULL, FALSE); + xmlFree(moonsetnext); astro->moon_phase = PROP(child_node, "phase"); } @@ -458,7 +466,7 @@ parse_astro_time(xmlNode *cur_node) /* - * Look at http://api.yr.no/weatherapi/sunrise/1.0/schema for information + * Look at http://api.yr.no/weatherapi/sunrise/1.1/schema for information * of elements and attributes to expect. */ gboolean @@ -686,6 +694,8 @@ xml_astro_copy(const xml_astro *src) dst->sun_never_sets = src->sun_never_sets; dst->moonrise = src->moonrise; dst->moonset = src->moonset; + dst->moonrisenext = src->moonrisenext; + dst->moonsetnext = src->moonsetnext; dst->moon_never_rises = src->moon_never_rises; dst->moon_never_sets = src->moon_never_sets; dst->moon_phase = g_strdup(src->moon_phase); diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h index 71e3f4d..138360e 100644 --- a/panel-plugin/weather-parsers.h +++ b/panel-plugin/weather-parsers.h @@ -89,6 +89,8 @@ typedef struct { time_t moonrise; time_t moonset; + time_t moonrisenext; + time_t moonsetnext; gboolean moon_never_rises; gboolean moon_never_sets; gchar *moon_phase; diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c index 10aa72a..ed1cdcc 100644 --- a/panel-plugin/weather-summary.c +++ b/panel-plugin/weather-summary.c @@ -328,7 +328,7 @@ create_summary_tab(plugin_data *data) gchar *value, *rawvalue, *wind; gchar *last_download, *next_download; gchar *interval_start, *interval_end, *point; - gchar *sunrise, *sunset, *moonrise, *moonset; + gchar *sunrise, *sunset, *moonrise, *moonset, *moonrisenext, *moonsetnext; summary_details *sum; sum = g_slice_new0(summary_details); @@ -480,6 +480,16 @@ create_summary_tab(plugin_data *data) value = g_strdup_printf(_("\tMoonset:\t%s\n"), moonset); g_free(moonset); APPEND_TEXT_ITEM_REAL(value); + + moonrisenext = format_date(data->current_astro->moonrisenext, NULL, TRUE); + value = g_strdup_printf(_("\tNext Moonrise:\t%s\n"), moonrisenext); + g_free(moonrisenext); + APPEND_TEXT_ITEM_REAL(value); + + moonsetnext = format_date(data->current_astro->moonsetnext, NULL, TRUE); + value = g_strdup_printf(_("\tNext Moonset:\t%s\n"), moonsetnext); + g_free(moonsetnext); + APPEND_TEXT_ITEM_REAL(value); } } else { value = g_strdup(_("\tData not available, will use sane " @@ -704,7 +714,7 @@ static gchar * forecast_day_header_tooltip_text(xml_astro *astro) { GString *text; - gchar *result, *day, *sunrise, *sunset, *moonrise, *moonset; + gchar *result, *day, *sunrise, *sunset, *moonrise, *moonset, *moonrisenext, *moonsetnext; /* TRANSLATORS: Please use spaces as needed or desired to properly align the values; Monospace font is enforced with tags for @@ -771,6 +781,18 @@ forecast_day_header_tooltip_text(xml_astro *astro) "Moonset: %s" ""), moonset); g_free(moonset); + + moonrisenext = format_date(astro->moonrisenext, NULL, TRUE); + g_string_append_printf(text, _("" + "Next Moonrise: %s" + ""), moonrisenext); + g_free(moonrisenext); + + moonsetnext = format_date(astro->moonsetnext, NULL, TRUE); + g_string_append_printf(text, _("" + "Next Moonset: %s" + ""), moonsetnext); + g_free(moonsetnext); } } diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c index 4de36e3..345af04 100644 --- a/panel-plugin/weather.c +++ b/panel-plugin/weather.c @@ -619,7 +619,7 @@ update_handler(plugin_data *data) end_tm = *localtime(&end_t); /* build url */ - url = g_strdup_printf("http://api.yr.no/weatherapi/sunrise/1.0/?" + url = g_strdup_printf("http://api.yr.no/weatherapi/sunrise/1.1/?" "lat=%s;lon=%s;" "from=%04d-%02d-%02d;" "to=%04d-%02d-%02d", @@ -1045,7 +1045,7 @@ write_cache_file(plugin_data *data) xml_time *timeslice; xml_location *loc; xml_astro *astro; - gchar *file, *start, *end, *point, *now, *value; + gchar *file, *start, *end, *snext, *enext, *point, *now, *value; gchar *date_format = "%Y-%m-%dT%H:%M:%SZ"; time_t now_t = time(NULL); gint i, j; @@ -1097,8 +1097,12 @@ write_cache_file(plugin_data *data) start = format_date(astro->moonrise, date_format, FALSE); end = format_date(astro->moonset, date_format, FALSE); + snext = format_date(astro->moonrisenext, date_format, FALSE); + enext = format_date(astro->moonsetnext, date_format, FALSE); CACHE_APPEND("moonrise=%s\n", start); CACHE_APPEND("moonset=%s\n", end); + CACHE_APPEND("moonrisenext=%s\n", end); + CACHE_APPEND("moonsetnext=%s\n", end); CACHE_APPEND("moon_never_rises=%s\n", astro->moon_never_rises ? "true" : "false"); CACHE_APPEND("moon_never_sets=%s\n", @@ -1283,6 +1287,12 @@ read_cache_file(plugin_data *data) CACHE_READ_STRING(timestring, "moonset"); astro->moonset = parse_timestring(timestring, NULL, FALSE); g_free(timestring); + CACHE_READ_STRING(timestring, "moonrisenext"); + astro->moonrisenext = parse_timestring(timestring, NULL, FALSE); + g_free(timestring); + CACHE_READ_STRING(timestring, "moonsetnext"); + astro->moonsetnext = parse_timestring(timestring, NULL, FALSE); + g_free(timestring); CACHE_READ_STRING(astro->moon_phase, "moon_phase"); astro->moon_never_rises = g_key_file_get_boolean(keyfile, group, "moon_never_rises", NULL);