From 4138abc3ebb024c3f3b5c3063cca669a60147f6b Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Mon, 9 Jul 2001 20:08:30 +0000 Subject: Get a lovely icon from jimmac for the type of weather svn path=/trunk/; revision=10929 --- my-evolution/ChangeLog | 7 ++++++ my-evolution/e-summary-weather.c | 8 ++++-- my-evolution/metar.c | 54 ++++++++++++++++++++++++++++++++++++++++ my-evolution/metar.h | 1 + 4 files changed, 68 insertions(+), 2 deletions(-) (limited to 'my-evolution') diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index deb5c70ba6..5ff8803b45 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,3 +1,10 @@ +2001-07-09 Iain Holmes + + * e-summary-weather.c (weather_make_html): Get an icon for the weather. + + * metar.[ch] (icon_from_weather): Work out what icon for a specific + weather type. + 2001-07-09 Iain Holmes * e-summary-rdf.c (tree_walk): Fix HTML so it doesn't give the big black diff --git a/my-evolution/e-summary-weather.c b/my-evolution/e-summary-weather.c index 164278fe50..47d077212a 100644 --- a/my-evolution/e-summary-weather.c +++ b/my-evolution/e-summary-weather.c @@ -86,9 +86,13 @@ weather_make_html (Weather *w) GString *string; ESummaryWeatherLocation *location; char *sky, *temp, *cond, *uri, *url, *s; + char *icon_name; - string = g_string_new ("
 "); + icon_name = icon_from_weather (w); + g_print ("icon_name: %s\n", icon_name); + string = g_string_new (""); + g_string_sprintf (string, "
 ", icon_name); location = g_hash_table_lookup (locations_hash, w->location); if (location == NULL) { url = make_url (w->location, w->location); diff --git a/my-evolution/metar.c b/my-evolution/metar.c index ee99816e00..34ed397a19 100644 --- a/my-evolution/metar.c +++ b/my-evolution/metar.c @@ -611,3 +611,57 @@ metar_tok_cond (gchar *tokp, return TRUE; } + +const char * +icon_from_weather (Weather *w) +{ + ESummaryWeatherConditions cond = w->cond; + ESummaryWeatherSky sky = w->sky; + + switch (cond.phenomenon) { + case PHENOMENON_DRIZZLE: + case PHENOMENON_RAIN: + case PHENOMENON_UNKNOWN_PRECIPITATION: + case PHENOMENON_HAIL: + case PHENOMENON_SMALL_HAIL: + return "myweather-rain.png"; + case PHENOMENON_SNOW: + case PHENOMENON_SNOW_GRAINS: + case PHENOMENON_ICE_PELLETS: + case PHENOMENON_ICE_CRYSTALS: + return "myweather-snow.png"; + case PHENOMENON_TORNADO: + case PHENOMENON_SQUALL: + return "myweather-storm.png"; + case PHENOMENON_MIST: + case PHENOMENON_FOG: + case PHENOMENON_SMOKE: + case PHENOMENON_VOLCANIC_ASH: + case PHENOMENON_SAND: + case PHENOMENON_HAZE: + case PHENOMENON_SPRAY: + case PHENOMENON_DUST: + case PHENOMENON_SANDSTORM: + case PHENOMENON_DUSTSTORM: + case PHENOMENON_FUNNEL_CLOUD: + case PHENOMENON_DUST_WHIRLS: + return "myweather-fog.png"; + default: + break; + } + + switch (sky) { + case SKY_CLEAR: + return "myweather-sun.png"; + case SKY_BROKEN: + case SKY_SCATTERED: + case SKY_FEW: + return "myweather-suncloud.png"; + case SKY_OVERCAST: + return "myweather-clouds.png"; + default: + break; + } + + return "es-weather.png"; +} diff --git a/my-evolution/metar.h b/my-evolution/metar.h index cbbb8f9550..91ec15d2a1 100644 --- a/my-evolution/metar.h +++ b/my-evolution/metar.h @@ -28,6 +28,7 @@ const char *weather_sky_string (Weather *w); char *weather_temp_string (Weather *w); const char *weather_conditions_string (Weather *w); const char *weather_wind_direction_string (Weather *w); +const char *icon_from_weather (Weather *w); void metar_init_re (void); gboolean metar_tok_time (char *token, -- cgit