Updating branch refs/heads/master to 683de85dc95a128c32ee20a885efba8667b9d27f (commit) from 370991e9d84fb678e3d2e143b5bf7a64ab68e775 (commit)
commit 683de85dc95a128c32ee20a885efba8667b9d27f Author: Harald Judt <h.j...@gmx.at> Date: Wed Jan 2 17:49:19 2013 +0100 New value: Dew point. The user can now add the dew point value to the scrollbox via the configuration dialog. panel-plugin/weather-config.c | 3 ++- panel-plugin/weather-data.c | 24 ++++++++++++++++++++++++ panel-plugin/weather-data.h | 1 + panel-plugin/weather-summary.c | 10 +++++++--- panel-plugin/weather.c | 3 +++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c index a531068..489c6a5 100644 --- a/panel-plugin/weather-config.c +++ b/panel-plugin/weather-config.c @@ -32,7 +32,7 @@ #include "weather-scrollbox.h" #define UPDATE_TIMER_DELAY 7 -#define OPTIONS_N 13 +#define OPTIONS_N 14 #define BORDER 4 #define LOC_NAME_MAX_LEN 50 @@ -99,6 +99,7 @@ static const labeloption labeloptions[OPTIONS_N] = { {N_("Wind direction (WD)"), WIND_DIRECTION}, {N_("Wind direction in degrees (WD)"), WIND_DIRECTION_DEG}, {N_("Humidity (H)"), HUMIDITY}, + {N_("Dew point (D)"), DEWPOINT}, {N_("Low clouds (CL)"), CLOUDS_LOW}, {N_("Medium clouds (CM)"), CLOUDS_MED}, {N_("High clouds (CH)"), CLOUDS_HIGH}, diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c index ab7d45f..a42a309 100644 --- a/panel-plugin/weather-data.c +++ b/panel-plugin/weather-data.c @@ -21,6 +21,7 @@ #endif #include <libxfce4util/libxfce4util.h> +#include <math.h> #include "weather-parsers.h" #include "weather-data.h" @@ -148,6 +149,22 @@ timeslice_is_interval(xml_time *timeslice) } +/* + * Calculate dew point in Celsius, taking the Magnus formulae as a + * basis. Source: http://de.wikipedia.org/wiki/Taupunkt + */ +static gdouble +calc_dewpoint(const xml_location *loc) +{ + gdouble temp = string_to_double(loc->temperature_value, 0); + gdouble humidity = string_to_double(loc->humidity_value, 0); + gdouble val = log(humidity / 100); + + return (241.2 * val + 4222.03716 * temp / (241.2 + temp)) + / (17.5043 - val - 17.5043 * temp / (241.2 + temp)); +} + + gchar * get_data(const xml_time *timeslice, const units_config *units, @@ -232,6 +249,12 @@ get_data(const xml_time *timeslice, case HUMIDITY: return LOCALE_DOUBLE(loc->humidity_value, ROUND_TO_INT("%.1f")); + case DEWPOINT: + val = calc_dewpoint(loc); + if (units->temperature == FAHRENHEIT) + val = val * 9.0 / 5.0 + 32.0; + return g_strdup_printf(ROUND_TO_INT("%.1f"), val); + case CLOUDS_LOW: return LOCALE_DOUBLE(loc->clouds_percent[CLOUDS_PERC_LOW], ROUND_TO_INT("%.1f")); @@ -276,6 +299,7 @@ get_unit(const units_config *units, case ALTITUDE: return (units->altitude == FEET) ? _("ft") : _("m"); case TEMPERATURE: + case DEWPOINT: return (units->temperature == FAHRENHEIT) ? _("°F") : _("°C"); case PRESSURE: switch (units->pressure) { diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h index 03be37c..9d7d32a 100644 --- a/panel-plugin/weather-data.h +++ b/panel-plugin/weather-data.h @@ -32,6 +32,7 @@ typedef enum { WIND_DIRECTION, WIND_DIRECTION_DEG, HUMIDITY, + DEWPOINT, CLOUDS_LOW, CLOUDS_MED, CLOUDS_HIGH, diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c index 6c51bc4..0fb2950 100644 --- a/panel-plugin/weather-summary.c +++ b/panel-plugin/weather-summary.c @@ -342,7 +342,7 @@ create_summary_tab(plugin_data *data) point = format_date(conditions->point, NULL, TRUE); value = g_strdup_printf - (_("\tTemperature, wind, atmosphere and cloud data calculated\n" + (_("\tTemperatures, wind, atmosphere and cloud data calculated\n" "\tfor:\t\t\t%s\n"), point); g_free(point); @@ -415,9 +415,10 @@ create_summary_tab(plugin_data *data) APPEND_TEXT_ITEM_REAL(value); } - /* temperature */ - APPEND_BTEXT(_("\nTemperature\n")); + /* temperatures */ + APPEND_BTEXT(_("\nTemperatures\n")); APPEND_TEXT_ITEM(_("Temperature"), TEMPERATURE); + APPEND_TEXT_ITEM(_("Dew point"), DEWPOINT); /* wind */ APPEND_BTEXT(_("\nWind\n")); @@ -540,6 +541,9 @@ forecast_cell_get_tooltip_text(plugin_data *data, g_string_append_printf(text, _("Data calculated for:\t%s\n\n"), value); g_free(value); + g_string_append(text, _("<b>Temperatures</b>\n")); + APPEND_TOOLTIP_ITEM(_("Dew point:\t\t\t%s%s%s\n\n"), DEWPOINT); + g_string_append(text, _("<b>Atmosphere</b>\n")); APPEND_TOOLTIP_ITEM(_("Pressure:\t%s%s%s\n"), PRESSURE); APPEND_TOOLTIP_ITEM(_("Humidity:\t%s%s%s\n\n"), HUMIDITY); diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c index e6d64b5..9bf464c 100644 --- a/panel-plugin/weather.c +++ b/panel-plugin/weather.c @@ -133,6 +133,9 @@ make_label(const plugin_data *data, case HUMIDITY: lbl = _("H"); break; + case DEWPOINT: + lbl = _("D"); + break; case CLOUDS_LOW: lbl = _("CL"); break; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits